Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(styles,theme): add S2 tokens and theme #4241

Merged
merged 133 commits into from May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
2983a36
refactor(theme): adds new system attribute and deprecates theme attri…
jnjosh Mar 13, 2024
956106f
chore(theme): made changes on theme attribute
Mar 21, 2024
407efbf
chore: reverted THEME Key to support migrations
Mar 21, 2024
f7c2486
Merge branch 'main' of https://github.com/adobe/spectrum-web-componen…
Apr 1, 2024
664d2c2
chore: theme registrated hard break
Apr 1, 2024
9714b15
refactor(theme): adds new system attribute and deprecates theme attri…
jnjosh Mar 13, 2024
4830eed
chore(theme): made changes on theme attribute
Mar 21, 2024
e69bb48
chore: reverted THEME Key to support migrations
Mar 21, 2024
dc00e12
chore: theme registrated hard break
Apr 1, 2024
a20edc2
Merge branch 'jnjosh/theming-systems' of https://github.com/adobe/spe…
Apr 1, 2024
e159afc
chore(theme): updated theme property to system
Apr 1, 2024
576b603
chore(theme): updated theme to system in sp-theme in layout
Apr 1, 2024
4ffc9fb
chore(theme): updated config for VRT
Apr 1, 2024
bfa82d9
chore(theme): updated config for VRT from theme to system
Apr 1, 2024
20595ee
chore: update theme property to system
Apr 2, 2024
6fe7a68
fix: added spectrum system variant
Apr 2, 2024
2490dd5
chore: updated theme for deprecation against system in theme files
Apr 3, 2024
8830483
chore: updated config to support system
Apr 3, 2024
be29dcc
chore: updated config yml
Apr 3, 2024
1a4624e
chore: updated config yml
Apr 3, 2024
4ea39f0
chore: updated config yml
Apr 3, 2024
36bf032
chore: undo system changes in stories
Apr 3, 2024
771a7be
chore: updated runner utils
Apr 3, 2024
c3625ae
chore: review to run with theme
Apr 3, 2024
e9da66d
chore(theme): updated command-line arguments to ue system instea do f…
Apr 3, 2024
6c413b0
chore(theme): updated command-line arguments to ue system instea do f…
Apr 3, 2024
d26d278
chore(theme): updated and cleaned up reduntant theme definitions with…
Apr 4, 2024
11a8e6d
chore: added theme fallback to the storydecotrator render
Apr 4, 2024
86e1fec
chore: added system flag in the create review site job in CI
Apr 4, 2024
32da346
chore: added system flag in the create review site job in CI
Apr 4, 2024
12fab6f
chore: updated config to include system
Apr 4, 2024
5033850
chore: removed classic from system variant
Apr 4, 2024
495df4c
chore: removed classic from system variant
Apr 4, 2024
f080dce
chore: added system in parameters in config
Apr 4, 2024
2c64fab
chore: added system in parameters in config
Apr 4, 2024
8266acf
chore: added system in parameters in config
Apr 4, 2024
947e8d6
chore: added system in parameters in config
Apr 4, 2024
9b7a4be
chore: added system in parameters in config
Apr 4, 2024
9d81c57
chore: added theme in parameters in config
Apr 4, 2024
278790d
chore: reverted to theme in currentStyles
Apr 9, 2024
87a8585
chore: update styles for both system/theme changes
TarunAdobe Apr 10, 2024
3e80cf4
chore: fixed updating theme when system value is not there
TarunAdobe Apr 10, 2024
2aaaf1d
chore: added t theme coverage tests
TarunAdobe Apr 10, 2024
4f20e3b
chore: updated doc on prperty theme
Apr 24, 2024
1471312
chore: updated golden image cache
Apr 24, 2024
ac47ddc
chore: updated to spectrum-two
Apr 24, 2024
9a217fd
chore: updated golden image cache
Apr 24, 2024
d056a0d
chore: resolved merged conflicts
Apr 24, 2024
f189220
chore: check added to update system for theme only attribute during d…
Apr 25, 2024
a6d4d94
chore: rebased to systems pr
TarunAdobe Apr 26, 2024
78a0664
feat: added s2 theme to storyDecorator
TarunAdobe Apr 4, 2024
a2cb7a4
chore: added s2 to documentation site
TarunAdobe Apr 4, 2024
94e1281
chore: added spectrum-two to the visual testing pipeline
TarunAdobe Apr 4, 2024
06df4d4
chore: added s2 in web-test-util
TarunAdobe Apr 4, 2024
6074ed4
chore: added s2 theme to vrts
TarunAdobe Apr 5, 2024
66c38a9
chore: testing if vrts run
TarunAdobe Apr 5, 2024
f46ed85
chore: added spectrum-two-tokens-config in package.json
TarunAdobe Apr 8, 2024
0e0c9a7
chore: removed extra console log and updated tokens
TarunAdobe Apr 8, 2024
6fc0009
chore: trying s2 as a theme in vrt instead of spectrum-two
TarunAdobe Apr 8, 2024
fccda29
chore: updated config
TarunAdobe Apr 8, 2024
4f8263f
chore: testing a hacky fix for s2 vrts
TarunAdobe Apr 8, 2024
2600a89
chore: updated button and fieldlable to s2
TarunAdobe Apr 8, 2024
19c76fb
chore: added core.ts to import theme helpers inside spectrum-two
Apr 10, 2024
7434a55
chore: spectrum-two core export
Apr 10, 2024
7d9080e
chore: testing if updating the global vars fixes the build
TarunAdobe Apr 10, 2024
dd46a75
chore: revert back css updates for button and field-label
TarunAdobe Apr 22, 2024
294677b
chore(styles): reapply some poorly cached build output (#4232)
Westbrook Apr 2, 2024
341bfa2
performance: added memory tests in packages (#4228)
Rajdeepc Apr 2, 2024
6a9e52e
fix(coachmark): add "step-count" slot for custom/internationalized pa…
Rajdeepc Apr 2, 2024
2a78be2
chore: bump the commitlint-ecosystem group with 2 updates (#4219)
dependabot[bot] Apr 2, 2024
b43662c
test: update benchmarking to configure "end" as "updateComplete" or "…
Westbrook Apr 1, 2024
7d76eed
fix(shared): ensure the "updateComplete" in Focusable is stable
Westbrook Apr 1, 2024
6aa150c
chore: release new versions #publish
Westbrook Apr 2, 2024
a513484
chore: bump webpack-dev-server from 5.0.2 to 5.0.4
dependabot[bot] Apr 2, 2024
dcfeee5
chore: bump markdown-it from 14.0.0 to 14.1.0
dependabot[bot] Apr 2, 2024
72a60c5
chore: bump fs-extra from 11.1.1 to 11.2.0
dependabot[bot] Apr 2, 2024
22cf1f5
chore(picker): update event bind timing
Westbrook Apr 3, 2024
bf238aa
chore: release new versions #publish
Westbrook Apr 3, 2024
cb38bb0
fix(color-area): providing x and y attributes renders color handle co…
blunteshwar Apr 4, 2024
a4e109c
chore(menu): remove deprecated CSS file (#4249)
Rocss Apr 9, 2024
471d85e
fix(combobox): correct package.json listings
Westbrook Apr 5, 2024
bb06fa1
chore: bump webpack from 5.90.3 to 5.91.0
dependabot[bot] Apr 10, 2024
d03f0aa
chore: bump prettier-plugin-package from 1.3.0 to 1.4.0
dependabot[bot] Apr 10, 2024
907773f
chore: bump @types/react from 18.2.15 to 18.2.75
dependabot[bot] Apr 10, 2024
98c8c4a
chore: bump protobufjs from 7.2.4 to 7.2.6
dependabot[bot] Apr 10, 2024
4def188
chore: bump @11ty/eleventy in the eleventy-ecosystem group
dependabot[bot] Apr 16, 2024
20ca375
chore: bump tar-stream from 3.1.6 to 3.1.7
dependabot[bot] Apr 16, 2024
628b002
chore: updated golden image hash
TarunAdobe Apr 23, 2024
3f6195b
chore: updated golden image hash
TarunAdobe Apr 23, 2024
c440d0a
chore: added sideeffectful registration of theme and removed lightest…
TarunAdobe Apr 24, 2024
a20402c
chore: Configure Renovate (#4248)
renovate[bot] Apr 22, 2024
d2fe74f
chore: update dependency rollup to v4.16.2 (#4288)
renovate[bot] Apr 23, 2024
503d565
chore: bump @11ty/eleventy in the eleventy-ecosystem group (#4291)
dependabot[bot] Apr 23, 2024
e68545f
chore: bump the commitlint-ecosystem group with 2 updates (#4290)
dependabot[bot] Apr 23, 2024
593c13b
chore: update chromedriver (#4293)
Westbrook Apr 24, 2024
df2d9af
chore: use latest playwright (#4295)
Westbrook Apr 24, 2024
d5efe6e
chore: updated golden image hash
TarunAdobe Apr 25, 2024
6c45b9b
chore: fixed merge conflicts
TarunAdobe Apr 26, 2024
408ed92
Merge branch 'main' into swc-s2-styles
TarunAdobe Apr 26, 2024
0408abb
Merge branch 'jnjosh/theming-systems' into swc-s2-styles
TarunAdobe Apr 26, 2024
1482230
chore: fixed merge conflicts
TarunAdobe Apr 26, 2024
84b1d49
chore: use system instead of theme in s2
TarunAdobe Apr 26, 2024
f4ac74b
chore: externalised process spectrum script and update golden image hash
TarunAdobe Apr 26, 2024
e239f2f
chore: merged main
TarunAdobe Apr 26, 2024
3cb248b
chore: normalized spectrum-two var naming usage
TarunAdobe Apr 26, 2024
f18ca66
chore: updated golden image hash
TarunAdobe Apr 26, 2024
f02fbb4
chore: testing something
TarunAdobe Apr 26, 2024
18ba2e0
chore: freshly processed tokens after cleaning everything
TarunAdobe Apr 26, 2024
1b0940f
chore: fixed the generate-tokens script
TarunAdobe Apr 29, 2024
08a787f
chore: updated golden image hash
TarunAdobe Apr 29, 2024
2ee10b4
chore: updated golden image hash
TarunAdobe Apr 29, 2024
645f3ca
chore: normalized the classic theme to spectrum
TarunAdobe Apr 30, 2024
c3e556a
chore: updating baseline for spectrum
TarunAdobe May 1, 2024
3170781
chore: merge main
TarunAdobe May 2, 2024
d8f7d27
chore: updated golden image hash
TarunAdobe May 2, 2024
a25b548
chore: updated golden image hash
TarunAdobe May 2, 2024
4cfc468
chore: removed lightest and darkest theme for spectrum-two
TarunAdobe May 2, 2024
0dc716a
chore: fixed the ci config
TarunAdobe May 2, 2024
4c5799f
chore: merged main
TarunAdobe May 3, 2024
49d9f9d
chore: updated golden image hash
TarunAdobe May 3, 2024
f704042
chore: fixed broken sidenav for vrts site
TarunAdobe May 3, 2024
1d004c6
Merge branch 'main' into swc-s2-styles
TarunAdobe May 3, 2024
a2f1ac1
chore: added devmode warning for S2 theme
TarunAdobe May 7, 2024
3dee34b
Merge branch 'main' into swc-s2-styles
TarunAdobe May 7, 2024
d98d1be
chore: show devmode warning on using s2 theme only in devmode
TarunAdobe May 7, 2024
a32f837
chore: added devmode tests for code coverage
TarunAdobe May 7, 2024
b8eda21
chore: updated devmode tests for theme
TarunAdobe May 8, 2024
2c5c4a6
Merge branch 'main' into swc-s2-styles
TarunAdobe May 8, 2024
33c5c24
chore: update tests for theme
May 13, 2024
03abfae
chore: merge main
TarunAdobe May 13, 2024
cdc49ed
chore: updated golden image cache
May 13, 2024
c5a1a42
Merge branch 'swc-s2-styles' of https://github.com/adobe/spectrum-web…
May 13, 2024
88dfc25
chore: updated golden image cache
May 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 16 additions & 3 deletions .circleci/config.yml
Expand Up @@ -10,7 +10,7 @@ executors:
parameters:
current_golden_images_hash:
type: string
default: 867c424b27081b9e23b1ab8e7f6b1423a6bb754f
default: 4c5799f8273b709eada1adbdb6f4b890678c449b
wireit_cache_name:
type: string
default: wireit
Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
keys:
- v2-golden-images-<< pipeline.parameters.current_golden_images_hash >>-hcm-
- v2-golden-images-main-hcm-
- v2-golden-images-main-classic-lightest-medium-ltr-
- v2-golden-images-main-spectrum-lightest-medium-ltr-
- run:
name: Count baseline images
command: find test/visual/screenshots-baseline -type f | wc -l > count_start.txt
Expand Down Expand Up @@ -321,11 +321,24 @@ workflows:
name: << matrix.theme >>-<< matrix.color >>-<< matrix.scale >>-<< matrix.dir >>
matrix:
parameters:
theme: [classic, express]
theme: [spectrum, express]
Rajdeepc marked this conversation as resolved.
Show resolved Hide resolved
color: [lightest, light, dark, darkest]
scale: [medium, large]
dir: [ltr, rtl]
filters:
branches:
# Forked pull requests have CIRCLE_BRANCH set to pull/XXX
ignore: /pull\/[0-9]+/
- visual:
name: << matrix.theme >>-<< matrix.color >>-<< matrix.scale >>-<< matrix.dir >>
matrix:
parameters:
# Spectrum-two doesn't support the lightest and darkest themes
theme: [spectrum-two]
color: [light, dark]
scale: [medium, large]
dir: [ltr, rtl]
filters:
branches:
# Forked pull requests have CIRCLE_BRANCH set to pull/XXX
ignore: /pull\/[0-9]+/
4 changes: 2 additions & 2 deletions package.json 100644 → 100755
Expand Up @@ -369,13 +369,13 @@
]
},
"process-spectrum": {
"command": "node ./scripts/spectrum-vars.js && node ./tasks/process-spectrum.js && node ./scripts/spectrum-tokens.js && yarn lint:css --fix && pretty-quick --pattern \"{packages,tools}/**/*.css\" && pretty-quick --pattern \"packages/dialog/src/spectrum-dialog.css\"",
"command": "node ./scripts/spectrum-vars.js && node ./tasks/process-spectrum.js && node ./scripts/generate-tokens.js && yarn lint:css --fix && pretty-quick --pattern \"{packages,tools}/**/*.css\" && pretty-quick --pattern \"packages/dialog/src/spectrum-dialog.css\"",
"files": [
"tasks/process-spectrum.js",
"packages/**/spectrum-config.js",
"tools/**/spectrum-config.js",
"node_modules/@spectrum-css/**/index-vars.css",
"scripts/spectrum-tokens.js",
"scripts/generate-tokens.js",
"node_modules/@spectrum-css/**/*.css",
"scripts/spectrum-vars.js",
"tools/styles/package.json"
Expand Down
55 changes: 29 additions & 26 deletions projects/documentation/src/components/layout.ts
Expand Up @@ -93,42 +93,50 @@ const lazyStyleFragment = (
): void => {
var fragmentName = `${name}-${system}`;
switch (fragmentName) {
case 'darkest-spectrum':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that there values are cached into the local storage for users that have previously visited the site. Please add some handling to normalize these to dark or light as needed in that case.

import('@spectrum-web-components/theme/theme-darkest.js');
break;
case 'dark-spectrum':
case 'dark-spectrum' || 'darkest-spectrum':
import('@spectrum-web-components/theme/theme-dark.js');
break;
case 'light-spectrum':
case 'light-spectrum' || 'lightest-spectrum':
import('@spectrum-web-components/theme/theme-light.js');
break;
case 'lightest-spectrum':
import('@spectrum-web-components/theme/theme-lightest.js');
break;
case 'medium-spectrum':
import('@spectrum-web-components/theme/scale-medium.js');
break;
case 'large-spectrum':
import('@spectrum-web-components/theme/scale-large.js');
break;
case 'darkest-express':
import('@spectrum-web-components/theme/express/theme-darkest.js');
break;
case 'dark-express':
case 'dark-express' || 'darkest-express':
import('@spectrum-web-components/theme/express/theme-dark.js');
break;
case 'light-express':
case 'light-express' || 'lightest-express':
import('@spectrum-web-components/theme/express/theme-light.js');
break;
case 'lightest-express':
import('@spectrum-web-components/theme/express/theme-lightest.js');
break;
case 'medium-express':
import('@spectrum-web-components/theme/express/scale-medium.js');
break;
case 'large-express':
import('@spectrum-web-components/theme/express/scale-large.js');
break;
case 'light-spectrum-two':
import(
'@spectrum-web-components/theme/spectrum-two/theme-light-core-tokens.js'
);
break;
case 'dark-spectrum-two':
import(
'@spectrum-web-components/theme/spectrum-two/theme-dark-core-tokens.js'
);
break;
case 'medium-spectrum-two':
import(
'@spectrum-web-components/theme/spectrum-two/scale-medium-core-tokens.js'
);
break;
case 'large-spectrum-two':
import(
'@spectrum-web-components/theme/spectrum-two/scale-large-core-tokens.js'
);
break;
}
};

Expand Down Expand Up @@ -346,6 +354,9 @@ export class LayoutElement extends LitElement {
>
<sp-menu-item value="spectrum">Spectrum</sp-menu-item>
<sp-menu-item value="express">Express</sp-menu-item>
<sp-menu-item value="spectrum-two">
Spectrum 2
</sp-menu-item>
</sp-picker>
</div>
<div class="theme-control">
Expand All @@ -356,10 +367,8 @@ export class LayoutElement extends LitElement {
value=${this.color}
@change=${this.updateColor}
>
<sp-menu-item value="lightest">Lightest</sp-menu-item>
<sp-menu-item value="light">Light</sp-menu-item>
<sp-menu-item value="dark">Dark</sp-menu-item>
<sp-menu-item value="darkest">Darkest</sp-menu-item>
</sp-picker>
</div>
<div class="theme-control">
Expand Down Expand Up @@ -483,17 +492,11 @@ export class LayoutElement extends LitElement {
...this.querySelectorAll('code-example'),
] as CodeExample[];
examples.forEach((example) => {
example.codeTheme =
this.color === 'dark' || this.color === 'darkest'
? 'dark'
: 'light';
example.codeTheme = this.color;
});
(
document.querySelector('html') as HTMLHtmlElement
).style.colorScheme =
this.color === 'dark' || this.color === 'darkest'
? 'dark'
: 'light';
).style.colorScheme = this.color;
}
if (changes.has('scale')) {
if (window.localStorage) {
Expand Down
6 changes: 3 additions & 3 deletions projects/story-decorator/src/StoryDecorator.ts
Expand Up @@ -25,6 +25,7 @@ import {
import { DARK_MODE } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
import '@spectrum-web-components/theme/sp-theme.js';
import '@spectrum-web-components/theme/src/themes.js';
import '@spectrum-web-components/theme/src/spectrum-two/themes-core-tokens.js';
import '@spectrum-web-components/theme/src/express/themes.js';
import '@spectrum-web-components/field-label/sp-field-label.js';
import '@spectrum-web-components/picker/sp-picker.js';
Expand Down Expand Up @@ -317,8 +318,9 @@ export class StoryDecorator extends SpectrumElement {
.value=${this.system}
@change=${this.updateTheme}
>
<sp-menu-item value="spectrum">Classic</sp-menu-item>
<sp-menu-item value="spectrum">Spectrum</sp-menu-item>
<sp-menu-item value="express">Express</sp-menu-item>
<sp-menu-item value="spectrum-two">Spectrum 2</sp-menu-item>
</sp-picker>
`;
}
Expand All @@ -335,10 +337,8 @@ export class StoryDecorator extends SpectrumElement {
.value=${this.color}
@change=${this.updateTheme}
>
<sp-menu-item value="lightest">Lightest</sp-menu-item>
<sp-menu-item value="light">Light</sp-menu-item>
<sp-menu-item value="dark">Dark</sp-menu-item>
<sp-menu-item value="darkest">Darkest</sp-menu-item>
</sp-picker>
`;
}
Expand Down
2 changes: 1 addition & 1 deletion projects/vrt-quick-link/404.html
Expand Up @@ -233,7 +233,7 @@
return temp.toLowerCase();
};
const { pathname, search } = window.location;
const flavor = search ? search.slice(1) : 'classic';
const flavor = search ? search.slice(1) : 'spectrum';
const destColor = 'light';
const destScale = 'medium';
const destDir = 'ltr';
Expand Down
109 changes: 65 additions & 44 deletions scripts/spectrum-tokens.js → scripts/generate-tokens-wrapper.js
Expand Up @@ -9,25 +9,26 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

import fg from 'fast-glob';
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const tokensRoot = path.join(
__dirname,
'..',
'node_modules',
'@spectrum-css',
'tokens',
'dist',
'css',
'**',
'*.css'
);
const tokensRoot = (tokensDir) => {
return path.join(
__dirname,
'..',
'node_modules',
'@spectrum-css',
tokensDir,
'dist',
'css',
'**',
'*.css'
);
};

/** @todo Could generate this from CSS packages that have @spectrum-css/tokens as a dependency */
const tokenPackages = [
Expand Down Expand Up @@ -123,55 +124,66 @@ const removeImporantComments = (css) => {
return css.replaceAll(importantCommentRegExp, '');
};

const processTokens = (srcPath) => {
const processTokens = (srcPath, tokensDir) => {
let css = fs.readFileSync(srcPath, 'utf8');
const fileName = srcPath.split(path.sep + 'css' + path.sep).at(-1);
css = removeImporantComments(targetHost(css));

// s2 doesn't need express tokens
if (tokensDir === 'tokens-v2' && fileName.startsWith('express')) {
return;
}

fs.writeFileSync(
path.join(__dirname, '..', 'tools', 'styles', 'tokens', fileName),
path.join(__dirname, '..', 'tools', 'styles', tokensDir, fileName),
css
);
};

const processPackages = async (srcPath, index) => {
const processPackages = async (srcPath, tokensDir, index) => {
const packageName = tokenPackages[index];
const expressPath = path.join(srcPath, 'express.css');
const spectrumPath = path.join(srcPath, 'spectrum.css');

// check if expressPath exists
if (fs.existsSync(expressPath)) {
let express = fs.readFileSync(expressPath, 'utf8');
express = removeImporantComments(targetHost(express));
// check if spectrumPath exists
if (fs.existsSync(spectrumPath)) {
let spectrum = fs.readFileSync(spectrumPath, 'utf8');
spectrum = removeImporantComments(targetHost(spectrum));
fs.appendFileSync(
path.join(
__dirname,
'..',
'tools',
'styles',
'tokens',
'express',
tokensDir,
'spectrum',
'global-vars.css'
),
express
spectrum
);
}

// check if spectrumPath exists
if (fs.existsSync(spectrumPath)) {
let spectrum = fs.readFileSync(spectrumPath, 'utf8');
spectrum = removeImporantComments(targetHost(spectrum));
// spectrum-2 doesn't need express package tokens
if (tokensDir === 'tokens-v2') {
return;
}

const expressPath = path.join(srcPath, 'express.css');

// check if expressPath exists
if (fs.existsSync(expressPath)) {
Rajdeepc marked this conversation as resolved.
Show resolved Hide resolved
let express = fs.readFileSync(expressPath, 'utf8');
express = removeImporantComments(targetHost(express));
fs.appendFileSync(
path.join(
__dirname,
'..',
'tools',
'styles',
'tokens',
'spectrum',
tokensDir,
'express',
'global-vars.css'
),
spectrum
express
);
}

Expand Down Expand Up @@ -199,24 +211,33 @@ const processPackages = async (srcPath, index) => {
}
};

const spectrumTokens = async () => {
/**
* Core entry function
*/
export async function generateTokensWrapper(spectrumVersion) {
const tokensDir = spectrumVersion === 'spectrum' ? 'tokens' : 'tokens-v2';
fs.mkdirSync(
path.join(__dirname, '..', 'tools', 'styles', 'tokens', 'spectrum'),
path.join(__dirname, '..', 'tools', 'styles', tokensDir, 'spectrum'),
{
recursive: true,
}
);
fs.mkdirSync(
path.join(__dirname, '..', 'tools', 'styles', 'tokens', 'express'),
{
recursive: true,
}
);
for (const tokensPath of await fg([`${tokensRoot}`])) {
processTokens(tokensPath);

if (spectrumVersion === 'spectrum') {
fs.mkdirSync(
path.join(__dirname, '..', 'tools', 'styles', tokensDir, 'express'),
{
recursive: true,
}
);
}

for (const tokensPath of await fg([`${tokensRoot(tokensDir)}`])) {
processTokens(tokensPath, tokensDir);
}
const processes = packagePaths.map(processPackages);
await Promise.all(processes);
};

spectrumTokens();
const processes = packagePaths.map((path, index) => {
return processPackages(path, tokensDir, index);
});
await Promise.all(processes);
}
19 changes: 19 additions & 0 deletions scripts/generate-tokens.js
@@ -0,0 +1,19 @@
#!/usr/bin/env node

/*
Copyright 2022 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

import { generateTokensWrapper } from './generate-tokens-wrapper.js';

(async () => {
await generateTokensWrapper('spectrum');
await generateTokensWrapper('spectrum-two');
})();