diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9a9949b Binary files /dev/null and b/.DS_Store differ diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..85a570b Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/index.ts b/src/index.ts index 162f4d7..1bddae4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -79,11 +79,20 @@ async function main() { } // Install tremor - const dependenciesSpinner = ora(`Installing @tremor/react...`).start(); + const tremorSpinner = ora(`Installing @tremor/react...`).start(); await execa(packageManager, [ packageManager === "npm" ? "install" : "add", "@tremor/react", ]); + tremorSpinner.succeed(); + + const dependenciesSpinner = ora( + `Installing Tailwind CSS dependency...` + ).start(); + await execa(packageManager, [ + packageManager === "npm" ? "install" : "add", + "-D @tailwindcss/forms", + ]); dependenciesSpinner.succeed(); const tailwindDestination = "./tailwind.config.js"; diff --git a/src/templates.ts b/src/templates.ts index 4fca683..3d055a5 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -38,35 +38,35 @@ export const CONTENT_REFINE = `[ "./node_modules/@tremor/**/*.{js,ts,jsx,tsx}", ]`; -export const SAFELIST = `[ - { - pattern: - /^(bg-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, - variants: ["hover", "ui-selected"], - }, - { - pattern: - /^(text-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, - variants: ["hover", "ui-selected"], - }, - { - pattern: - /^(border-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, - variants: ["hover", "ui-selected"], - }, - { - pattern: - /^(ring-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, - }, - { - pattern: - /^(stroke-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, - }, - { - pattern: - /^(fill-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, - }, - ]`; +export const SAFELIST = `safelist: [ + { + pattern: + /^(bg-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, + variants: ["hover", "ui-selected"], + }, + { + pattern: + /^(text-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, + variants: ["hover", "ui-selected"], + }, + { + pattern: + /^(border-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, + variants: ["hover", "ui-selected"], + }, + { + pattern: + /^(ring-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, + }, + { + pattern: + /^(stroke-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, + }, + { + pattern: + /^(fill-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, + }, +],`; export const THEME = `{ transparent: "transparent", @@ -76,61 +76,61 @@ export const THEME = `{ // light mode tremor: { brand: { - faint: "#eff6ff", // blue-50 - muted: "#bfdbfe", // blue-200 - subtle: "#60a5fa", // blue-400 - DEFAULT: "#3b82f6", // blue-500 - emphasis: "#1d4ed8", // blue-700 - inverted: "#ffffff", // white + faint: colors.blue[50], + muted: colors.blue[200], + subtle: colors.blue[400], + DEFAULT: colors.blue[500], + emphasis: colors.blue[700], + inverted: colors.white, }, background: { - muted: "#f9fafb", // gray-50 - subtle: "#f3f4f6", // gray-100 - DEFAULT: "#ffffff", // white - emphasis: "#374151", // gray-700 + muted: colors.gray[50], + subtle: colors.gray[100], + DEFAULT: colors.white, + emphasis: colors.gray[700], }, border: { - DEFAULT: "#e5e7eb", // gray-200 + DEFAULT: colors.gray[200], }, ring: { - DEFAULT: "#e5e7eb", // gray-200 + DEFAULT: colors.gray[200], }, content: { - subtle: "#9ca3af", // gray-400 - DEFAULT: "#6b7280", // gray-500 - emphasis: "#374151", // gray-700 - strong: "#111827", // gray-900 - inverted: "#ffffff", // white + subtle: colors.gray[400], + DEFAULT: colors.gray[500], + emphasis: colors.gray[700], + strong: colors.gray[900], + inverted: colors.white, }, }, // dark mode "dark-tremor": { brand: { - faint: "#0B1229", // custom - muted: "#172554", // blue-950 - subtle: "#1e40af", // blue-800 - DEFAULT: "#3b82f6", // blue-500 - emphasis: "#60a5fa", // blue-400 - inverted: "#030712", // gray-950 + faint: "#0B1229", + muted: colors.blue[950], + subtle: colors.blue[800], + DEFAULT: colors.blue[500], + emphasis: colors.blue[400], + inverted: colors.gray[950], }, background: { - muted: "#131A2B", // custom - subtle: "#1f2937", // gray-800 - DEFAULT: "#111827", // gray-900 - emphasis: "#d1d5db", // gray-300 + muted: "#131A2B", + subtle: colors.gray[800], + DEFAULT: colors.gray[900], + emphasis: colors.gray[300], }, border: { - DEFAULT: "#1f2937", // gray-800 + DEFAULT: colors.gray[800], }, ring: { - DEFAULT: "#1f2937", // gray-800 + DEFAULT: colors.gray[800], }, content: { - subtle: "#4b5563", // gray-600 - DEFAULT: "#6b7280", // gray-600 - emphasis: "#e5e7eb", // gray-200 - strong: "#f9fafb", // gray-50 - inverted: "#000000", // black + subtle: colors.gray[600], + DEFAULT: colors.gray[600], + emphasis: colors.gray[200], + strong: colors.gray[50], + inverted: colors.black, }, }, }, @@ -150,10 +150,12 @@ export const THEME = `{ "tremor-full": "9999px", }, fontSize: { - "tremor-label": ["0.75rem"], + "tremor-label": ["0.75rem", { lineHeight: "1rem" }], "tremor-default": ["0.875rem", { lineHeight: "1.25rem" }], "tremor-title": ["1.125rem", { lineHeight: "1.75rem" }], "tremor-metric": ["1.875rem", { lineHeight: "2.25rem" }], }, }, }`; + +export const PLUGINS = `[require('@headlessui/tailwindcss'), require('@tailwindcss/forms')],`; diff --git a/src/utils/get-tailwind-config.ts b/src/utils/get-tailwind-config.ts index b151ec8..e506848 100644 --- a/src/utils/get-tailwind-config.ts +++ b/src/utils/get-tailwind-config.ts @@ -8,6 +8,7 @@ import { CONTENT_VITE, SAFELIST, THEME, + PLUGINS, } from "../templates"; import { FrameworkConfigType } from "../types"; @@ -24,12 +25,13 @@ const tailwindContentConfigs: { [key in FrameworkConfigType]: string } = { export const getTailwindConfig = (frameworkConfigType: FrameworkConfigType) => { const contentConfig = tailwindContentConfigs[frameworkConfigType]; return `/** @type {import('tailwindcss').Config} */ +const colors = require('tailwindcss/colors'); /* eslint-disable max-len */ module.exports = { content: ${contentConfig}, theme: ${THEME}, safelist: ${SAFELIST}, - plugins: [require("@headlessui/tailwindcss")], + plugins: ${PLUGINS}, }; `; };