Skip to content

Commit 24255db

Browse files
committed
1,657th Commit
1 parent 38a55e8 commit 24255db

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

app/vite.config.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,29 @@ export default defineConfig({
3535
transformers: [transformerDirectives({ enforce: 'pre' })],
3636
theme: {
3737
colors: {
38-
primary: tailwindColors.indigo,
38+
/**
39+
* Defines a dynamic primary color palette based on Tailwind CSS's colors.
40+
*
41+
* ```ts
42+
* import tailwindColors from 'tailwindcss/colors';
43+
*
44+
* type ColorPalette = (typeof tailwindColors)[keyof typeof tailwindColors];
45+
*
46+
* function setPrimaryPalette(palette: ColorPalette) {
47+
* for (const [shade, color] of Object.entries(palette)) {
48+
* document.documentElement.style.setProperty(`--color-primary-${shade}`, color);
49+
* }
50+
* }
51+
*
52+
* setPrimaryPalette(tailwindColors.violet);
53+
* ```
54+
*/
55+
primary: Object.fromEntries(
56+
Object.entries(tailwindColors.indigo).map(([shade, color]) => [
57+
shade,
58+
`var(--color-primary-${shade}, ${color})`,
59+
]),
60+
),
3961
secondary: tailwindColors.neutral,
4062
success: tailwindColors.emerald,
4163
danger: tailwindColors.rose,

0 commit comments

Comments
 (0)