forked from AsakuraMizu/unocss-preset-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.ts
49 lines (43 loc) · 1.44 KB
/
theme.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
export const colorNamesCore = ['primary', 'secondary', 'tertiary'];
export const colorNamesCoreRe = `(${colorNamesCore.join('|')})`;
export const colorNamesState = ['success', 'warning', 'error'];
export const colorNamesStateRe = `(${colorNamesState.join('|')})`;
export const colorNames = [...colorNamesCore, ...colorNamesState, 'surface'];
export const colorNamesRe = `(${colorNames.join('|')})`;
export const colorShades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
export const colors = Object.fromEntries(
colorNames.map((name) => [
name,
Object.fromEntries(
colorShades.map((shade) => [shade, `rgba(var(--color-${name}-${shade}), %alpha)`]),
),
]),
);
colors.on = {};
colorNames.forEach((color) => {
colors[color].DEFAULT ||= colors[color][400] as string;
colorShades.forEach((shade) => {
const short = +shade / 100;
if (short === Math.round(short)) colors[color][short] = colors[color][shade];
});
colors.on[color] = `rgb(var(--on-${color}))`;
});
colors.theme = {
base: 'rgba(var(--theme-font-color-base), %alpha)',
dark: 'rgba(var(--theme-font-color-dark), %alpha)',
};
const theme: object = {
colors,
fontFamily: {
base: 'var(--theme-font-family-base)',
heading: 'var(--theme-font-family-heading)',
},
borderRadius: {
base: 'var(--theme-rounded-base)',
container: 'var(--theme-rounded-container)',
},
lineWidth: {
base: 'var(--theme-border-base)',
},
};
export default theme;