Skip to content

Commit 531e8e6

Browse files
authored
feat: Adds color seed API and palette generation utilities (#130)
1 parent e28b540 commit 531e8e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3069
-381
lines changed

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
2525
"@cloudscape-design/browser-test-tools": "^3.0.2",
2626
"@cloudscape-design/component-toolkit": "^1.0.0-beta.53",
27+
"@material/material-color-utilities": "^0.3.0",
2728
"@tsconfig/node16": "^1.0.3",
2829
"@types/loader-utils": "^2.0.3",
2930
"@types/lodash": "^4.14.183",
30-
"@types/node": "^18.19.23",
3131
"@types/postcss-inline-svg": "^5.0.0",
3232
"@types/rimraf": "^3.0.2",
3333
"@types/string-hash": "^1.1.1",
@@ -66,5 +66,8 @@
6666
"package-lock.json": [
6767
"./scripts/unlock-packages.js"
6868
]
69+
},
70+
"devDependencies": {
71+
"@types/node": "^24.10.0"
6972
}
7073
}

scripts/generate-package.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const packages = [
2323
},
2424
packageRoot: path.join(root, './lib/node'),
2525
dependencies: [
26+
'@material/material-color-utilities',
2627
'autoprefixer',
2728
'glob',
2829
'jsonschema',
@@ -44,7 +45,7 @@ const packages = [
4445
files: ['shared', 'browser'],
4546
},
4647
packageRoot: path.join(root, './lib/browser'),
47-
dependencies: ['tslib'],
48+
dependencies: ['@material/material-color-utilities', 'tslib'],
4849
},
4950
];
5051

src/__fixtures__/common.ts

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const emptyTheme: Theme = {
9090

9191
export const rootTheme: Theme = {
9292
id: 'root',
93-
selector: ':root',
93+
selector: 'body',
9494
tokens: {
9595
fontFamilyBase: '"Helvetica Neue", Arial, sans-serif',
9696
fontFamilyBody: '{fontFamilyBase}',
@@ -435,3 +435,59 @@ export const descriptionsForValidTheme = {
435435
colorButton: 'color',
436436
shadowContainer: 'shadow',
437437
};
438+
439+
// Themes for performance testing: seed vs explicit palette
440+
export const themeWithSeedColor: Theme = {
441+
...rootTheme,
442+
referenceTokens: {
443+
color: {
444+
primary: '#0073bb',
445+
},
446+
},
447+
};
448+
449+
export const themeWithExplicitPalette: Theme = {
450+
...rootTheme,
451+
referenceTokens: {
452+
color: {
453+
primary: {
454+
50: '#f7f9ff',
455+
100: '#ecf3ff',
456+
200: '#d2e6ff',
457+
300: '#aed3ff',
458+
400: '#7abbff',
459+
500: '#4e9fea',
460+
600: '#0073bb',
461+
700: '#006aad',
462+
800: '#005187',
463+
900: '#003b64',
464+
1000: '#001123',
465+
},
466+
},
467+
},
468+
};
469+
470+
export const presetWithSeedColor: ThemePreset = {
471+
theme: themeWithSeedColor,
472+
themeable: [],
473+
exposed: [],
474+
propertiesMap: createStubPropertiesMap(themeWithSeedColor),
475+
variablesMap: createStubVariablesMap(themeWithSeedColor),
476+
};
477+
478+
export const presetWithExplicitPalette: ThemePreset = {
479+
theme: themeWithExplicitPalette,
480+
themeable: [],
481+
exposed: [],
482+
propertiesMap: createStubPropertiesMap(themeWithExplicitPalette),
483+
variablesMap: createStubVariablesMap(themeWithExplicitPalette),
484+
};
485+
486+
export const overrideWithSeedColor: Override = {
487+
tokens: { ...override.tokens },
488+
referenceTokens: {
489+
color: {
490+
primary: '#0073bb',
491+
},
492+
},
493+
};

0 commit comments

Comments
 (0)