igniteui-theming 25.1.0 → 25.2.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/dist/index.d.ts +75 -0
- package/dist/index.js +12 -0
- package/dist/json/components/bootstrap.json +1 -0
- package/dist/json/components/fluent.json +1 -0
- package/dist/json/components/indigo.json +1 -0
- package/dist/json/components/material.json +1 -0
- package/{json → dist/json}/components/themes.json +31 -1
- package/dist/mcp/generators/css.d.ts +7 -4
- package/dist/mcp/generators/css.js +129 -104
- package/dist/mcp/generators/sass.js +227 -254
- package/dist/mcp/index.js +259 -323
- package/dist/mcp/knowledge/color-usage.js +524 -502
- package/dist/mcp/knowledge/colors.js +61 -50
- package/dist/mcp/knowledge/component-metadata.js +697 -598
- package/dist/mcp/knowledge/component-themes.js +70 -57
- package/dist/mcp/knowledge/custom-palettes.js +4 -9
- package/dist/mcp/knowledge/docs/colors/guidance.js +4 -0
- package/dist/mcp/knowledge/docs/colors/usage.js +4 -0
- package/dist/mcp/knowledge/docs/layout/functions/border-radius.js +4 -0
- package/dist/mcp/knowledge/docs/layout/functions/pad.js +4 -0
- package/dist/mcp/knowledge/docs/layout/functions/sizable.js +4 -0
- package/dist/mcp/knowledge/docs/layout/mixins/sizable.js +4 -0
- package/dist/mcp/knowledge/docs/layout/mixins/sizing.js +4 -0
- package/dist/mcp/knowledge/docs/layout/mixins/spacing.js +4 -0
- package/dist/mcp/knowledge/docs/layout/overview.js +4 -0
- package/dist/mcp/knowledge/docs/setup/platform.js +4 -0
- package/dist/mcp/knowledge/elevations.d.ts +1 -1
- package/dist/mcp/knowledge/elevations.js +26 -12
- package/dist/mcp/knowledge/index.js +23 -87
- package/dist/mcp/knowledge/layout-docs.d.ts +1 -1
- package/dist/mcp/knowledge/multipliers.js +5 -0
- package/dist/mcp/knowledge/palettes.js +29 -17
- package/dist/mcp/knowledge/platforms/angular.js +98 -120
- package/dist/mcp/knowledge/platforms/blazor.js +39 -34
- package/dist/mcp/knowledge/platforms/common.js +83 -68
- package/dist/mcp/knowledge/platforms/index.js +265 -242
- package/dist/mcp/knowledge/platforms/react.js +43 -35
- package/dist/mcp/knowledge/platforms/webcomponents.js +266 -292
- package/dist/mcp/knowledge/sass-api.js +1 -0
- package/dist/mcp/knowledge/typography.js +13 -5
- package/dist/mcp/resources/index.js +1 -0
- package/dist/mcp/resources/presets.js +409 -508
- package/dist/mcp/theming/dist/json/colors/meta/multipliers.js +50 -0
- package/dist/mcp/theming/dist/json/colors/presets/palettes.js +85 -0
- package/dist/mcp/theming/dist/json/components/themes.js +5792 -0
- package/dist/mcp/theming/dist/json/elevations/indigo.js +29 -0
- package/dist/mcp/theming/dist/json/elevations/material.js +3 -0
- package/dist/mcp/theming/dist/json/typography/presets/typescales.js +621 -0
- package/dist/mcp/tools/descriptions.js +98 -154
- package/dist/mcp/tools/handlers/color.js +58 -56
- package/dist/mcp/tools/handlers/component-theme.js +163 -225
- package/dist/mcp/tools/handlers/component-tokens.js +159 -219
- package/dist/mcp/tools/handlers/custom-palette.js +138 -179
- package/dist/mcp/tools/handlers/elevations.js +27 -28
- package/dist/mcp/tools/handlers/index.js +11 -0
- package/dist/mcp/tools/handlers/layout.js +125 -176
- package/dist/mcp/tools/handlers/palette.js +105 -120
- package/dist/mcp/tools/handlers/platform.js +289 -311
- package/dist/mcp/tools/handlers/resource.js +22 -31
- package/dist/mcp/tools/handlers/theme.js +86 -103
- package/dist/mcp/tools/handlers/typography.js +29 -30
- package/dist/mcp/tools/index.js +13 -0
- package/dist/mcp/tools/schemas.js +239 -218
- package/dist/mcp/utils/color.js +277 -239
- package/dist/mcp/utils/preprocessing.js +57 -30
- package/dist/mcp/utils/result.js +43 -45
- package/dist/mcp/utils/sass.js +271 -191
- package/dist/mcp/utils/theming-resolve.d.ts +19 -0
- package/dist/mcp/utils/theming-resolve.js +57 -0
- package/dist/mcp/utils/types.js +96 -53
- package/dist/mcp/validators/custom-palette.js +218 -243
- package/dist/mcp/validators/index.js +3 -0
- package/dist/mcp/validators/palette.js +231 -229
- package/dist/tailwind/utilities/bootstrap.css +1 -0
- package/dist/tailwind/utilities/fluent.css +1 -0
- package/dist/tailwind/utilities/indigo.css +1 -0
- package/dist/tailwind/utilities/material.css +1 -0
- package/package.json +45 -64
- package/sass/json/README.md +12 -7
- package/sass/themes/_mixins.scss +1 -0
- package/sass/themes/components/button-group/_button-group-theme.scss +42 -0
- package/sass/themes/components/grid/_grid-theme.scss +1 -1
- package/sass/themes/schemas/components/dark/_button-group.scss +173 -50
- package/sass/themes/schemas/components/dark/_grid.scss +0 -16
- package/sass/themes/schemas/components/light/_button-group.scss +221 -99
- package/sass/themes/schemas/components/light/_grid.scss +14 -20
- package/LICENSE +0 -21
- package/README.md +0 -391
- package/dist/mcp/json/colors/presets/palettes.json.js +0 -13
- package/dist/mcp/json/components/themes.json.js +0 -143
- package/dist/mcp/json/elevations/indigo.json.js +0 -8
- package/dist/mcp/json/elevations/material.json.js +0 -8
- package/dist/mcp/json/typography/presets/typescales.json.js +0 -17
- package/dist/mcp/knowledge/docs/colors/guidance.md.js +0 -4
- package/dist/mcp/knowledge/docs/colors/usage.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/functions/border-radius.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/functions/pad.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/functions/sizable.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/mixins/sizable.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/mixins/sizing.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/mixins/spacing.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/overview.md.js +0 -4
- package/dist/mcp/knowledge/docs/setup/platform.md.js +0 -4
- package/dist/mcp/vite-env.d.ts +0 -18
- package/index.js +0 -5
- package/json/components/bootstrap.json +0 -1
- package/json/components/fluent.json +0 -1
- package/json/components/indigo.json +0 -1
- package/json/components/material.json +0 -1
- package/tailwind/utilities/bootstrap.css +0 -1
- package/tailwind/utilities/fluent.css +0 -1
- package/tailwind/utilities/indigo.css +0 -1
- package/tailwind/utilities/material.css +0 -1
- /package/{json → dist/json}/colors/meta/multipliers.json +0 -0
- /package/{json → dist/json}/colors/meta/palette.json +0 -0
- /package/{json → dist/json}/colors/presets/palettes.json +0 -0
- /package/{json → dist/json}/elevations/indigo.json +0 -0
- /package/{json → dist/json}/elevations/material.json +0 -0
- /package/{json → dist/json}/typography/presets/typescales.json +0 -0
- /package/{tailwind → dist/tailwind}/themes/base.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/dark/bootstrap.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/dark/fluent.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/dark/indigo.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/dark/material.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/light/bootstrap.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/light/fluent.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/light/indigo.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/light/material.css +0 -0
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
import { getComponentSelector } from "../knowledge/component-metadata.js";
|
|
2
2
|
import { getComponentTheme } from "../knowledge/component-themes.js";
|
|
3
|
-
import { generateAngularThemeSass } from "../knowledge/platforms/angular.js";
|
|
4
3
|
import { SCHEMAS } from "../knowledge/platforms/common.js";
|
|
5
4
|
import { generateWebComponentsThemeSass } from "../knowledge/platforms/webcomponents.js";
|
|
6
5
|
import { TYPOGRAPHY_PRESETS } from "../knowledge/typography.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { generateHeader, generatePresetImports, generateUseStatement, quoteFontFamily, toVariableName } from "../utils/sass.js";
|
|
7
|
+
import { generateAngularThemeSass } from "../knowledge/platforms/angular.js";
|
|
8
|
+
//#region src/generators/sass.ts
|
|
9
|
+
/**
|
|
10
|
+
* Sass code generator for Ignite UI Theming.
|
|
11
|
+
* Generates valid Sass code that uses the igniteui-theming library.
|
|
12
|
+
*
|
|
13
|
+
* Supported platforms:
|
|
14
|
+
* - Angular: Uses `igniteui-angular/theming` with `core()` and `theme()` mixins
|
|
15
|
+
* - Web Components: Uses `igniteui-theming` directly with individual mixins
|
|
16
|
+
* - Blazor: Uses `igniteui-theming` directly with individual mixins
|
|
17
|
+
* - React: Uses `igniteui-theming` directly with individual mixins
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Generate a palette definition.
|
|
21
|
+
*/
|
|
9
22
|
function generatePalette(input) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
const variant = input.variant ?? "light";
|
|
24
|
+
const varName = `$${input.name ? toVariableName(input.name) : `custom-${variant}`}-palette`;
|
|
25
|
+
const paletteArgs = [
|
|
26
|
+
`$primary: ${input.primary}`,
|
|
27
|
+
`$secondary: ${input.secondary}`,
|
|
28
|
+
`$surface: ${input.surface}`
|
|
29
|
+
];
|
|
30
|
+
if (input.gray) paletteArgs.push(`$gray: ${input.gray}`);
|
|
31
|
+
if (input.info) paletteArgs.push(`$info: ${input.info}`);
|
|
32
|
+
if (input.success) paletteArgs.push(`$success: ${input.success}`);
|
|
33
|
+
if (input.warn) paletteArgs.push(`$warn: ${input.warn}`);
|
|
34
|
+
if (input.error) paletteArgs.push(`$error: ${input.error}`);
|
|
35
|
+
return {
|
|
36
|
+
code: `${generateHeader(`${variant} palette with primary color ${input.primary}`)}
|
|
24
37
|
${generateUseStatement(input.platform, input.licensed)}
|
|
25
38
|
|
|
26
39
|
// Custom ${variant} palette
|
|
@@ -30,27 +43,26 @@ ${varName}: palette(
|
|
|
30
43
|
|
|
31
44
|
// Apply the palette (generates CSS custom properties)
|
|
32
45
|
@include palette(${varName});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
variables: [varName]
|
|
38
|
-
};
|
|
46
|
+
`,
|
|
47
|
+
description: `Generated a ${variant} color palette with primary color ${input.primary}`,
|
|
48
|
+
variables: [varName]
|
|
49
|
+
};
|
|
39
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Generate typography setup.
|
|
53
|
+
*/
|
|
40
54
|
function generateTypography(input) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
].join("\n");
|
|
53
|
-
const code = `${generateHeader(`Typography setup using ${designSystem} type scale`)}
|
|
55
|
+
const designSystem = input.designSystem ?? "material";
|
|
56
|
+
const typeScaleVar = `$${designSystem}-type-scale`;
|
|
57
|
+
const preset = TYPOGRAPHY_PRESETS[designSystem];
|
|
58
|
+
const typeface = input.fontFamily || preset.typeface;
|
|
59
|
+
const presetImports = generatePresetImports({
|
|
60
|
+
platform: input.platform,
|
|
61
|
+
includeTypography: true
|
|
62
|
+
});
|
|
63
|
+
const imports = [generateUseStatement(input.platform, input.licensed), ...presetImports].join("\n");
|
|
64
|
+
return {
|
|
65
|
+
code: `${generateHeader(`Typography setup using ${designSystem} type scale`)}
|
|
54
66
|
${imports}
|
|
55
67
|
|
|
56
68
|
// Typography setup with ${designSystem} type scale
|
|
@@ -58,238 +70,199 @@ ${imports}
|
|
|
58
70
|
$font-family: ${quoteFontFamily(typeface)},
|
|
59
71
|
$type-scale: ${typeScaleVar}
|
|
60
72
|
);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
variables: [typeScaleVar]
|
|
66
|
-
};
|
|
73
|
+
`,
|
|
74
|
+
description: `Generated typography setup using ${designSystem} design system with font family ${typeface}`,
|
|
75
|
+
variables: [typeScaleVar]
|
|
76
|
+
};
|
|
67
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Generate elevations setup.
|
|
80
|
+
*/
|
|
68
81
|
function generateElevations(input) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
].join("\n");
|
|
79
|
-
const code = `${generateHeader(`Elevations setup using ${preset} preset`)}
|
|
82
|
+
const preset = input.designSystem ?? "material";
|
|
83
|
+
const elevationsVar = `$${preset}-elevations`;
|
|
84
|
+
const presetImports = generatePresetImports({
|
|
85
|
+
platform: input.platform,
|
|
86
|
+
includeElevations: true
|
|
87
|
+
});
|
|
88
|
+
const imports = [generateUseStatement(input.platform, input.licensed), ...presetImports].join("\n");
|
|
89
|
+
return {
|
|
90
|
+
code: `${generateHeader(`Elevations setup using ${preset} preset`)}
|
|
80
91
|
${imports}
|
|
81
92
|
|
|
82
93
|
// Elevations setup with ${preset} shadows
|
|
83
94
|
@include elevations(${elevationsVar});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
variables: [elevationsVar]
|
|
89
|
-
};
|
|
95
|
+
`,
|
|
96
|
+
description: `Generated elevations setup using ${preset} preset (25 elevation levels)`,
|
|
97
|
+
variables: [elevationsVar]
|
|
98
|
+
};
|
|
90
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Generate a complete theme (palette + typography + elevations).
|
|
102
|
+
*
|
|
103
|
+
* Supports two platforms:
|
|
104
|
+
* - `angular`: Uses `igniteui-angular/theming` with `core()` and `theme()` mixins
|
|
105
|
+
* - `webcomponents`: Uses `igniteui-theming` directly with individual mixins
|
|
106
|
+
*
|
|
107
|
+
* If no platform is specified, defaults to generating platform-agnostic code
|
|
108
|
+
* using igniteui-theming directly (similar to webcomponents but simpler).
|
|
109
|
+
*/
|
|
91
110
|
function generateTheme(input) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
default:
|
|
103
|
-
return generateGenericTheme(input, designSystem, variant);
|
|
104
|
-
}
|
|
111
|
+
const platform = input.platform;
|
|
112
|
+
const designSystem = input.designSystem ?? "material";
|
|
113
|
+
const variant = input.variant ?? "light";
|
|
114
|
+
switch (platform) {
|
|
115
|
+
case "angular": return generateAngularTheme(input, designSystem, variant);
|
|
116
|
+
case "webcomponents":
|
|
117
|
+
case "react":
|
|
118
|
+
case "blazor": return generateWebComponentsTheme(input, designSystem, variant);
|
|
119
|
+
default: return generateGenericTheme(input, designSystem, variant);
|
|
120
|
+
}
|
|
105
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Generate Angular-specific theme using core() and theme() mixins.
|
|
124
|
+
*/
|
|
106
125
|
function generateAngularTheme(input, designSystem, variant) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
code,
|
|
130
|
-
description: `Generated Angular ${variant} theme based on ${designSystem} design system`,
|
|
131
|
-
variables
|
|
132
|
-
};
|
|
126
|
+
const code = generateAngularThemeSass({
|
|
127
|
+
designSystem,
|
|
128
|
+
variant,
|
|
129
|
+
primaryColor: input.primaryColor,
|
|
130
|
+
secondaryColor: input.secondaryColor,
|
|
131
|
+
surfaceColor: input.surfaceColor,
|
|
132
|
+
customPaletteName: input.name ? `$${toVariableName(input.name)}-palette` : void 0,
|
|
133
|
+
fontFamily: input.fontFamily,
|
|
134
|
+
includeTypography: input.includeTypography !== false
|
|
135
|
+
});
|
|
136
|
+
const variables = [];
|
|
137
|
+
if (input.name) variables.push(`$${toVariableName(input.name)}-palette`);
|
|
138
|
+
variables.push(`$${variant}-${designSystem}-schema`);
|
|
139
|
+
if (input.includeTypography !== false) {
|
|
140
|
+
if (!input.fontFamily) variables.push(`$${designSystem}-typeface`);
|
|
141
|
+
variables.push(`$${designSystem}-type-scale`);
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
code,
|
|
145
|
+
description: `Generated Angular ${variant} theme based on ${designSystem} design system`,
|
|
146
|
+
variables
|
|
147
|
+
};
|
|
133
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Generate Web Components-specific theme using individual mixins.
|
|
151
|
+
*/
|
|
134
152
|
function generateWebComponentsTheme(input, designSystem, variant) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
variables.push(
|
|
161
|
-
designSystem === "indigo" ? "$indigo-elevations" : "$material-elevations"
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
code,
|
|
166
|
-
description: `Generated Web Components ${variant} theme based on ${designSystem} design system`,
|
|
167
|
-
variables
|
|
168
|
-
};
|
|
153
|
+
const code = generateWebComponentsThemeSass({
|
|
154
|
+
designSystem,
|
|
155
|
+
variant,
|
|
156
|
+
primaryColor: input.primaryColor,
|
|
157
|
+
secondaryColor: input.secondaryColor,
|
|
158
|
+
surfaceColor: input.surfaceColor,
|
|
159
|
+
customPaletteName: input.name ? `$${toVariableName(input.name)}-palette` : void 0,
|
|
160
|
+
fontFamily: input.fontFamily,
|
|
161
|
+
includeTypography: input.includeTypography !== false,
|
|
162
|
+
includeElevations: input.includeElevations !== false,
|
|
163
|
+
includeSpacing: input.includeSpacing !== false
|
|
164
|
+
});
|
|
165
|
+
const variables = [];
|
|
166
|
+
if (input.name) variables.push(`$${toVariableName(input.name)}-palette`);
|
|
167
|
+
else variables.push("$palette");
|
|
168
|
+
if (input.includeTypography !== false) {
|
|
169
|
+
if (!input.fontFamily) variables.push("$typeface");
|
|
170
|
+
variables.push("$type-scale");
|
|
171
|
+
}
|
|
172
|
+
if (input.includeElevations !== false) variables.push(designSystem === "indigo" ? "$indigo-elevations" : "$material-elevations");
|
|
173
|
+
return {
|
|
174
|
+
code,
|
|
175
|
+
description: `Generated Web Components ${variant} theme based on ${designSystem} design system`,
|
|
176
|
+
variables
|
|
177
|
+
};
|
|
169
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Generate platform-agnostic theme (legacy behavior).
|
|
181
|
+
* Uses igniteui-theming directly without platform-specific optimizations.
|
|
182
|
+
*/
|
|
170
183
|
function generateGenericTheme(input, designSystem, variant) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
");"
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
if (includeElevations) {
|
|
220
|
-
const elevationPreset = designSystem === "indigo" ? "indigo" : "material";
|
|
221
|
-
const elevationsVar = `$${elevationPreset}-elevations`;
|
|
222
|
-
variables.push(elevationsVar);
|
|
223
|
-
sections.push(
|
|
224
|
-
"",
|
|
225
|
-
"// Elevations setup",
|
|
226
|
-
`@include elevations(${elevationsVar});`
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
const code = `${sections.join("\n")}
|
|
230
|
-
`;
|
|
231
|
-
return {
|
|
232
|
-
code,
|
|
233
|
-
description: `Generated complete ${variant} theme based on ${designSystem} design system (platform-agnostic)`,
|
|
234
|
-
variables
|
|
235
|
-
};
|
|
184
|
+
const themeName = input.name ? toVariableName(input.name) : `${variant}-${designSystem}`;
|
|
185
|
+
const paletteVar = `$${themeName}-palette`;
|
|
186
|
+
const includeTypography = input.includeTypography !== false;
|
|
187
|
+
const includeElevations = input.includeElevations !== false;
|
|
188
|
+
const variables = [paletteVar];
|
|
189
|
+
const paletteArgs = [`$primary: ${input.primaryColor}`];
|
|
190
|
+
if (input.secondaryColor) paletteArgs.push(`$secondary: ${input.secondaryColor}`);
|
|
191
|
+
if (input.surfaceColor) paletteArgs.push(`$surface: ${input.surfaceColor}`);
|
|
192
|
+
else paletteArgs.push(`$surface: ${variant === "dark" ? "#222222" : "white"}`);
|
|
193
|
+
const presetImports = generatePresetImports({
|
|
194
|
+
platform: input.platform,
|
|
195
|
+
includeTypography,
|
|
196
|
+
includeElevations
|
|
197
|
+
});
|
|
198
|
+
const sections = [
|
|
199
|
+
generateHeader(`Complete ${variant} theme based on ${designSystem} design system`),
|
|
200
|
+
"// NOTE: Specify platform (\"angular\" or \"webcomponents\") for optimized output",
|
|
201
|
+
generateUseStatement(input.platform, input.licensed),
|
|
202
|
+
...presetImports,
|
|
203
|
+
"",
|
|
204
|
+
`// ${themeName} palette`,
|
|
205
|
+
`${paletteVar}: palette(`,
|
|
206
|
+
` ${paletteArgs.join(",\n ")}`,
|
|
207
|
+
");",
|
|
208
|
+
"",
|
|
209
|
+
"// Apply the palette",
|
|
210
|
+
`@include palette(${paletteVar});`
|
|
211
|
+
];
|
|
212
|
+
if (includeTypography) {
|
|
213
|
+
const preset = TYPOGRAPHY_PRESETS[designSystem];
|
|
214
|
+
const typeface = input.fontFamily || preset.typeface;
|
|
215
|
+
const typeScaleVar = `$${designSystem}-type-scale`;
|
|
216
|
+
variables.push(typeScaleVar);
|
|
217
|
+
sections.push("", "// Typography setup", "@include typography(", ` $font-family: ${quoteFontFamily(typeface)},`, ` $type-scale: ${typeScaleVar}`, ");");
|
|
218
|
+
}
|
|
219
|
+
if (includeElevations) {
|
|
220
|
+
const elevationsVar = `$${designSystem === "indigo" ? "indigo" : "material"}-elevations`;
|
|
221
|
+
variables.push(elevationsVar);
|
|
222
|
+
sections.push("", "// Elevations setup", `@include elevations(${elevationsVar});`);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
code: `${sections.join("\n")}\n`,
|
|
226
|
+
description: `Generated complete ${variant} theme based on ${designSystem} design system (platform-agnostic)`,
|
|
227
|
+
variables
|
|
228
|
+
};
|
|
236
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Generate Sass code for a component theme.
|
|
232
|
+
*/
|
|
237
233
|
function generateComponentTheme(input) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
sections.push(`${selector} {`);
|
|
271
|
-
sections.push(` @include tokens(${themeName});`);
|
|
272
|
-
sections.push("}");
|
|
273
|
-
const code = `${sections.join("\n")}
|
|
274
|
-
`;
|
|
275
|
-
return {
|
|
276
|
-
code,
|
|
277
|
-
description: `Generated custom ${input.component} theme with ${Object.keys(input.tokens).length} token(s) using ${designSystem} design system (${variant} variant)`,
|
|
278
|
-
variables: [themeName]
|
|
279
|
-
};
|
|
234
|
+
const theme = getComponentTheme(input.component);
|
|
235
|
+
if (!theme) throw new Error(`Unknown component: ${input.component}`);
|
|
236
|
+
const designSystem = input.designSystem ?? "material";
|
|
237
|
+
const variant = input.variant ?? "light";
|
|
238
|
+
const themeFn = theme.themeFunctionName;
|
|
239
|
+
const themeName = input.name ? `$${toVariableName(input.name)}` : `$custom-${input.component}-theme`;
|
|
240
|
+
const tokenArgs = [`$schema: ${SCHEMAS[variant][designSystem]}`];
|
|
241
|
+
for (const [tokenName, value] of Object.entries(input.tokens)) {
|
|
242
|
+
const stringValue = typeof value === "number" ? String(value) : value;
|
|
243
|
+
tokenArgs.push(`$${tokenName}: ${stringValue}`);
|
|
244
|
+
}
|
|
245
|
+
const defaultSelectors = getComponentSelector(input.component, input.platform);
|
|
246
|
+
const selector = input.selector || (defaultSelectors.length > 0 ? defaultSelectors[0] : input.component);
|
|
247
|
+
const sections = [
|
|
248
|
+
generateHeader(`Custom ${input.component} theme`),
|
|
249
|
+
generateUseStatement(input.platform, input.licensed),
|
|
250
|
+
"",
|
|
251
|
+
`// Custom ${input.component} theme`,
|
|
252
|
+
`${themeName}: ${themeFn}(`
|
|
253
|
+
];
|
|
254
|
+
if (tokenArgs.length > 0) sections.push(` ${tokenArgs.join(",\n ")}`);
|
|
255
|
+
sections.push(");");
|
|
256
|
+
sections.push("");
|
|
257
|
+
sections.push(`// Apply the theme to ${selector}`);
|
|
258
|
+
sections.push(`${selector} {`);
|
|
259
|
+
sections.push(` @include tokens(${themeName});`);
|
|
260
|
+
sections.push("}");
|
|
261
|
+
return {
|
|
262
|
+
code: `${sections.join("\n")}\n`,
|
|
263
|
+
description: `Generated custom ${input.component} theme with ${Object.keys(input.tokens).length} token(s) using ${designSystem} design system (${variant} variant)`,
|
|
264
|
+
variables: [themeName]
|
|
265
|
+
};
|
|
280
266
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
generateElevations,
|
|
284
|
-
generateElevationsCode,
|
|
285
|
-
generateHeader,
|
|
286
|
-
generatePalette,
|
|
287
|
-
generatePaletteCode,
|
|
288
|
-
generatePresetImports,
|
|
289
|
-
generateTheme,
|
|
290
|
-
generateTypography,
|
|
291
|
-
generateTypographyCode,
|
|
292
|
-
generateUseStatement,
|
|
293
|
-
quoteFontFamily,
|
|
294
|
-
toVariableName
|
|
295
|
-
};
|
|
267
|
+
//#endregion
|
|
268
|
+
export { generateComponentTheme, generateElevations, generatePalette, generateTheme, generateTypography };
|