@vinhhypc/config-theme 0.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/README.md +57 -0
- package/dist/components/themed/Accordion.d.ts +23 -0
- package/dist/components/themed/Accordion.js +37 -0
- package/dist/components/themed/Accordion.js.map +1 -0
- package/dist/components/themed/Alert.d.ts +13 -0
- package/dist/components/themed/Alert.js +17 -0
- package/dist/components/themed/Alert.js.map +1 -0
- package/dist/components/themed/Avatar.d.ts +19 -0
- package/dist/components/themed/Avatar.js +30 -0
- package/dist/components/themed/Avatar.js.map +1 -0
- package/dist/components/themed/Badge.d.ts +11 -0
- package/dist/components/themed/Badge.js +17 -0
- package/dist/components/themed/Badge.js.map +1 -0
- package/dist/components/themed/Button.d.ts +14 -0
- package/dist/components/themed/Button.js +20 -0
- package/dist/components/themed/Button.js.map +1 -0
- package/dist/components/themed/Calendar.d.ts +18 -0
- package/dist/components/themed/Calendar.js +59 -0
- package/dist/components/themed/Calendar.js.map +1 -0
- package/dist/components/themed/Card.d.ts +17 -0
- package/dist/components/themed/Card.js +14 -0
- package/dist/components/themed/Card.js.map +1 -0
- package/dist/components/themed/Checkbox.d.ts +16 -0
- package/dist/components/themed/Checkbox.js +15 -0
- package/dist/components/themed/Checkbox.js.map +1 -0
- package/dist/components/themed/DropdownMenu.d.ts +20 -0
- package/dist/components/themed/DropdownMenu.js +39 -0
- package/dist/components/themed/DropdownMenu.js.map +1 -0
- package/dist/components/themed/Input.d.ts +18 -0
- package/dist/components/themed/Input.js +25 -0
- package/dist/components/themed/Input.js.map +1 -0
- package/dist/components/themed/Pagination.d.ts +17 -0
- package/dist/components/themed/Pagination.js +33 -0
- package/dist/components/themed/Pagination.js.map +1 -0
- package/dist/components/themed/Select.d.ts +16 -0
- package/dist/components/themed/Select.js +20 -0
- package/dist/components/themed/Select.js.map +1 -0
- package/dist/components/themed/Sheet.d.ts +19 -0
- package/dist/components/themed/Sheet.js +28 -0
- package/dist/components/themed/Sheet.js.map +1 -0
- package/dist/components/themed/Sidebar.d.ts +21 -0
- package/dist/components/themed/Sidebar.js +11 -0
- package/dist/components/themed/Sidebar.js.map +1 -0
- package/dist/components/themed/Table.d.ts +21 -0
- package/dist/components/themed/Table.js +10 -0
- package/dist/components/themed/Table.js.map +1 -0
- package/dist/components/themed/ThemeProvider.d.ts +41 -0
- package/dist/components/themed/ThemeProvider.js +53 -0
- package/dist/components/themed/ThemeProvider.js.map +1 -0
- package/dist/components/themed/Toast.d.ts +19 -0
- package/dist/components/themed/Toast.js +13 -0
- package/dist/components/themed/Toast.js.map +1 -0
- package/dist/components/themed/Tooltip.d.ts +15 -0
- package/dist/components/themed/Tooltip.js +11 -0
- package/dist/components/themed/Tooltip.js.map +1 -0
- package/dist/components/themed/index.d.ts +33 -0
- package/dist/components/themed/index.js +35 -0
- package/dist/components/themed/index.js.map +1 -0
- package/dist/components/themed/styles.d.ts +29 -0
- package/dist/components/themed/styles.js +270 -0
- package/dist/components/themed/styles.js.map +1 -0
- package/dist/components/themed/themeCss.d.ts +35 -0
- package/dist/components/themed/themeCss.js +76 -0
- package/dist/components/themed/themeCss.js.map +1 -0
- package/dist/lib/config/defaults.d.ts +5 -0
- package/dist/lib/config/defaults.js +86 -0
- package/dist/lib/config/defaults.js.map +1 -0
- package/dist/lib/config/presets.d.ts +13 -0
- package/dist/lib/config/presets.js +104 -0
- package/dist/lib/config/presets.js.map +1 -0
- package/dist/lib/config/types.d.ts +146 -0
- package/dist/lib/config/types.js +46 -0
- package/dist/lib/config/types.js.map +1 -0
- package/dist/lib/tokens/adapters.d.ts +15 -0
- package/dist/lib/tokens/adapters.js +102 -0
- package/dist/lib/tokens/adapters.js.map +1 -0
- package/dist/lib/tokens/color.d.ts +23 -0
- package/dist/lib/tokens/color.js +132 -0
- package/dist/lib/tokens/color.js.map +1 -0
- package/dist/lib/tokens/elevation.d.ts +6 -0
- package/dist/lib/tokens/elevation.js +40 -0
- package/dist/lib/tokens/elevation.js.map +1 -0
- package/dist/lib/tokens/index.d.ts +43 -0
- package/dist/lib/tokens/index.js +88 -0
- package/dist/lib/tokens/index.js.map +1 -0
- package/dist/lib/tokens/interactions.d.ts +12 -0
- package/dist/lib/tokens/interactions.js +72 -0
- package/dist/lib/tokens/interactions.js.map +1 -0
- package/dist/lib/tokens/opacity.d.ts +14 -0
- package/dist/lib/tokens/opacity.js +34 -0
- package/dist/lib/tokens/opacity.js.map +1 -0
- package/dist/lib/tokens/spacing.d.ts +17 -0
- package/dist/lib/tokens/spacing.js +32 -0
- package/dist/lib/tokens/spacing.js.map +1 -0
- package/dist/lib/tokens/typography.d.ts +16 -0
- package/dist/lib/tokens/typography.js +23 -0
- package/dist/lib/tokens/typography.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The central data model for Theme Config.
|
|
3
|
+
* Every exported markdown file is derived purely from a `DesignConfig`.
|
|
4
|
+
*/
|
|
5
|
+
/** Base framework / authoring approach. */
|
|
6
|
+
export type TargetStack = "react-tailwind" | "html-css" | "vue-tailwind" | "next";
|
|
7
|
+
/** Optional component library layered on top of a React base. */
|
|
8
|
+
export type ComponentLib = "none" | "shadcn" | "antd";
|
|
9
|
+
/**
|
|
10
|
+
* The stack the generators actually render for: the base framework, unless a
|
|
11
|
+
* component library is selected (shadcn/antd imply their own component code).
|
|
12
|
+
*/
|
|
13
|
+
export type RenderStack = TargetStack | "shadcn" | "antd";
|
|
14
|
+
export type ThemeMode = "light" | "dark" | "both";
|
|
15
|
+
export type ThemeStyle = "modern" | "classic" | "minimal" | "playful" | "brutalist";
|
|
16
|
+
export type RadiusStyle = "sharp" | "rounded" | "pill";
|
|
17
|
+
export type BorderStyle = "solid" | "dashed";
|
|
18
|
+
export type ElevationStyle = "flat" | "soft" | "hard";
|
|
19
|
+
export type AnimationStyle = "none" | "subtle" | "smooth" | "bouncy";
|
|
20
|
+
export type HoverEffect = "none" | "darken" | "lift" | "scale" | "glow";
|
|
21
|
+
export type ComponentSize = "sm" | "md" | "lg";
|
|
22
|
+
export type InputVariant = "outline" | "filled" | "underline";
|
|
23
|
+
export type CardVariant = "elevated" | "outlined" | "flat";
|
|
24
|
+
export type NamingConvention = "tailwind" | "css-vars" | "bem";
|
|
25
|
+
export type AccessibilityLevel = "AA" | "AAA";
|
|
26
|
+
export interface DesignColors {
|
|
27
|
+
primary: string;
|
|
28
|
+
secondary: string;
|
|
29
|
+
accent: string;
|
|
30
|
+
neutral: string;
|
|
31
|
+
success: string;
|
|
32
|
+
warning: string;
|
|
33
|
+
error: string;
|
|
34
|
+
info: string;
|
|
35
|
+
}
|
|
36
|
+
export interface DesignConfig {
|
|
37
|
+
meta: {
|
|
38
|
+
name: string;
|
|
39
|
+
version: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
targetStack: TargetStack;
|
|
42
|
+
/** Optional component library; only meaningful for React-based stacks. */
|
|
43
|
+
componentLib: ComponentLib;
|
|
44
|
+
/**
|
|
45
|
+
* When `install` is on, the exported docs instruct consuming the prebuilt
|
|
46
|
+
* component package from npm (with `<ThemeProvider>` + usage) instead of
|
|
47
|
+
* hand-rolling components. Only applies to React stacks without another
|
|
48
|
+
* component library. Default off.
|
|
49
|
+
*/
|
|
50
|
+
componentPackage: {
|
|
51
|
+
install: boolean;
|
|
52
|
+
/** npm package name to install. */
|
|
53
|
+
name: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
theme: {
|
|
57
|
+
mode: ThemeMode;
|
|
58
|
+
style: ThemeStyle;
|
|
59
|
+
colors: DesignColors;
|
|
60
|
+
};
|
|
61
|
+
typography: {
|
|
62
|
+
fontFamilyBase: string;
|
|
63
|
+
fontFamilyHeading: string;
|
|
64
|
+
fontFamilyMono: string;
|
|
65
|
+
baseSize: number;
|
|
66
|
+
scaleRatio: number;
|
|
67
|
+
weights: number[];
|
|
68
|
+
lineHeight: number;
|
|
69
|
+
};
|
|
70
|
+
spacing: {
|
|
71
|
+
baseUnit: number;
|
|
72
|
+
scale: number[];
|
|
73
|
+
};
|
|
74
|
+
radius: {
|
|
75
|
+
style: RadiusStyle;
|
|
76
|
+
base: number;
|
|
77
|
+
};
|
|
78
|
+
borders: {
|
|
79
|
+
width: number;
|
|
80
|
+
style: BorderStyle;
|
|
81
|
+
defaultColorToken: string;
|
|
82
|
+
};
|
|
83
|
+
elevation: {
|
|
84
|
+
style: ElevationStyle;
|
|
85
|
+
levels: number;
|
|
86
|
+
};
|
|
87
|
+
animation: {
|
|
88
|
+
enabled: boolean;
|
|
89
|
+
style: AnimationStyle;
|
|
90
|
+
durationMs: number;
|
|
91
|
+
easing: string;
|
|
92
|
+
};
|
|
93
|
+
/** How interactive elements respond to hover / focus / press. */
|
|
94
|
+
interactions: {
|
|
95
|
+
hover: HoverEffect;
|
|
96
|
+
pressFeedback: boolean;
|
|
97
|
+
focusRing: boolean;
|
|
98
|
+
underlineLinks: boolean;
|
|
99
|
+
};
|
|
100
|
+
components: {
|
|
101
|
+
button: {
|
|
102
|
+
variants: string[];
|
|
103
|
+
defaultSize: ComponentSize;
|
|
104
|
+
};
|
|
105
|
+
input: {
|
|
106
|
+
variant: InputVariant;
|
|
107
|
+
};
|
|
108
|
+
card: {
|
|
109
|
+
variant: CardVariant;
|
|
110
|
+
};
|
|
111
|
+
badge: {
|
|
112
|
+
enabled: boolean;
|
|
113
|
+
};
|
|
114
|
+
modal: {
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
};
|
|
117
|
+
table: {
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
aiRules: {
|
|
122
|
+
enforceTokensOnly: boolean;
|
|
123
|
+
namingConvention: NamingConvention;
|
|
124
|
+
accessibility: AccessibilityLevel;
|
|
125
|
+
cleanCode: boolean;
|
|
126
|
+
customRules: string[];
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** React-based stacks can layer on a component library (shadcn/antd). */
|
|
130
|
+
export declare function stackSupportsComponentLib(stack: TargetStack): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Whether exported docs should instruct installing the prebuilt npm component
|
|
133
|
+
* package: the toggle is on, the stack is React-based, and no other component
|
|
134
|
+
* library (shadcn/antd) is selected.
|
|
135
|
+
*/
|
|
136
|
+
export declare function usesComponentPackage(config: DesignConfig): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* The stack the generators render for. A selected component library takes
|
|
139
|
+
* precedence over the base framework (shadcn/antd ship their own components).
|
|
140
|
+
*/
|
|
141
|
+
export declare function effectiveStack(config: DesignConfig): RenderStack;
|
|
142
|
+
/** Names of the colour roles, used when iterating in token generators. */
|
|
143
|
+
export declare const COLOR_ROLES: (keyof DesignColors)[];
|
|
144
|
+
/** Steps used for the auto-generated colour scale (primary-50 … primary-900). */
|
|
145
|
+
export declare const COLOR_SCALE_STEPS: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
146
|
+
export type ColorScaleStep = (typeof COLOR_SCALE_STEPS)[number];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The central data model for Theme Config.
|
|
3
|
+
* Every exported markdown file is derived purely from a `DesignConfig`.
|
|
4
|
+
*/
|
|
5
|
+
/** React-based stacks can layer on a component library (shadcn/antd). */
|
|
6
|
+
export function stackSupportsComponentLib(stack) {
|
|
7
|
+
return stack === "react-tailwind" || stack === "next";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Whether exported docs should instruct installing the prebuilt npm component
|
|
11
|
+
* package: the toggle is on, the stack is React-based, and no other component
|
|
12
|
+
* library (shadcn/antd) is selected.
|
|
13
|
+
*/
|
|
14
|
+
export function usesComponentPackage(config) {
|
|
15
|
+
return (config.meta.componentPackage.install &&
|
|
16
|
+
stackSupportsComponentLib(config.meta.targetStack) &&
|
|
17
|
+
config.meta.componentLib === "none");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The stack the generators render for. A selected component library takes
|
|
21
|
+
* precedence over the base framework (shadcn/antd ship their own components).
|
|
22
|
+
*/
|
|
23
|
+
export function effectiveStack(config) {
|
|
24
|
+
const { targetStack, componentLib } = config.meta;
|
|
25
|
+
if (stackSupportsComponentLib(targetStack)) {
|
|
26
|
+
if (componentLib === "shadcn")
|
|
27
|
+
return "shadcn";
|
|
28
|
+
if (componentLib === "antd")
|
|
29
|
+
return "antd";
|
|
30
|
+
}
|
|
31
|
+
return targetStack;
|
|
32
|
+
}
|
|
33
|
+
/** Names of the colour roles, used when iterating in token generators. */
|
|
34
|
+
export const COLOR_ROLES = [
|
|
35
|
+
"primary",
|
|
36
|
+
"secondary",
|
|
37
|
+
"accent",
|
|
38
|
+
"neutral",
|
|
39
|
+
"success",
|
|
40
|
+
"warning",
|
|
41
|
+
"error",
|
|
42
|
+
"info",
|
|
43
|
+
];
|
|
44
|
+
/** Steps used for the auto-generated colour scale (primary-50 … primary-900). */
|
|
45
|
+
export const COLOR_SCALE_STEPS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
46
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../lib/config/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoIH,yEAAyE;AACzE,MAAM,UAAU,yBAAyB,CAAC,KAAkB;IAC1D,OAAO,KAAK,KAAK,gBAAgB,IAAI,KAAK,KAAK,MAAM,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACvD,OAAO,CACL,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO;QACpC,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,YAAY,KAAK,MAAM,CACpC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAoB;IACjD,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IAClD,IAAI,yBAAyB,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3C,IAAI,YAAY,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC/C,IAAI,YAAY,KAAK,MAAM;YAAE,OAAO,MAAM,CAAC;IAC7C,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,WAAW,GAA2B;IACjD,SAAS;IACT,WAAW;IACX,QAAQ;IACR,SAAS;IACT,SAAS;IACT,SAAS;IACT,OAAO;IACP,MAAM;CACP,CAAC;AAEF,iFAAiF;AACjF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DesignConfig } from "../../lib/config/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Adapters that map a DesignConfig onto popular component libraries.
|
|
4
|
+
* Pure functions returning ready-to-paste code strings.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* shadcn/ui `globals.css` — maps our token scales onto shadcn's semantic CSS
|
|
8
|
+
* variables, in the HSL-channel format shadcn uses (`hsl(var(--primary))`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function shadcnCssVars(config: DesignConfig): string;
|
|
11
|
+
/**
|
|
12
|
+
* Ant Design v6 theme config for `<ConfigProvider theme={...}>`.
|
|
13
|
+
* antd derives its own palettes from these seed tokens.
|
|
14
|
+
*/
|
|
15
|
+
export declare function antdThemeConfig(config: DesignConfig): string;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { generateColorScale, hexToHslChannels, readableTextColor } from "./color.js";
|
|
2
|
+
/**
|
|
3
|
+
* Adapters that map a DesignConfig onto popular component libraries.
|
|
4
|
+
* Pure functions returning ready-to-paste code strings.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* shadcn/ui `globals.css` — maps our token scales onto shadcn's semantic CSS
|
|
8
|
+
* variables, in the HSL-channel format shadcn uses (`hsl(var(--primary))`).
|
|
9
|
+
*/
|
|
10
|
+
export function shadcnCssVars(config) {
|
|
11
|
+
const c = config.theme.colors;
|
|
12
|
+
const primary = generateColorScale(c.primary);
|
|
13
|
+
const neutral = generateColorScale(c.neutral);
|
|
14
|
+
const error = generateColorScale(c.error);
|
|
15
|
+
const h = hexToHslChannels;
|
|
16
|
+
const light = [
|
|
17
|
+
` --background: ${h(neutral[50])};`,
|
|
18
|
+
` --foreground: ${h(neutral[900])};`,
|
|
19
|
+
` --card: ${h("#ffffff")};`,
|
|
20
|
+
` --card-foreground: ${h(neutral[900])};`,
|
|
21
|
+
` --popover: ${h("#ffffff")};`,
|
|
22
|
+
` --popover-foreground: ${h(neutral[900])};`,
|
|
23
|
+
` --primary: ${h(primary[600])};`,
|
|
24
|
+
` --primary-foreground: ${h(readableTextColor(primary[600]))};`,
|
|
25
|
+
` --secondary: ${h(neutral[100])};`,
|
|
26
|
+
` --secondary-foreground: ${h(neutral[900])};`,
|
|
27
|
+
` --muted: ${h(neutral[100])};`,
|
|
28
|
+
` --muted-foreground: ${h(neutral[600])};`,
|
|
29
|
+
` --accent: ${h(neutral[100])};`,
|
|
30
|
+
` --accent-foreground: ${h(neutral[900])};`,
|
|
31
|
+
` --destructive: ${h(error[600])};`,
|
|
32
|
+
` --destructive-foreground: ${h("#ffffff")};`,
|
|
33
|
+
` --border: ${h(neutral[200])};`,
|
|
34
|
+
` --input: ${h(neutral[200])};`,
|
|
35
|
+
` --ring: ${h(primary[500])};`,
|
|
36
|
+
` --radius: ${config.radius.base}px;`,
|
|
37
|
+
].join("\n");
|
|
38
|
+
let css = `:root {\n${light}\n}`;
|
|
39
|
+
if (config.theme.mode === "both" || config.theme.mode === "dark") {
|
|
40
|
+
const dark = [
|
|
41
|
+
` --background: ${h(neutral[900])};`,
|
|
42
|
+
` --foreground: ${h(neutral[50])};`,
|
|
43
|
+
` --card: ${h(neutral[900])};`,
|
|
44
|
+
` --card-foreground: ${h(neutral[50])};`,
|
|
45
|
+
` --popover: ${h(neutral[900])};`,
|
|
46
|
+
` --popover-foreground: ${h(neutral[50])};`,
|
|
47
|
+
` --primary: ${h(primary[500])};`,
|
|
48
|
+
` --primary-foreground: ${h(readableTextColor(primary[500]))};`,
|
|
49
|
+
` --secondary: ${h(neutral[800])};`,
|
|
50
|
+
` --secondary-foreground: ${h(neutral[50])};`,
|
|
51
|
+
` --muted: ${h(neutral[800])};`,
|
|
52
|
+
` --muted-foreground: ${h(neutral[300])};`,
|
|
53
|
+
` --accent: ${h(neutral[800])};`,
|
|
54
|
+
` --accent-foreground: ${h(neutral[50])};`,
|
|
55
|
+
` --destructive: ${h(error[500])};`,
|
|
56
|
+
` --destructive-foreground: ${h("#ffffff")};`,
|
|
57
|
+
` --border: ${h(neutral[700])};`,
|
|
58
|
+
` --input: ${h(neutral[700])};`,
|
|
59
|
+
` --ring: ${h(primary[500])};`,
|
|
60
|
+
].join("\n");
|
|
61
|
+
css += `\n\n.dark {\n${dark}\n}`;
|
|
62
|
+
}
|
|
63
|
+
return css;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Ant Design v6 theme config for `<ConfigProvider theme={...}>`.
|
|
67
|
+
* antd derives its own palettes from these seed tokens.
|
|
68
|
+
*/
|
|
69
|
+
export function antdThemeConfig(config) {
|
|
70
|
+
const c = config.theme.colors;
|
|
71
|
+
const algoComment = config.theme.mode === "both"
|
|
72
|
+
? " // light + dark: swap to theme.darkAlgorithm when in dark mode"
|
|
73
|
+
: config.theme.mode === "dark"
|
|
74
|
+
? ""
|
|
75
|
+
: "";
|
|
76
|
+
const algo = config.theme.mode === "dark" ? "theme.darkAlgorithm" : "theme.defaultAlgorithm";
|
|
77
|
+
return [
|
|
78
|
+
`import { theme, type ThemeConfig } from "antd";`,
|
|
79
|
+
``,
|
|
80
|
+
`export const themeConfig: ThemeConfig = {`,
|
|
81
|
+
` token: {`,
|
|
82
|
+
` colorPrimary: "${c.primary}",`,
|
|
83
|
+
` colorSuccess: "${c.success}",`,
|
|
84
|
+
` colorWarning: "${c.warning}",`,
|
|
85
|
+
` colorError: "${c.error}",`,
|
|
86
|
+
` colorInfo: "${c.info}",`,
|
|
87
|
+
` colorTextBase: "${c.neutral}",`,
|
|
88
|
+
` borderRadius: ${config.radius.base},`,
|
|
89
|
+
` fontFamily: ${JSON.stringify(config.typography.fontFamilyBase)},`,
|
|
90
|
+
` fontSize: ${config.typography.baseSize},`,
|
|
91
|
+
` lineHeight: ${config.typography.lineHeight},`,
|
|
92
|
+
` motionDurationMid: "${config.animation.enabled ? config.animation.durationMs : 0}ms",`,
|
|
93
|
+
` wireframe: false,`,
|
|
94
|
+
` },`,
|
|
95
|
+
` algorithm: ${algo},${algoComment}`,
|
|
96
|
+
`};`,
|
|
97
|
+
``,
|
|
98
|
+
`// Usage:`,
|
|
99
|
+
`// <ConfigProvider theme={themeConfig}>{children}</ConfigProvider>`,
|
|
100
|
+
].join("\n");
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../../../../../lib/tokens/adapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAElF;;;GAGG;AAEH;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAoB;IAChD,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;IAC9B,MAAM,OAAO,GAAG,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,kBAAkB,CAAC,CAA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C1C,mBAAmB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG;QACtE,iBAAiB,MAAM,CAAC,UAAU,CAAC,QAAQ,GAAG;QAC9C,mBAAmB,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG;QAClD,2BAA2B,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM;QAC3F,uBAAuB;QACvB,MAAM;QACN,gBAAgB,IAAI,IAAI,WAAW,EAAE;QACrC,IAAI;QACJ,EAAE;QACF,WAAW;QACX,oEAAoE;KACrE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ColorScaleStep } from "../../lib/config/types.js";
|
|
2
|
+
export interface RGB {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
}
|
|
7
|
+
/** Parse #rgb or #rrggbb into RGB. Returns null for invalid input. */
|
|
8
|
+
export declare function hexToRgb(hex: string): RGB | null;
|
|
9
|
+
export declare function rgbToHex({ r, g, b }: RGB): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generate a 50..900 scale from a single base hex.
|
|
12
|
+
* 500 is the base colour; lighter steps are tints, darker steps are shades.
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateColorScale(baseHex: string): Record<ColorScaleStep, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Convert a hex color to an HSL *channel* string like `"221 83% 53%"`,
|
|
17
|
+
* the format shadcn/ui expects for its CSS variables (`hsl(var(--primary))`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function hexToHslChannels(hex: string): string;
|
|
20
|
+
/** WCAG contrast ratio between two hex colours (1..21). */
|
|
21
|
+
export declare function contrastRatio(hexA: string, hexB: string): number;
|
|
22
|
+
/** Choose black or white text for best contrast against a background hex. */
|
|
23
|
+
export declare function readableTextColor(bgHex: string): "#000000" | "#ffffff";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { COLOR_SCALE_STEPS } from "../../lib/config/types.js";
|
|
2
|
+
/** Parse #rgb or #rrggbb into RGB. Returns null for invalid input. */
|
|
3
|
+
export function hexToRgb(hex) {
|
|
4
|
+
const m = hex.trim().match(/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);
|
|
5
|
+
if (!m)
|
|
6
|
+
return null;
|
|
7
|
+
let h = m[1];
|
|
8
|
+
if (h.length === 3) {
|
|
9
|
+
h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2];
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
r: parseInt(h.slice(0, 2), 16),
|
|
13
|
+
g: parseInt(h.slice(2, 4), 16),
|
|
14
|
+
b: parseInt(h.slice(4, 6), 16),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const clamp = (n) => Math.max(0, Math.min(255, Math.round(n)));
|
|
18
|
+
export function rgbToHex({ r, g, b }) {
|
|
19
|
+
const toHex = (n) => clamp(n).toString(16).padStart(2, "0");
|
|
20
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
21
|
+
}
|
|
22
|
+
/** Mix a colour toward white (amount 0..1). */
|
|
23
|
+
function tint(rgb, amount) {
|
|
24
|
+
return {
|
|
25
|
+
r: rgb.r + (255 - rgb.r) * amount,
|
|
26
|
+
g: rgb.g + (255 - rgb.g) * amount,
|
|
27
|
+
b: rgb.b + (255 - rgb.b) * amount,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Mix a colour toward black (amount 0..1). */
|
|
31
|
+
function shade(rgb, amount) {
|
|
32
|
+
return {
|
|
33
|
+
r: rgb.r * (1 - amount),
|
|
34
|
+
g: rgb.g * (1 - amount),
|
|
35
|
+
b: rgb.b * (1 - amount),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* How far each step is tinted (toward white, steps < 500) or
|
|
40
|
+
* shaded (toward black, steps > 500). Step 500 is the base colour.
|
|
41
|
+
*/
|
|
42
|
+
const TINT_BY_STEP = {
|
|
43
|
+
50: 0.95,
|
|
44
|
+
100: 0.88,
|
|
45
|
+
200: 0.74,
|
|
46
|
+
300: 0.56,
|
|
47
|
+
400: 0.3,
|
|
48
|
+
500: 0,
|
|
49
|
+
600: 0.12,
|
|
50
|
+
700: 0.26,
|
|
51
|
+
800: 0.42,
|
|
52
|
+
900: 0.58,
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Generate a 50..900 scale from a single base hex.
|
|
56
|
+
* 500 is the base colour; lighter steps are tints, darker steps are shades.
|
|
57
|
+
*/
|
|
58
|
+
export function generateColorScale(baseHex) {
|
|
59
|
+
const base = hexToRgb(baseHex) ?? { r: 0, g: 0, b: 0 };
|
|
60
|
+
const out = {};
|
|
61
|
+
for (const step of COLOR_SCALE_STEPS) {
|
|
62
|
+
const amount = TINT_BY_STEP[step];
|
|
63
|
+
if (step < 500)
|
|
64
|
+
out[step] = rgbToHex(tint(base, amount));
|
|
65
|
+
else if (step > 500)
|
|
66
|
+
out[step] = rgbToHex(shade(base, amount));
|
|
67
|
+
else
|
|
68
|
+
out[step] = rgbToHex(base);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Convert a hex color to an HSL *channel* string like `"221 83% 53%"`,
|
|
74
|
+
* the format shadcn/ui expects for its CSS variables (`hsl(var(--primary))`).
|
|
75
|
+
*/
|
|
76
|
+
export function hexToHslChannels(hex) {
|
|
77
|
+
const rgb = hexToRgb(hex) ?? { r: 0, g: 0, b: 0 };
|
|
78
|
+
const r = rgb.r / 255;
|
|
79
|
+
const g = rgb.g / 255;
|
|
80
|
+
const b = rgb.b / 255;
|
|
81
|
+
const max = Math.max(r, g, b);
|
|
82
|
+
const min = Math.min(r, g, b);
|
|
83
|
+
const l = (max + min) / 2;
|
|
84
|
+
let h = 0;
|
|
85
|
+
let s = 0;
|
|
86
|
+
if (max !== min) {
|
|
87
|
+
const d = max - min;
|
|
88
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
89
|
+
switch (max) {
|
|
90
|
+
case r:
|
|
91
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
92
|
+
break;
|
|
93
|
+
case g:
|
|
94
|
+
h = (b - r) / d + 2;
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
h = (r - g) / d + 4;
|
|
98
|
+
}
|
|
99
|
+
h /= 6;
|
|
100
|
+
}
|
|
101
|
+
const H = Math.round(h * 360);
|
|
102
|
+
const S = Math.round(s * 100);
|
|
103
|
+
const L = Math.round(l * 100);
|
|
104
|
+
return `${H} ${S}% ${L}%`;
|
|
105
|
+
}
|
|
106
|
+
/** Relative luminance per WCAG. */
|
|
107
|
+
function relativeLuminance({ r, g, b }) {
|
|
108
|
+
const channel = (c) => {
|
|
109
|
+
const s = c / 255;
|
|
110
|
+
return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
|
|
111
|
+
};
|
|
112
|
+
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
|
113
|
+
}
|
|
114
|
+
/** WCAG contrast ratio between two hex colours (1..21). */
|
|
115
|
+
export function contrastRatio(hexA, hexB) {
|
|
116
|
+
const a = hexToRgb(hexA);
|
|
117
|
+
const b = hexToRgb(hexB);
|
|
118
|
+
if (!a || !b)
|
|
119
|
+
return 1;
|
|
120
|
+
const la = relativeLuminance(a);
|
|
121
|
+
const lb = relativeLuminance(b);
|
|
122
|
+
const lighter = Math.max(la, lb);
|
|
123
|
+
const darker = Math.min(la, lb);
|
|
124
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
125
|
+
}
|
|
126
|
+
/** Choose black or white text for best contrast against a background hex. */
|
|
127
|
+
export function readableTextColor(bgHex) {
|
|
128
|
+
return contrastRatio(bgHex, "#ffffff") >= contrastRatio(bgHex, "#000000")
|
|
129
|
+
? "#ffffff"
|
|
130
|
+
: "#000000";
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../../../../lib/tokens/color.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,oBAAoB,CAAC;AAQ5E,sEAAsE;AACtE,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAClE,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACb,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO;QACL,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QAC9B,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QAC9B,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;KAC/B,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GA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M,GAAG,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC;QACvE,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Box-shadow presets per elevation style. Index 0 = no shadow.
|
|
3
|
+
* We return up to `levels` shadows (level 0 is always "none").
|
|
4
|
+
*/
|
|
5
|
+
const PRESETS = {
|
|
6
|
+
flat: [
|
|
7
|
+
"none",
|
|
8
|
+
"0 1px 1px rgba(0,0,0,0.04)",
|
|
9
|
+
"0 1px 2px rgba(0,0,0,0.06)",
|
|
10
|
+
"0 2px 3px rgba(0,0,0,0.06)",
|
|
11
|
+
"0 2px 4px rgba(0,0,0,0.08)",
|
|
12
|
+
"0 3px 6px rgba(0,0,0,0.08)",
|
|
13
|
+
],
|
|
14
|
+
soft: [
|
|
15
|
+
"none",
|
|
16
|
+
"0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.10)",
|
|
17
|
+
"0 2px 4px rgba(0,0,0,0.06), 0 4px 8px rgba(0,0,0,0.10)",
|
|
18
|
+
"0 4px 8px rgba(0,0,0,0.08), 0 8px 16px rgba(0,0,0,0.12)",
|
|
19
|
+
"0 8px 16px rgba(0,0,0,0.10), 0 16px 32px rgba(0,0,0,0.14)",
|
|
20
|
+
"0 16px 32px rgba(0,0,0,0.12), 0 24px 48px rgba(0,0,0,0.16)",
|
|
21
|
+
],
|
|
22
|
+
hard: [
|
|
23
|
+
"none",
|
|
24
|
+
"2px 2px 0 rgba(0,0,0,0.90)",
|
|
25
|
+
"3px 3px 0 rgba(0,0,0,0.90)",
|
|
26
|
+
"4px 4px 0 rgba(0,0,0,0.90)",
|
|
27
|
+
"6px 6px 0 rgba(0,0,0,0.90)",
|
|
28
|
+
"8px 8px 0 rgba(0,0,0,0.90)",
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
export function generateElevation(elevation) {
|
|
32
|
+
const preset = PRESETS[elevation.style];
|
|
33
|
+
const count = Math.min(elevation.levels, preset.length - 1);
|
|
34
|
+
const out = [{ token: "shadow-0", value: "none" }];
|
|
35
|
+
for (let i = 1; i <= count; i++) {
|
|
36
|
+
out.push({ token: `shadow-${i}`, value: preset[i] });
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=elevation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elevation.js","sourceRoot":"","sources":["../../../../../lib/tokens/elevation.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,GAAyD;IACpE,IAAI,EAAE;QACJ,MAAM;QACN,4BAA4B;QAC5B,4BAA4B;QAC5B,4BAA4B;QAC5B,4BAA4B;QAC5B,4BAA4B;KAC7B;IACD,IAAI,EAAE;QACJ,MAAM;QACN,wDAAwD;QACxD,wDAAwD;QACxD,yDAAyD;QACzD,2DAA2D;QAC3D,4DAA4D;KAC7D;IACD,IAAI,EAAE;QACJ,MAAM;QACN,4BAA4B;QAC5B,4BAA4B;QAC5B,4BAA4B;QAC5B,4BAA4B;QAC5B,4BAA4B;KAC7B;CACF,CAAC;AAOF,MAAM,UAAU,iBAAiB,CAAC,SAAoC;IACpE,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAkB,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAClE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type DesignConfig } from "../../lib/config/types.js";
|
|
2
|
+
import { type TypeStep } from "./typography.js";
|
|
3
|
+
import { type SpacingToken, type RadiusToken } from "./spacing.js";
|
|
4
|
+
import { type ShadowToken } from "./elevation.js";
|
|
5
|
+
import { type OpacityToken } from "./opacity.js";
|
|
6
|
+
export * from "./color.js";
|
|
7
|
+
export * from "./typography.js";
|
|
8
|
+
export * from "./spacing.js";
|
|
9
|
+
export * from "./elevation.js";
|
|
10
|
+
export * from "./interactions.js";
|
|
11
|
+
export * from "./opacity.js";
|
|
12
|
+
export * from "./adapters.js";
|
|
13
|
+
export interface ColorTokenEntry {
|
|
14
|
+
role: string;
|
|
15
|
+
step: number | null;
|
|
16
|
+
token: string;
|
|
17
|
+
hex: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ResolvedTokens {
|
|
20
|
+
colors: ColorTokenEntry[];
|
|
21
|
+
colorScales: Record<string, Record<number, string>>;
|
|
22
|
+
type: TypeStep[];
|
|
23
|
+
spacing: SpacingToken[];
|
|
24
|
+
radius: RadiusToken[];
|
|
25
|
+
elevation: ShadowToken[];
|
|
26
|
+
opacity: OpacityToken[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a DesignConfig into the full set of concrete token values.
|
|
30
|
+
* Pure function — the single source of truth for both markdown export and preview.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveTokens(config: DesignConfig): ResolvedTokens;
|
|
33
|
+
/** What goes inside a `--var: value;` declaration. */
|
|
34
|
+
export interface CssVar {
|
|
35
|
+
name: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}
|
|
38
|
+
/** Build the CSS custom properties for `:root`. */
|
|
39
|
+
export declare function buildCssVars(config: DesignConfig): CssVar[];
|
|
40
|
+
/** Serialise CSS vars into a `:root { ... }` block string. */
|
|
41
|
+
export declare function cssVarsToBlock(config: DesignConfig, selector?: string): string;
|
|
42
|
+
/** A flat record form, convenient for React inline `style` on the preview root. */
|
|
43
|
+
export declare function cssVarsToStyleObject(config: DesignConfig): Record<string, string>;
|