-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtailwind.config.cjs
71 lines (67 loc) · 1.66 KB
/
tailwind.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Radix UI color system (https://www.radix-ui.com/colors)
const radixColors = require('@radix-ui/colors');
// Transform Radix color to object suitable for Tailwind CSS theme
// Filter out transparent palettes (eg 'tomatoA')
const getRadixUiPalette = (color) =>
Object.entries(radixColors[color])
.filter(([color]) => !color.match(/.*A\d+$/))
.reduce((paletteObject, [colorName, colorValue]) => {
paletteObject[colorName.replace(/\D/g, '')] = colorValue;
return paletteObject;
}, {});
const getLightDarkTuples = (tailwindName, radixName) => ({
[tailwindName]: getRadixUiPalette(radixName),
[`${tailwindName}-dark`]: getRadixUiPalette(`${radixName}Dark`),
});
// map Tailwind colors (name) to Radix colors (value)
const radixColorNames = {
surface: 'sage',
gray: 'gray',
mauve: 'mauve',
slate: 'slate',
sage: 'sage',
olive: 'olive',
sand: 'sand',
tomato: 'tomato',
red: 'red',
crimson: 'crimson',
pink: 'pink',
plum: 'plum',
purple: 'purple',
violet: 'violet',
indigo: 'indigo',
blue: 'blue',
cyan: 'cyan',
teal: 'teal',
green: 'green',
grass: 'grass',
brown: 'brown',
orange: 'orange',
sky: 'sky',
mint: 'mint',
lime: 'lime',
yellow: 'yellow',
amber: 'amber',
gold: 'gold',
bronze: 'bronze',
};
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{html,js,svelte,ts}'],
theme: {
colors: {
white: '#ffffff',
black: '#000000',
transparent: 'transparent',
current: 'currentColor',
...Object.entries(radixColorNames).reduce(
(tailwindColors, [tailwindName, radixName]) => ({
...tailwindColors,
...getLightDarkTuples(tailwindName, radixName),
}),
{},
),
},
},
plugins: [],
};