@evolve.ui/theme-system 1.0.0 → 1.1.0
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/evolve-ui.entries.json +46 -0
- package/package.json +4 -2
- package/src/index.ts +37 -0
- package/src/tailwind/borderRadius.ts +32 -0
- package/src/tailwind/boxShadow.ts +19 -0
- package/src/tailwind/colors.ts +332 -0
- package/src/tailwind/cssVars.ts +301 -0
- package/src/tailwind/fontFamily.ts +14 -0
- package/src/tailwind/plugin.ts +308 -0
- package/src/tailwind/screens.ts +22 -0
- package/src/tailwind/spacing.ts +20 -0
- package/src/tailwind/text.ts +170 -0
- package/src/tailwind/width.ts +14 -0
- package/src/themes/BasketballTraining.ts +166 -0
- package/src/themes/Default.ts +165 -0
- package/src/themes/ProfessionalBrand.ts +166 -0
- package/src/themes/allThemes.ts +12 -0
- package/src/themes/brands.ts +37 -0
- package/src/themes/common.ts +65 -0
- package/src/themes/generate.ts +46 -0
- package/src/themes/generateCSSVars.ts +123 -0
- package/src/themes/runtime/basketballTraining.ts +3 -0
- package/src/themes/runtime/buildTheme.ts +424 -0
- package/src/themes/runtime/default.ts +3 -0
- package/src/themes/runtime/professionalBrand.ts +3 -0
- package/src/themes/semanticColorTokenSteps.ts +20 -0
- package/src/themes/themeType.ts +169 -0
- package/src/themes/writeToCSSFile.ts +11 -0
- package/src/utils/cn.ts +35 -0
- package/src/utils/color.ts +82 -0
- package/src/utils/wrapVar.ts +24 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import tinycolor from 'tinycolor2';
|
|
2
|
+
|
|
3
|
+
// https://github.com/bgrins/TinyColor
|
|
4
|
+
|
|
5
|
+
export const lighten = (percentAsInt: number, unprocessedColor: string): tinycolor.Instance => {
|
|
6
|
+
const color = tinycolor(unprocessedColor);
|
|
7
|
+
const amount = (percentAsInt * ((1 - color.toHsl().l) * 100)) / 100;
|
|
8
|
+
return color.lighten(amount);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const darken = (percentAsInt: number, unprocessedColor: string): tinycolor.Instance => {
|
|
12
|
+
const color = tinycolor(unprocessedColor);
|
|
13
|
+
const amount = (percentAsInt * (color.toHsl().l * 100)) / 100;
|
|
14
|
+
return color.darken(amount);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// https://tailwindcss.com/docs/customizing-colors#using-custom-colors
|
|
18
|
+
const removeRGB = (color: string) => color.replace(/rgb\(|,|\)/g, '');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generate a set of color steps from a base color. Base color becomes 500.
|
|
22
|
+
*
|
|
23
|
+
* @param color The color to generate the steps from
|
|
24
|
+
* @returns An array of 50, 100, 200, 300, 400, 500, 600, 700, 800, 900 color values.
|
|
25
|
+
*/
|
|
26
|
+
export const generateNormalColorSteps = (color: string) => {
|
|
27
|
+
return [
|
|
28
|
+
removeRGB(lighten(95, color).toRgbString()),
|
|
29
|
+
removeRGB(lighten(85, color).toRgbString()),
|
|
30
|
+
removeRGB(lighten(70, color).toRgbString()),
|
|
31
|
+
removeRGB(lighten(40, color).toRgbString()),
|
|
32
|
+
removeRGB(lighten(20, color).toRgbString()),
|
|
33
|
+
removeRGB(tinycolor(color).toRgbString()),
|
|
34
|
+
removeRGB(darken(20, color).toRgbString()),
|
|
35
|
+
removeRGB(darken(40, color).toRgbString()),
|
|
36
|
+
removeRGB(darken(50, color).toRgbString()),
|
|
37
|
+
removeRGB(darken(70, color).toRgbString()),
|
|
38
|
+
];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generate a set of color steps from a base color. Base color becomes 500.
|
|
43
|
+
*
|
|
44
|
+
* @param color The color to generate the steps from
|
|
45
|
+
* @param isNeutral Whether the color is a neutral color to make surface-50 true white
|
|
46
|
+
* @returns An array of 50, 100, 200, 300, 400, 500, 600, 700, 800, 900 color values.
|
|
47
|
+
*/
|
|
48
|
+
export const generateSurfaceColorSteps = (color: string, isNeutral: boolean = false) => {
|
|
49
|
+
return [
|
|
50
|
+
removeRGB(lighten(isNeutral ? 100 : 99, color).toRgbString()),
|
|
51
|
+
removeRGB(lighten(95, color).toRgbString()),
|
|
52
|
+
removeRGB(lighten(80, color).toRgbString()),
|
|
53
|
+
removeRGB(lighten(50, color).toRgbString()),
|
|
54
|
+
removeRGB(lighten(30, color).toRgbString()),
|
|
55
|
+
removeRGB(tinycolor(color).toRgbString()),
|
|
56
|
+
removeRGB(darken(20, color).toRgbString()),
|
|
57
|
+
removeRGB(darken(40, color).toRgbString()),
|
|
58
|
+
removeRGB(darken(50, color).toRgbString()),
|
|
59
|
+
removeRGB(darken(70, color).toRgbString()),
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type Steps = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
64
|
+
export const steps: Steps[] = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
|
|
65
|
+
export type StepObject = Record<Steps, string>;
|
|
66
|
+
|
|
67
|
+
export const colorStepArrayToObject = (colorStepArray: string[]): StepObject => {
|
|
68
|
+
return {
|
|
69
|
+
'100': colorStepArray[1],
|
|
70
|
+
'200': colorStepArray[2],
|
|
71
|
+
'300': colorStepArray[3],
|
|
72
|
+
'400': colorStepArray[4],
|
|
73
|
+
'50': colorStepArray[0],
|
|
74
|
+
'500': colorStepArray[5],
|
|
75
|
+
'600': colorStepArray[6],
|
|
76
|
+
'700': colorStepArray[7],
|
|
77
|
+
'800': colorStepArray[8],
|
|
78
|
+
'900': colorStepArray[9],
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { tinycolor };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS variable wrapping utilities for Tailwind CSS configuration
|
|
3
|
+
*
|
|
4
|
+
* These utilities handle the conversion of CSS custom property names
|
|
5
|
+
* into proper var() references, with optional opacity support for
|
|
6
|
+
* Tailwind's alpha modifier syntax (e.g., `bg-primary-500/50`).
|
|
7
|
+
*
|
|
8
|
+
* @see https://tailwindcss.com/docs/customizing-colors#using-css-variables
|
|
9
|
+
* Internal reference: Hammer UI patterns
|
|
10
|
+
* Ported from the upstream theme system.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Wraps a CSS variable name in var() */
|
|
14
|
+
export const wrapVar = (value: string): string => `var(${value})`;
|
|
15
|
+
|
|
16
|
+
/** Wraps a CSS variable name in rgb(var()) */
|
|
17
|
+
export const wrapVarRgb = (value: string): string => `rgb(var(${value}))`;
|
|
18
|
+
|
|
19
|
+
/** Wraps a variable reference with a fixed percentage opacity */
|
|
20
|
+
export const wrapOpacity = (wrappedVariable: string, percentOpacity: number): string =>
|
|
21
|
+
`rgb(${wrappedVariable} / ${percentOpacity}%)`;
|
|
22
|
+
|
|
23
|
+
/** Wraps a variable reference with Tailwind's alpha-value placeholder for dynamic opacity */
|
|
24
|
+
export const wrapVariableOpacity = (wrappedVariable: string): string => `rgb(${wrappedVariable} / <alpha-value>)`;
|