@cyclone-ui/theme-builder 0.0.0-stage → 0.0.4
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/CHANGELOG.md +15 -0
- package/LICENSE +187 -0
- package/README.md +305 -2
- package/dist/generate.cjs +1 -0
- package/dist/generate.d.cts +5 -0
- package/dist/generate.d.cts.map +1 -0
- package/dist/generate.d.mts +6 -0
- package/dist/generate.d.mts.map +1 -0
- package/dist/generate.mjs +2 -0
- package/dist/generate.mjs.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -0
- package/dist/preprocessor.cjs +1 -0
- package/dist/preprocessor.d.cts +4 -0
- package/dist/preprocessor.d.cts.map +1 -0
- package/dist/preprocessor.d.mts +5 -0
- package/dist/preprocessor.d.mts.map +1 -0
- package/dist/preprocessor.mjs +2 -0
- package/dist/preprocessor.mjs.map +1 -0
- package/package.json +70 -3
- package/powerlines.config.ts +28 -0
- package/project.json +8 -0
- package/src/generate.ts +66 -0
- package/src/index.ts +22 -0
- package/src/preprocessor.ts +1524 -0
- package/test/preprocessor.spec.ts +518 -0
- package/test/shiki-theme-mapping.spec.ts +160 -0
- package/test/storybook-theme-mapping.spec.ts +118 -0
- package/tsconfig.json +13 -0
- package/tsconfig.spec.json +16 -0
- package/vitest.config.mts +24 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
vi.mock("@razorwind/color-variants", () => ({
|
|
4
|
+
default: () => ({ name: "color-variants" })
|
|
5
|
+
}));
|
|
6
|
+
|
|
7
|
+
vi.mock("@razorwind/core", () => ({
|
|
8
|
+
defineConfig: <T>(config: T) => config
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
vi.mock("@razorwind/core/plugin", () => ({
|
|
12
|
+
definePlugin: <T>(plugin: T) => plugin
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock("@razorwind/css/generate", () => ({
|
|
16
|
+
default: (options: unknown = {}) => options
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
vi.mock("@razorwind/design-md/generate", () => ({
|
|
20
|
+
default: (options: unknown = {}) => options
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
vi.mock("@razorwind/docgen/generate", () => ({
|
|
24
|
+
default: (options: unknown = {}) => options
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
vi.mock("@razorwind/llms/generate", () => ({
|
|
28
|
+
default: (options: unknown = {}) => options
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
vi.mock("@razorwind/shadcn/generate", () => ({
|
|
32
|
+
default: (options: unknown = {}) => options
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
vi.mock("@razorwind/shiki/generate", () => ({
|
|
36
|
+
default: (options: unknown = {}) => options
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
vi.mock("@razorwind/storybook/generate", () => ({
|
|
40
|
+
default: (options: unknown) => options
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
vi.mock("@razorwind/tamagui/generate", () => ({
|
|
44
|
+
default: (options: unknown = {}) => options
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
type Token = { $value: string | number };
|
|
48
|
+
type StorybookPlugin = {
|
|
49
|
+
outputPath: string;
|
|
50
|
+
mapTheme: (tokens: unknown) => Record<string, Record<string, unknown>>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const token = ($value: string | number): Token => ({ $value });
|
|
54
|
+
|
|
55
|
+
const semanticColors = (prefix: string) => ({
|
|
56
|
+
color: {
|
|
57
|
+
primary: token(`${prefix}-primary`),
|
|
58
|
+
secondary: token(`${prefix}-secondary`),
|
|
59
|
+
tertiary: token(`${prefix}-tertiary`),
|
|
60
|
+
border: token(`${prefix}-border`),
|
|
61
|
+
"surface-canvas": token(`${prefix}-surface-canvas`),
|
|
62
|
+
"surface-elevated": token(`${prefix}-surface-elevated`),
|
|
63
|
+
"surface-floating": token(`${prefix}-surface-floating`)
|
|
64
|
+
},
|
|
65
|
+
radius: { md: token(6) }
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe("Storybook theme mapping", () => {
|
|
69
|
+
it("maps the latest semantic token roles for both Storybook themes", async () => {
|
|
70
|
+
const config = (await import("../../../razorwind.config")).default as {
|
|
71
|
+
plugins: unknown[];
|
|
72
|
+
};
|
|
73
|
+
const storybookPlugin = config.plugins.find(
|
|
74
|
+
(plugin): plugin is StorybookPlugin =>
|
|
75
|
+
typeof plugin === "object" &&
|
|
76
|
+
plugin !== null &&
|
|
77
|
+
"outputPath" in plugin &&
|
|
78
|
+
plugin.outputPath === "apps/storybook/src" &&
|
|
79
|
+
"mapTheme" in plugin &&
|
|
80
|
+
typeof plugin.mapTheme === "function"
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
expect(storybookPlugin).toBeDefined();
|
|
84
|
+
|
|
85
|
+
const themes = storybookPlugin!.mapTheme({
|
|
86
|
+
dark: semanticColors("dark"),
|
|
87
|
+
light: semanticColors("light")
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
expect(themes.dark).toMatchObject({
|
|
91
|
+
base: "dark",
|
|
92
|
+
colorPrimary: "dark-primary",
|
|
93
|
+
colorSecondary: "dark-tertiary",
|
|
94
|
+
textColor: "dark-primary",
|
|
95
|
+
textInverseColor: "dark-surface-canvas",
|
|
96
|
+
appBg: "dark-surface-canvas",
|
|
97
|
+
appContentBg: "dark-surface-elevated",
|
|
98
|
+
appPreviewBg: "dark-surface-canvas",
|
|
99
|
+
appBorderColor: "dark-border",
|
|
100
|
+
appBorderRadius: 6,
|
|
101
|
+
barTextColor: "dark-secondary",
|
|
102
|
+
barSelectedColor: "dark-primary",
|
|
103
|
+
barBg: "dark-surface-floating",
|
|
104
|
+
barHoverColor: "dark-tertiary",
|
|
105
|
+
buttonBg: "dark-surface-elevated",
|
|
106
|
+
buttonBorder: "dark-border",
|
|
107
|
+
inputBg: "dark-surface-elevated",
|
|
108
|
+
inputBorder: "dark-border",
|
|
109
|
+
inputTextColor: "dark-secondary",
|
|
110
|
+
inputBorderRadius: 6,
|
|
111
|
+
booleanBg: "dark-surface-elevated",
|
|
112
|
+
booleanSelectedBg: "dark-tertiary"
|
|
113
|
+
});
|
|
114
|
+
expect(themes.light.colorPrimary).toBe("light-primary");
|
|
115
|
+
expect(themes.light.textColor).toBe("light-primary");
|
|
116
|
+
expect(themes.light.appBg).toBe("light-surface-canvas");
|
|
117
|
+
});
|
|
118
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"tsBuildInfoFile": "../../dist/out-tsc/packages/theme-builder/tsconfig.tsbuildinfo",
|
|
5
|
+
"types": ["node"],
|
|
6
|
+
"strict": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"outDir": "../../dist/out-tsc/packages/theme-builder",
|
|
9
|
+
"ignoreDeprecations": "6.0"
|
|
10
|
+
},
|
|
11
|
+
"include": ["src/**/*", "powerlines.config.ts", "powerlines.d.ts"],
|
|
12
|
+
"exclude": ["vitest.config.mts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": ".",
|
|
5
|
+
"types": [
|
|
6
|
+
"vitest/globals",
|
|
7
|
+
"vitest/importMeta",
|
|
8
|
+
"node",
|
|
9
|
+
"vitest",
|
|
10
|
+
"@cloudflare/workers-types"
|
|
11
|
+
],
|
|
12
|
+
"outDir": "../../dist/out-tsc"
|
|
13
|
+
},
|
|
14
|
+
"include": ["vitest.config.mts", "src/**/*.ts", "src/**/*.d.ts"],
|
|
15
|
+
"exclude": []
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig(() => ({
|
|
5
|
+
root: import.meta.dirname,
|
|
6
|
+
cacheDir: "../../node_modules/.vite/packages/theme-builder",
|
|
7
|
+
plugins: [nxViteTsPaths()],
|
|
8
|
+
test: {
|
|
9
|
+
name: "theme-builder",
|
|
10
|
+
watch: false,
|
|
11
|
+
globals: true,
|
|
12
|
+
environment: "node",
|
|
13
|
+
include: [
|
|
14
|
+
"src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
15
|
+
"test/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
16
|
+
"tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"
|
|
17
|
+
],
|
|
18
|
+
reporters: ["default"],
|
|
19
|
+
coverage: {
|
|
20
|
+
reportsDirectory: "../../coverage/packages/theme-builder",
|
|
21
|
+
provider: "v8" as const
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}));
|