@autofleet/theme 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/package.json +2 -3
- package/project.json +40 -0
- package/src/colors/atomic-colors.ts +169 -0
- package/src/colors/index.ts +31 -0
- package/src/colors/tokens/color-token-mapping.ts +909 -0
- package/src/colors/tokens/color-tokens.ts +110 -0
- package/src/colors-utils.ts +196 -0
- package/src/const.ts +4 -0
- package/src/fonts/atomic-fonts.ts +102 -0
- package/src/fonts/index.ts +22 -0
- package/src/index.ts +38 -0
- package/src/shadow/{index.js → index.ts} +32 -11
- package/src/spacing/border-radius.ts +8 -0
- package/src/spacing/{index.js → index.ts} +3 -3
- package/src/spacing/spacing.ts +15 -0
- package/tsconfig.json +22 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +20 -0
- package/vite.config.ts +15 -0
- package/src/colors/atomic-colors.d.ts +0 -132
- package/src/colors/atomic-colors.js +0 -150
- package/src/colors/atomic-colors.js.map +0 -1
- package/src/colors/index.d.ts +0 -12
- package/src/colors/index.js +0 -12
- package/src/colors/index.js.map +0 -1
- package/src/colors/tokens/color-token-mapping.d.ts +0 -8
- package/src/colors/tokens/color-token-mapping.js +0 -885
- package/src/colors/tokens/color-token-mapping.js.map +0 -1
- package/src/colors/tokens/color-tokens.d.ts +0 -17
- package/src/colors/tokens/color-tokens.js +0 -97
- package/src/colors/tokens/color-tokens.js.map +0 -1
- package/src/colors-utils.d.ts +0 -57
- package/src/colors-utils.js +0 -104
- package/src/colors-utils.js.map +0 -1
- package/src/const.d.ts +0 -4
- package/src/const.js +0 -5
- package/src/const.js.map +0 -1
- package/src/fonts/atomic-fonts.d.ts +0 -13
- package/src/fonts/atomic-fonts.js +0 -75
- package/src/fonts/atomic-fonts.js.map +0 -1
- package/src/fonts/index.d.ts +0 -20
- package/src/fonts/index.js +0 -22
- package/src/fonts/index.js.map +0 -1
- package/src/index.d.ts +0 -76
- package/src/index.js +0 -15
- package/src/index.js.map +0 -1
- package/src/shadow/index.d.ts +0 -19
- package/src/shadow/index.js.map +0 -1
- package/src/spacing/border-radius.d.ts +0 -8
- package/src/spacing/border-radius.js +0 -9
- package/src/spacing/border-radius.js.map +0 -1
- package/src/spacing/index.d.ts +0 -25
- package/src/spacing/index.js.map +0 -1
- package/src/spacing/spacing.d.ts +0 -15
- package/src/spacing/spacing.js +0 -16
- package/src/spacing/spacing.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export const COLOR_TOKENS = [
|
|
2
|
+
'bg-primary',
|
|
3
|
+
'bg-secondary',
|
|
4
|
+
'bg-info',
|
|
5
|
+
'bg-success',
|
|
6
|
+
'bg-warning',
|
|
7
|
+
'bg-error',
|
|
8
|
+
'divider-neutral',
|
|
9
|
+
'divider-invert',
|
|
10
|
+
'divider-brand',
|
|
11
|
+
'divider-info',
|
|
12
|
+
'divider-success',
|
|
13
|
+
'divider-warning',
|
|
14
|
+
'divider-error',
|
|
15
|
+
'primary-btn',
|
|
16
|
+
'primary-btn-hover',
|
|
17
|
+
'primary-btn-opa-01',
|
|
18
|
+
'primary-btn-opa-02',
|
|
19
|
+
'other',
|
|
20
|
+
'other-hover',
|
|
21
|
+
'other-opa-01',
|
|
22
|
+
'other-opa-02',
|
|
23
|
+
'other-text',
|
|
24
|
+
'neutral',
|
|
25
|
+
'neutral-dark',
|
|
26
|
+
'neutral-text',
|
|
27
|
+
'neutral-charcoal',
|
|
28
|
+
'neutral-light',
|
|
29
|
+
'neutral-invert',
|
|
30
|
+
'neutral-opa-01',
|
|
31
|
+
'neutral-opa-02',
|
|
32
|
+
'info-hover',
|
|
33
|
+
'info',
|
|
34
|
+
'info-opa-01',
|
|
35
|
+
'info-opa-02',
|
|
36
|
+
'info-text',
|
|
37
|
+
'success-hover',
|
|
38
|
+
'success',
|
|
39
|
+
'success-opa-01',
|
|
40
|
+
'success-opa-02',
|
|
41
|
+
'success-text',
|
|
42
|
+
'warning-hover',
|
|
43
|
+
'warning',
|
|
44
|
+
'warning-opa-01',
|
|
45
|
+
'warning-opa-02',
|
|
46
|
+
'warning-text',
|
|
47
|
+
'error-hover',
|
|
48
|
+
'error',
|
|
49
|
+
'error-opa-01',
|
|
50
|
+
'error-opa-02',
|
|
51
|
+
'error-text',
|
|
52
|
+
'purple',
|
|
53
|
+
'purple-opa-01',
|
|
54
|
+
'purple-opa-02',
|
|
55
|
+
'purple-text',
|
|
56
|
+
'orange',
|
|
57
|
+
'orange-opa-01',
|
|
58
|
+
'orange-opa-02',
|
|
59
|
+
'orange-text',
|
|
60
|
+
'turquoise',
|
|
61
|
+
'turquoise-opa-01',
|
|
62
|
+
'turquoise-opa-02',
|
|
63
|
+
'turquoise-text',
|
|
64
|
+
'pink',
|
|
65
|
+
'pink-opa-01',
|
|
66
|
+
'pink-opa-02',
|
|
67
|
+
'pink-text',
|
|
68
|
+
'ultramarine',
|
|
69
|
+
'ultramarine-opa-01',
|
|
70
|
+
'ultramarine-opa-02',
|
|
71
|
+
'ultramarine-text',
|
|
72
|
+
'peach',
|
|
73
|
+
'peach-opa-01',
|
|
74
|
+
'peach-opa-02',
|
|
75
|
+
'peach-text',
|
|
76
|
+
'apple',
|
|
77
|
+
'apple-opa-01',
|
|
78
|
+
'apple-opa-02',
|
|
79
|
+
'apple-text',
|
|
80
|
+
'bubblegum',
|
|
81
|
+
'bubblegum-opa-01',
|
|
82
|
+
'bubblegum-opa-02',
|
|
83
|
+
'bubblegum-text',
|
|
84
|
+
'ocher',
|
|
85
|
+
'ocher-opa-01',
|
|
86
|
+
'ocher-opa-02',
|
|
87
|
+
'ocher-text',
|
|
88
|
+
'blueberry',
|
|
89
|
+
'blueberry-opa-01',
|
|
90
|
+
'blueberry-opa-02',
|
|
91
|
+
'blueberry-text',
|
|
92
|
+
] as const;
|
|
93
|
+
|
|
94
|
+
type NoDash<T> = T extends `${string}-${string}` ? never : T;
|
|
95
|
+
type WithText<T> = T extends `${infer P}-text` ? P : never;
|
|
96
|
+
type COLOR_TOKEN = (typeof COLOR_TOKENS)[number];
|
|
97
|
+
/**
|
|
98
|
+
* Colors that are used as primary colors in the design system.
|
|
99
|
+
*/
|
|
100
|
+
export type MAIN_COLOR_TOKEN = NoDash<COLOR_TOKEN>; // | PrefixNoDash<COLOR_TOKEN>;
|
|
101
|
+
/**
|
|
102
|
+
* {@link MAIN_COLOR_TOKEN} with text colors only. TODO: Maintain this list manually.
|
|
103
|
+
*/
|
|
104
|
+
export type MAIN_COLOR_TOKEN_WITH_TEXT = WithText<COLOR_TOKEN>;
|
|
105
|
+
/**
|
|
106
|
+
* The main colors in the design system, i.e colors that are not shades or opacities.
|
|
107
|
+
*/
|
|
108
|
+
export const mainColorTokens = COLOR_TOKENS.filter(
|
|
109
|
+
(token: COLOR_TOKEN): token is NoDash<COLOR_TOKEN> => !token.includes('-')
|
|
110
|
+
);
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
const RGBToHSL = (color: string) => {
|
|
2
|
+
const colorArray = color.split(',').map((c) => parseInt(c, 10));
|
|
3
|
+
const r = colorArray[0] / 255;
|
|
4
|
+
const g = colorArray[1] / 255;
|
|
5
|
+
const b = colorArray[2] / 255;
|
|
6
|
+
const l = Math.max(r, g, b);
|
|
7
|
+
const s = l - Math.min(r, g, b);
|
|
8
|
+
const h = s
|
|
9
|
+
? l === r
|
|
10
|
+
? (g - b) / s
|
|
11
|
+
: l === g
|
|
12
|
+
? 2 + (b - r) / s
|
|
13
|
+
: 4 + (r - g) / s
|
|
14
|
+
: 0;
|
|
15
|
+
return [
|
|
16
|
+
60 * h < 0 ? 60 * h + 360 : 60 * h,
|
|
17
|
+
100 * (s ? (l <= 0.5 ? s / (2 * l - s) : s / (2 - (2 * l - s))) : 0),
|
|
18
|
+
(100 * (2 * l - s)) / 2,
|
|
19
|
+
];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const HSLToRGB = (h: number, s: number, l: number) => {
|
|
23
|
+
const saturationValue = s / 100;
|
|
24
|
+
const lightnessValue = l / 100;
|
|
25
|
+
const calculateKValue = (n: number) => (n + h / 30) % 12;
|
|
26
|
+
const calculateAValue =
|
|
27
|
+
saturationValue * Math.min(lightnessValue, 1 - lightnessValue);
|
|
28
|
+
const calculateFValue = (n: number) =>
|
|
29
|
+
lightnessValue -
|
|
30
|
+
calculateAValue *
|
|
31
|
+
Math.max(
|
|
32
|
+
-1,
|
|
33
|
+
Math.min(calculateKValue(n) - 3, Math.min(9 - calculateKValue(n), 1))
|
|
34
|
+
);
|
|
35
|
+
const red = 255 * calculateFValue(0);
|
|
36
|
+
const green = 255 * calculateFValue(8);
|
|
37
|
+
const blue = 255 * calculateFValue(4);
|
|
38
|
+
return [red, green, blue];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const adjustBrightness = (color: string) => {
|
|
42
|
+
const hsl = RGBToHSL(color);
|
|
43
|
+
|
|
44
|
+
// Adjust the lightness value
|
|
45
|
+
const adjustedL = hsl[2] + (hsl[2] * -24) / 100;
|
|
46
|
+
|
|
47
|
+
const [r, g, b] = HSLToRGB(hsl[0], hsl[1], adjustedL);
|
|
48
|
+
return `${r}, ${g}, ${b}`;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type ColorVariant = Record<string, string>;
|
|
52
|
+
|
|
53
|
+
interface IColorVariants {
|
|
54
|
+
[key: string]: string | ColorVariant;
|
|
55
|
+
infoColor: string;
|
|
56
|
+
infoColorHover: string;
|
|
57
|
+
infoColorOpacityWeak: string;
|
|
58
|
+
infoColorOpacityStrong: string;
|
|
59
|
+
infoHoverComponentBgColor: string;
|
|
60
|
+
errorColor: string;
|
|
61
|
+
errorColorHover: string;
|
|
62
|
+
errorColorOpacityWeak: string;
|
|
63
|
+
errorColorOpacityStrong: string;
|
|
64
|
+
errorHoverComponentBgColor: string;
|
|
65
|
+
successColor: string;
|
|
66
|
+
successColorHover: string;
|
|
67
|
+
successColorOpacityWeak: string;
|
|
68
|
+
successColorOpacityStrong: string;
|
|
69
|
+
successHoverComponentBgColor: string;
|
|
70
|
+
warningColor: string;
|
|
71
|
+
warningColorHover: string;
|
|
72
|
+
warningColorOpacityWeak: string;
|
|
73
|
+
warningColorOpacityStrong: string;
|
|
74
|
+
warningHoverComponentBgColor: string;
|
|
75
|
+
primaryColor: string;
|
|
76
|
+
primaryColorHover: string;
|
|
77
|
+
primaryColorOpacityWeak: string;
|
|
78
|
+
primaryColorOpacityStrong: string;
|
|
79
|
+
primaryHoverComponentBgColor: string;
|
|
80
|
+
primaryBackgroundText: string;
|
|
81
|
+
primaryBackgroundHoverText: string;
|
|
82
|
+
primaryTextColor: string;
|
|
83
|
+
secondaryTextColor: string;
|
|
84
|
+
disabledTextColor: string;
|
|
85
|
+
placeholderTextColor: string;
|
|
86
|
+
primaryBackgroundColor: string;
|
|
87
|
+
secondaryBackgroundColor: string;
|
|
88
|
+
dividerColor: string;
|
|
89
|
+
secondaryButtonsHoverColor: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const HOVER_COMPONENT_BG_COLORS: Record<string, Record<string, string>> = {
|
|
93
|
+
info: {
|
|
94
|
+
light: 'rgba(231, 246, 255, 1)',
|
|
95
|
+
dark: 'rgba(30, 55, 75, 1)',
|
|
96
|
+
},
|
|
97
|
+
error: {
|
|
98
|
+
light: 'rgba(254, 235, 236, 1)',
|
|
99
|
+
dark: 'rgba(67, 37, 45, 1)',
|
|
100
|
+
},
|
|
101
|
+
success: {
|
|
102
|
+
light: 'rgba(233, 248, 239, 1)',
|
|
103
|
+
dark: 'rgba(34, 58, 50, 1)',
|
|
104
|
+
},
|
|
105
|
+
warning: {
|
|
106
|
+
light: 'rgba(254, 246, 231, 1)',
|
|
107
|
+
dark: 'rgba(68, 55, 37, 1)',
|
|
108
|
+
},
|
|
109
|
+
primary: {
|
|
110
|
+
light: 'rgba(231, 246, 255, 1)',
|
|
111
|
+
dark: 'rgba(30, 55, 75, 1)',
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const createColorVariants = (
|
|
116
|
+
name: string,
|
|
117
|
+
color: string,
|
|
118
|
+
type: 'light' | 'dark'
|
|
119
|
+
) => ({
|
|
120
|
+
[`${name}Color`]: `rgba(${color}, 1)`,
|
|
121
|
+
[`${name}ColorHover`]: `rgba(${adjustBrightness(color)}, 1)`,
|
|
122
|
+
[`${name}ColorOpacityWeak`]: `rgba(${color}, 0.32)`,
|
|
123
|
+
[`${name}ColorOpacityStrong`]: `rgba(${color}, ${type === 'light' ? 0.1 : 0.16
|
|
124
|
+
})`,
|
|
125
|
+
[`${name}HoverComponentBgColor`]: HOVER_COMPONENT_BG_COLORS[name][type],
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const COLORS = [
|
|
129
|
+
['info', '17, 164, 255'],
|
|
130
|
+
['error', '248, 55, 67'],
|
|
131
|
+
['success', '37, 184, 97'],
|
|
132
|
+
['warning', '250, 166, 19'],
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
const getTextContrastColor = (rgb: string) => {
|
|
136
|
+
// Calculate the relative luminance of the background color
|
|
137
|
+
const [r, g, b] = rgb.split(',').map((c: string) => parseInt(c, 10));
|
|
138
|
+
const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
|
|
139
|
+
|
|
140
|
+
// Set the text color based on the contrast ratio
|
|
141
|
+
const textColor = luminance > 0.6 ? '#000000' : '#FFFFFF';
|
|
142
|
+
|
|
143
|
+
return textColor;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const COLORS_DARK_MODE_HANDLED = {
|
|
147
|
+
primaryTextColor: (isDarkMode: boolean): string =>
|
|
148
|
+
isDarkMode ? 'rgba(244, 245, 248, 1)' : 'rgba(33, 34, 41, 1)',
|
|
149
|
+
secondaryTextColor: (isDarkMode: boolean): string =>
|
|
150
|
+
isDarkMode ? 'rgba(173, 174, 186, 1)' : 'rgba(102, 105, 117, 1)',
|
|
151
|
+
disabledTextColor: (isDarkMode: boolean): string =>
|
|
152
|
+
isDarkMode ? 'rgba(102, 105, 117, 1)' : 'rgba(173, 174, 186, 1)',
|
|
153
|
+
placeholderTextColor: (isDarkMode: boolean): string =>
|
|
154
|
+
isDarkMode ? 'rgba(102, 105, 117, 1)' : 'rgba(173, 174, 186, 1)',
|
|
155
|
+
primaryBackgroundColor: (isDarkMode: boolean): string =>
|
|
156
|
+
isDarkMode ? 'rgba(33, 34, 41, 1)' : 'rgba(255, 255, 255, 1)',
|
|
157
|
+
secondaryBackgroundColor: (isDarkMode: boolean): string =>
|
|
158
|
+
isDarkMode ? 'rgba(43, 45, 51, 1)' : 'rgba(244, 245, 248, 1)',
|
|
159
|
+
dividerColor: (isDarkMode: boolean): string =>
|
|
160
|
+
isDarkMode ? 'rgba(125, 139, 172, 0.32)' : 'rgba(125, 139, 172, 0.24)',
|
|
161
|
+
secondaryButtonsHoverColor: (isDarkMode: boolean): string =>
|
|
162
|
+
isDarkMode ? 'rgba(124, 134, 163, 0.16)' : 'rgba(124, 134, 163, 0.1)',
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const buildColorsObject = (type: 'light' | 'dark') =>
|
|
166
|
+
Object.fromEntries(
|
|
167
|
+
Object.entries(COLORS_DARK_MODE_HANDLED).map(
|
|
168
|
+
([colorKey, colorFunction]) => [colorKey, colorFunction(type === 'dark')]
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
export const getColorVariants = (
|
|
173
|
+
givenPrimary: string,
|
|
174
|
+
type: 'light' | 'dark'
|
|
175
|
+
): IColorVariants => {
|
|
176
|
+
const variants: Partial<IColorVariants> = [
|
|
177
|
+
...COLORS,
|
|
178
|
+
['primary', givenPrimary],
|
|
179
|
+
]
|
|
180
|
+
.map(([name, color]) => createColorVariants(name, color, type))
|
|
181
|
+
.reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
182
|
+
return {
|
|
183
|
+
...variants,
|
|
184
|
+
primaryBackgroundText: getTextContrastColor(givenPrimary),
|
|
185
|
+
primaryBackgroundHoverText: getTextContrastColor(
|
|
186
|
+
adjustBrightness(givenPrimary)
|
|
187
|
+
),
|
|
188
|
+
...buildColorsObject(type),
|
|
189
|
+
} as IColorVariants;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export interface RGBColor {
|
|
193
|
+
red: number;
|
|
194
|
+
green: number;
|
|
195
|
+
blue: number;
|
|
196
|
+
}
|
package/src/const.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
interface IFontFormat<
|
|
2
|
+
TSize extends string,
|
|
3
|
+
TStyle extends string,
|
|
4
|
+
TWeight extends string,
|
|
5
|
+
TLineHeight extends string,
|
|
6
|
+
TFamily extends string = string
|
|
7
|
+
> {
|
|
8
|
+
family?: TFamily;
|
|
9
|
+
size: TSize;
|
|
10
|
+
style: TStyle;
|
|
11
|
+
weight: TWeight;
|
|
12
|
+
lineHeight: TLineHeight;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const buildAtomicFontCss = <
|
|
16
|
+
TSize extends string,
|
|
17
|
+
TStyle extends string,
|
|
18
|
+
TWeight extends string,
|
|
19
|
+
TLineHeight extends string,
|
|
20
|
+
TFamily extends string = 'Montserrat, sans-serif !important'
|
|
21
|
+
>({
|
|
22
|
+
size,
|
|
23
|
+
style,
|
|
24
|
+
weight,
|
|
25
|
+
lineHeight,
|
|
26
|
+
family = 'Montserrat, sans-serif !important' as TFamily,
|
|
27
|
+
}: IFontFormat<TSize, TStyle, TWeight, TLineHeight, TFamily>) =>
|
|
28
|
+
`
|
|
29
|
+
font-family: ${family};
|
|
30
|
+
font-size: ${size};
|
|
31
|
+
font-style: ${style};
|
|
32
|
+
font-weight: ${weight};
|
|
33
|
+
line-height: ${lineHeight};` as const;
|
|
34
|
+
|
|
35
|
+
export const ATOMIC_FONTS = {
|
|
36
|
+
'typo-11': buildAtomicFontCss({
|
|
37
|
+
size: '48px',
|
|
38
|
+
style: 'normal',
|
|
39
|
+
weight: '700',
|
|
40
|
+
lineHeight: '60px',
|
|
41
|
+
}),
|
|
42
|
+
'typo-10': buildAtomicFontCss({
|
|
43
|
+
size: '24px',
|
|
44
|
+
style: 'normal',
|
|
45
|
+
weight: '700',
|
|
46
|
+
lineHeight: '60px',
|
|
47
|
+
}),
|
|
48
|
+
'typo-9': buildAtomicFontCss({
|
|
49
|
+
size: '24px',
|
|
50
|
+
style: 'normal',
|
|
51
|
+
weight: '400',
|
|
52
|
+
lineHeight: '30px',
|
|
53
|
+
}),
|
|
54
|
+
'typo-8': buildAtomicFontCss({
|
|
55
|
+
size: '20px',
|
|
56
|
+
style: 'normal',
|
|
57
|
+
weight: '700',
|
|
58
|
+
lineHeight: '26px',
|
|
59
|
+
}),
|
|
60
|
+
'typo-7': buildAtomicFontCss({
|
|
61
|
+
size: '18px',
|
|
62
|
+
style: 'normal',
|
|
63
|
+
weight: '700',
|
|
64
|
+
lineHeight: '24px',
|
|
65
|
+
}),
|
|
66
|
+
'typo-6': buildAtomicFontCss({
|
|
67
|
+
size: '16px',
|
|
68
|
+
style: 'normal',
|
|
69
|
+
weight: '500',
|
|
70
|
+
lineHeight: '24px',
|
|
71
|
+
}),
|
|
72
|
+
'typo-5': buildAtomicFontCss({
|
|
73
|
+
size: '16px',
|
|
74
|
+
style: 'normal',
|
|
75
|
+
weight: '700',
|
|
76
|
+
lineHeight: '24px',
|
|
77
|
+
}),
|
|
78
|
+
'typo-4': buildAtomicFontCss({
|
|
79
|
+
size: '14px',
|
|
80
|
+
style: 'normal',
|
|
81
|
+
weight: '500',
|
|
82
|
+
lineHeight: '20px',
|
|
83
|
+
}),
|
|
84
|
+
'typo-3': buildAtomicFontCss({
|
|
85
|
+
size: '14px',
|
|
86
|
+
style: 'normal',
|
|
87
|
+
weight: '700',
|
|
88
|
+
lineHeight: '20px',
|
|
89
|
+
}),
|
|
90
|
+
'typo-2': buildAtomicFontCss({
|
|
91
|
+
size: '12px',
|
|
92
|
+
style: 'normal',
|
|
93
|
+
weight: '700',
|
|
94
|
+
lineHeight: '16px',
|
|
95
|
+
}),
|
|
96
|
+
'typo-1': buildAtomicFontCss({
|
|
97
|
+
size: '12px',
|
|
98
|
+
style: 'normal',
|
|
99
|
+
weight: '500',
|
|
100
|
+
lineHeight: '16px',
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ATOMIC_FONTS } from './atomic-fonts';
|
|
2
|
+
|
|
3
|
+
export const getThemeFonts = () => ({
|
|
4
|
+
desktop: {
|
|
5
|
+
largeTitle: ATOMIC_FONTS['typo-11'],
|
|
6
|
+
mediumTitle: ATOMIC_FONTS['typo-10'],
|
|
7
|
+
placeHolderTitleInput: ATOMIC_FONTS['typo-9'],
|
|
8
|
+
smallTitle: ATOMIC_FONTS['typo-7'],
|
|
9
|
+
fine: ATOMIC_FONTS['typo-1'],
|
|
10
|
+
fineStrong: ATOMIC_FONTS['typo-2'],
|
|
11
|
+
bodyStrong: ATOMIC_FONTS['typo-3'],
|
|
12
|
+
body: ATOMIC_FONTS['typo-4'],
|
|
13
|
+
},
|
|
14
|
+
mobile: {
|
|
15
|
+
bodyStrong: ATOMIC_FONTS['typo-5'],
|
|
16
|
+
body: ATOMIC_FONTS['typo-6'],
|
|
17
|
+
smallTitle: ATOMIC_FONTS['typo-8'],
|
|
18
|
+
largeTitle: ATOMIC_FONTS['typo-10'],
|
|
19
|
+
fineStrong: ATOMIC_FONTS['typo-3'],
|
|
20
|
+
fine: ATOMIC_FONTS['typo-4'],
|
|
21
|
+
},
|
|
22
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RGBColor } from './colors-utils';
|
|
2
|
+
import { generateColorsForTheme } from './colors';
|
|
3
|
+
import { LABEL_OPTIONS } from './const';
|
|
4
|
+
import { getThemeFonts } from './fonts';
|
|
5
|
+
import { getThemeShadows } from './shadow';
|
|
6
|
+
import { getThemeSpacings } from './spacing';
|
|
7
|
+
|
|
8
|
+
interface IThemeProps {
|
|
9
|
+
isDarkMode: boolean;
|
|
10
|
+
label?: (typeof LABEL_OPTIONS)[keyof typeof LABEL_OPTIONS] | undefined;
|
|
11
|
+
primaryColor?: RGBColor;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const loadThemeStyles = ({
|
|
15
|
+
isDarkMode,
|
|
16
|
+
label = LABEL_OPTIONS.AUTOFLEET,
|
|
17
|
+
primaryColor,
|
|
18
|
+
}: IThemeProps) => {
|
|
19
|
+
const colors = generateColorsForTheme({
|
|
20
|
+
lightMode: isDarkMode ? 'dark' : 'light',
|
|
21
|
+
label,
|
|
22
|
+
primaryColor,
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
...getThemeSpacings(),
|
|
26
|
+
colors,
|
|
27
|
+
fonts: getThemeFonts(),
|
|
28
|
+
shadows: getThemeShadows(colors),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type IThemeStyle = ReturnType<typeof loadThemeStyles>;
|
|
33
|
+
export interface ITheme {
|
|
34
|
+
theme: IThemeStyle;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export * from './colors-utils';
|
|
38
|
+
export * from './colors/tokens/color-tokens';
|
|
@@ -1,14 +1,36 @@
|
|
|
1
|
+
import type { ColorTokenResponse } from '../colors';
|
|
1
2
|
import { SPACING } from '../spacing/spacing';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
const changeColorAlpha = (color: string, newAlpha: number) => {
|
|
5
|
+
if (!color.startsWith('rgba(')) return color;
|
|
6
|
+
return color.replace(
|
|
7
|
+
/(rgba\(\d{1,3},\s?\d{1,3},\s?\d{1,3}(?:,|\s?\/)\s?)((?:\d\.)?\d)(\))/,
|
|
8
|
+
`$1${newAlpha}$3`
|
|
9
|
+
);
|
|
6
10
|
};
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
const getLowShadow = (color: string, opacity = 12) =>
|
|
13
|
+
`${SPACING.NONE} ${SPACING.XS} ${SPACING.SM} ${changeColorAlpha(
|
|
14
|
+
color,
|
|
15
|
+
opacity / 100
|
|
16
|
+
)}` as const;
|
|
17
|
+
const getMedShadow = (color: string, opacity = 12) =>
|
|
18
|
+
`${SPACING.NONE} ${SPACING.SM} ${SPACING.LG} ${changeColorAlpha(
|
|
19
|
+
color,
|
|
20
|
+
opacity / 100
|
|
21
|
+
)}` as const;
|
|
22
|
+
const getHighShadow = (color: string, opacity = 16) =>
|
|
23
|
+
`${SPACING.NONE} ${SPACING.LG} ${SPACING['5XL']} ${changeColorAlpha(
|
|
24
|
+
color,
|
|
25
|
+
opacity / 100
|
|
26
|
+
)}` as const;
|
|
27
|
+
|
|
28
|
+
export const getThemeShadows = (colors: ColorTokenResponse) =>
|
|
29
|
+
({
|
|
30
|
+
'shadow-map-element': `${SPACING.NONE} 3px ${SPACING.LG} ${changeColorAlpha(
|
|
31
|
+
colors['neutral-dark'],
|
|
32
|
+
0.32
|
|
33
|
+
)}` as const,
|
|
12
34
|
// Neutral
|
|
13
35
|
'shadow-neutral-low': getLowShadow(colors['neutral-dark'], 8),
|
|
14
36
|
'shadow-neutral-medium': getMedShadow(colors['neutral-dark'], 8),
|
|
@@ -29,5 +51,4 @@ export const getThemeShadows = (colors) => ({
|
|
|
29
51
|
'shadow-error-low': getLowShadow(colors.error),
|
|
30
52
|
'shadow-error-medium': getMedShadow(colors.error),
|
|
31
53
|
'shadow-error-high': getHighShadow(colors.error),
|
|
32
|
-
});
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
|
54
|
+
} as const);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BORDER_RADIUS } from './border-radius';
|
|
2
2
|
import { SPACING } from './spacing';
|
|
3
|
+
|
|
3
4
|
export const getThemeSpacings = () => ({
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
borderRadius: BORDER_RADIUS,
|
|
6
|
+
spacings: SPACING,
|
|
6
7
|
});
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true
|
|
11
|
+
},
|
|
12
|
+
"files": [],
|
|
13
|
+
"include": [],
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "./tsconfig.lib.json"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "./tsconfig.spec.json"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"types": ["vitest/importMeta", "vite/client", "node", "vitest"]
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"vite.config.ts",
|
|
9
|
+
"vitest.config.ts",
|
|
10
|
+
"src/**/*.test.ts",
|
|
11
|
+
"src/**/*.spec.ts",
|
|
12
|
+
"src/**/*.test.tsx",
|
|
13
|
+
"src/**/*.spec.tsx",
|
|
14
|
+
"src/**/*.test.js",
|
|
15
|
+
"src/**/*.spec.js",
|
|
16
|
+
"src/**/*.test.jsx",
|
|
17
|
+
"src/**/*.spec.jsx",
|
|
18
|
+
"src/**/*.d.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
root: __dirname,
|
|
5
|
+
cacheDir: '../../node_modules/.vite/libs/theme',
|
|
6
|
+
plugins: [nxViteTsPaths()],
|
|
7
|
+
test: {
|
|
8
|
+
cache: { dir: '../../node_modules/.vitest' },
|
|
9
|
+
coverage: {
|
|
10
|
+
reportsDirectory: '../../coverage/libs/theme',
|
|
11
|
+
provider: 'v8',
|
|
12
|
+
reporter: 'text',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|