From 65759d510ae7840ec1aedda72db98b5da9c06ed8 Mon Sep 17 00:00:00 2001 From: Matt Cowley Date: Wed, 27 Nov 2024 22:26:39 +0000 Subject: [PATCH] Fix Tailwind extend not being inside theme (#82) * Fix Tailwind extend not being inside theme * Improve type-safety for preset config * New patch version --- package-lock.json | 4 ++-- package.json | 2 +- src/tailwind.ts | 55 +++++++++++++++++++++++++++++++---------------- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 328af0b..e7786f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@alveusgg/data", - "version": "0.43.0", + "version": "0.43.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@alveusgg/data", - "version": "0.43.0", + "version": "0.43.1", "license": "SEE LICENSE IN LICENSE.md", "devDependencies": { "@typescript-eslint/eslint-plugin": "^6.2.0", diff --git a/package.json b/package.json index 5da3aef..248ecaf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@alveusgg/data", - "version": "0.43.0", + "version": "0.43.1", "private": true, "license": "SEE LICENSE IN LICENSE.md", "repository": { diff --git a/src/tailwind.ts b/src/tailwind.ts index 9121184..eedbd9a 100644 --- a/src/tailwind.ts +++ b/src/tailwind.ts @@ -1,5 +1,24 @@ import type { PresetsConfig } from "tailwindcss/types/config"; +// Thanks https://stackoverflow.com/a/66252656 +type RemoveIndex = { + [K in keyof T as string extends K + ? never + : number extends K + ? never + : symbol extends K + ? never + : K]: T[K]; +}; + +type RefinedConfig = Omit, "theme"> & { + theme?: Omit>, "extend"> & { + extend?: RemoveIndex< + NonNullable["extend"]> + >; + }; +}; + const config = { theme: { colors: { @@ -121,25 +140,25 @@ const config = { twitch: "#6441A5", highlight: "#FF9F1C", }, - }, - extend: { - gridTemplateColumns: { - ...Object.fromEntries( - Array.from({ length: 12 }, (_, i) => [ - `${i + 1}-auto`, - `repeat(${i + 1}, auto)`, - ]), - ), - }, - gridTemplateRows: { - ...Object.fromEntries( - Array.from({ length: 12 }, (_, i) => [ - `${i + 1}-auto`, - `repeat(${i + 1}, auto)`, - ]), - ), + extend: { + gridTemplateColumns: { + ...Object.fromEntries( + Array.from({ length: 12 }, (_, i) => [ + `${i + 1}-auto`, + `repeat(${i + 1}, auto)`, + ]), + ), + }, + gridTemplateRows: { + ...Object.fromEntries( + Array.from({ length: 12 }, (_, i) => [ + `${i + 1}-auto`, + `repeat(${i + 1}, auto)`, + ]), + ), + }, }, }, -} satisfies PresetsConfig; +} satisfies RefinedConfig; export default config;