-
Notifications
You must be signed in to change notification settings - Fork 1
/
tailwind-preset.ts
99 lines (93 loc) · 3.45 KB
/
tailwind-preset.ts
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import colors from 'tailwindcss/colors';
import defaultTheme from 'tailwindcss/defaultTheme';
import { parseColor } from 'tailwindcss/lib/util/color';
import { PresetsConfig } from 'tailwindcss/types/config';
function toRgb(color: unknown) {
return parseColor(color).color.join(' ');
}
function toRgbObject(colors: Record<string, unknown>) {
return Object.entries(colors).reduce((obj, [name, color]) => ({ ...obj, [name]: toRgb(color) }), {});
}
const commonColors = {
inherit: colors.inherit,
transparent: colors.transparent,
current: colors.current,
white: colors.white,
black: colors.black,
};
const backgroundColors = {
neutral: 'rgb(var(--color-background-neutral) / <alpha-value>)',
inverted: 'rgb(var(--color-background-inverted) / <alpha-value>)',
red: 'rgb(var(--color-background-red) / <alpha-value>)',
green: 'rgb(var(--color-background-green) / <alpha-value>)',
blue: 'rgb(var(--color-background-blue) / <alpha-value>)',
orange: 'rgb(var(--color-background-orange) / <alpha-value>)',
gray: 'rgb(var(--color-background-gray) / <alpha-value>)',
};
const contrastColors = {
red: 'rgb(var(--color-text-red-contrast) / <alpha-value>)',
green: 'rgb(var(--color-text-green-contrast) / <alpha-value>)',
blue: 'rgb(var(--color-text-blue-contrast) / <alpha-value>)',
orange: 'rgb(var(--color-text-orange-contrast) / <alpha-value>)',
gray: 'rgb(var(--color-text-gray-contrast) / <alpha-value>)',
popover: 'rgb(var(--color-text-popover-contrast) / <alpha-value>)',
};
export default {
theme: {
colors: {
rgb: {
white: toRgb(colors.white),
black: toRgb(colors.black),
zinc: toRgbObject(colors.zinc),
gray: toRgbObject(colors.gray),
stone: toRgbObject(colors.stone),
neutral: toRgbObject(colors.neutral),
red: toRgbObject(colors.red),
amber: toRgbObject(colors.amber),
emerald: toRgbObject(colors.emerald),
sky: toRgbObject(colors.sky),
},
...commonColors,
...backgroundColors,
},
backgroundColor: {
...commonColors,
...backgroundColors,
muted: 'rgb(var(--color-background-muted) / <alpha-value>)',
popover: 'rgb(var(--color-background-popover) / <alpha-value>)',
},
textColor: {
...commonColors,
default: 'rgb(var(--color-text-default) / <alpha-value>)',
inverted: 'rgb(var(--color-text-inverted) / <alpha-value>)',
dim: 'rgb(var(--color-text-dim) / <alpha-value>)',
placeholder: 'rgb(var(--color-text-placeholder) / <alpha-value>)',
red: 'rgb(var(--color-text-red) / <alpha-value>)',
green: 'rgb(var(--color-text-green) / <alpha-value>)',
blue: 'rgb(var(--color-text-blue) / <alpha-value>)',
orange: 'rgb(var(--color-text-orange) / <alpha-value>)',
gray: 'rgb(var(--color-text-gray) / <alpha-value>)',
contrast: contrastColors,
},
borderColor: {
...commonColors,
...backgroundColors,
default: 'rgb(var(--color-border-default) / <alpha-value>)',
strong: 'rgb(var(--color-border-strong) / <alpha-value>)',
contrast: contrastColors,
},
fontFamily: {
sans: ['Inter Variable', ...defaultTheme.fontFamily.sans],
mono: ['JetBrains Mono Variable', ...defaultTheme.fontFamily.mono],
gilroy: ['Gilroy', ...defaultTheme.fontFamily.sans],
},
extend: {
spacing: {
em: '1em',
},
boxShadow: {
badge: '0 0 2px rgba(0, 0, 0, 0.55)',
},
},
},
} satisfies PresetsConfig;