Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1ccd632
feat(typography): init 2nd-gen typography stylesheet generation
5t3ph Feb 9, 2026
256b15e
feat(typography): adjust CJK font-size, margin multipliers, color, mo…
5t3ph Feb 9, 2026
38bf4be
feat(*): update token related scripts, imports, README
5t3ph Feb 9, 2026
cfdedb7
feat(typography): init stories, preview styles
5t3ph Feb 10, 2026
380f0ce
feat(typography): resolve sizes, improve custom properties, update ex…
5t3ph Feb 11, 2026
6c75822
feat(typography): improve stories
5t3ph Feb 11, 2026
b29b845
feat(typography): improve maintainability, prose semantic element styles
5t3ph Feb 11, 2026
e666289
feat(typography): add title variant
5t3ph Feb 12, 2026
cd5561c
feat(typography): prevent size change for CJK code
5t3ph Feb 12, 2026
299baa9
feat(typography): script cleanup
5t3ph Feb 12, 2026
0344544
feat(typography): adjust heading styles, improve stories
5t3ph Feb 17, 2026
3860946
Merge branch 'main' of https://github.com/adobe/spectrum-web-componen…
5t3ph Feb 17, 2026
df2fb59
chore(swc-tokens): update README
5t3ph Feb 17, 2026
9324b82
fix(typography): stylelint-ignore generated file
5t3ph Feb 17, 2026
b29db7c
fix(*): address linting
5t3ph Feb 17, 2026
ec488c5
fix(*): lint order
5t3ph Feb 18, 2026
95c1e77
fix(*): prettier
5t3ph Feb 18, 2026
14d340e
fix(*): prettier
5t3ph Feb 18, 2026
a972f9d
feat(typography): story bg, heavy story, move logs to debug flag
5t3ph Feb 20, 2026
98fc0bf
feat(storybook): hide Getting Started based on `utility` tag
5t3ph Feb 20, 2026
a19d44c
feat(typography): add missing heading XS, update swc-tokens README
5t3ph Feb 23, 2026
255c3c9
Merge branch 'main' of https://github.com/adobe/spectrum-web-componen…
5t3ph Feb 23, 2026
3745c33
fix(typography): lint format
5t3ph Feb 23, 2026
1d8f305
fix(tokens): revert back to stylesheets dir
5t3ph Feb 23, 2026
b47680f
fix(*): revert eslint comment removal
5t3ph Feb 23, 2026
fabee5c
feat(tokens): integrate and expose `renamed` token data
5t3ph Feb 23, 2026
0e260f1
Merge branch 'main' of https://github.com/adobe/spectrum-web-componen…
5t3ph Feb 23, 2026
6ce6219
fix(typography): use double quotes
5t3ph Feb 23, 2026
9ade16e
feat(tokens): extension perf/match improvements
5t3ph Feb 24, 2026
e320c03
Merge branch 'main' of https://github.com/adobe/spectrum-web-componen…
5t3ph Feb 24, 2026
d358726
fix(tokens): fix README merge conflict
5t3ph Feb 24, 2026
c8ddfd0
feat(tokens): exclude /tools/ from token diagnostics
5t3ph Feb 24, 2026
cdb90ad
fix(typography): reformat stylesheet
5t3ph Feb 24, 2026
ca42add
fix(typography): add missing `token` to string
5t3ph Feb 24, 2026
ffcdb67
fix(picker): flaky test
Feb 25, 2026
69be0dd
chore(docs): update customization > getting started
5t3ph Feb 25, 2026
7d8632e
Merge branch 'main' into rajdeep/fix-picker-test
Rajdeepc Feb 26, 2026
553f1ee
Merge branch 'rajdeep/fix-picker-test' into seckles/tokens-expose-ren…
Feb 26, 2026
da62e2a
fix(tokens): reuse data, not re-compute
5t3ph Feb 27, 2026
59837bc
feat(tokens): add onDidClose to clear out sessions
5t3ph Feb 27, 2026
6b2ab17
feat(tokens): optimize paths and cleanup diagnostic cache
5t3ph Feb 27, 2026
8b2dca7
feat(tokens): update extension vsix
5t3ph Feb 27, 2026
1b136ae
Merge branch 'main' of https://github.com/adobe/spectrum-web-componen…
5t3ph Feb 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ To use 2nd-gen SWC in your application, you need two things:

## Include the stylesheet

{/* TODO: Help needed figuring out how to get this to export post-processing! Open to different name, ex. just `@adobe/spectrum-wc/tokens.css */}

The stylesheet is available via `@adobe/spectrum-wc/swc.css`.

Inclusion will be dependent on your application environment and build pipeline.
Expand All @@ -42,9 +40,11 @@ Please note that if you are re-processing the stylesheet through PostCSS and usi
```json
stage: 2,
features: {
'nesting-rules': true,
'nesting-rules': false,
'custom-properties': false,
'light-dark-function': false,
'logical-properties-and-values': false,
'is-pseudo-class': false,
'cascade-layers': false,
}
```
17 changes: 16 additions & 1 deletion 2nd-gen/packages/tools/swc-tokens/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@ flowchart TD

</details>

## Renamed/Deprecated Tokens

Deprecated tokens in the source data have an optional second parameter of `renamed` that when included points to the name of the replacement token.

The token JSON created from `--outputType data` is in the following shape:

```json
{
"tokens": { "...": "..." },
"renamed": { "old-token": "new-token" }
}
```

The `swc-vscode-token` package uses the `renamed` data for hover diagnostics and suggestions.

## Token Stylesheet Generation

The unified token stylesheet splits tokens into two groups:
Expand Down Expand Up @@ -265,7 +280,7 @@ This outputs the stylesheet into the noted `--out` directory and filename, with
Valid `--outputType` values include:

- `tokens` - token stylesheet
- `data` - token JSON
- `data` - token JSON, split into `tokens` and `renamed`
- `typography` - typography stylesheet

## Commands
Expand Down
4 changes: 2 additions & 2 deletions 2nd-gen/packages/tools/swc-tokens/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import prettier from 'prettier';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

import { allTokens, generateCSS } from './src/tokens.js';
import { allTokenData, generateCSS } from './src/tokens.js';
import { generateTypographyCssFile } from './src/typography.js';

const argv = yargs(hideBin(process.argv))
Expand Down Expand Up @@ -99,7 +99,7 @@ if (outputType === 'tokens') {
} else {
fs.writeFileSync(
out,
JSON.stringify(await allTokens(prefix, log), '', 4) + '\n',
JSON.stringify(await allTokenData(prefix, log), '', 4) + '\n',
'utf8'
);

Expand Down
2 changes: 1 addition & 1 deletion 2nd-gen/packages/tools/swc-tokens/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/swc-tokens",
"version": "0.0.1",
"version": "0.1.0",
"private": true,
"description": "Second generation Spectrum Web Components token processing",
"license": "Apache-2.0",
Expand Down
68 changes: 67 additions & 1 deletion 2nd-gen/packages/tools/swc-tokens/src/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,13 @@ function extractTokenValues(

for (const [name, token] of Object.entries(json)) {
if (token?.deprecated) {
log(`[DEPRECATED] token '${name}'`);
if (token?.renamed) {
log(
`[RENAMED] deprecated token '${name}' renamed to '${token.renamed}'`
);
} else {
log(`[DEPRECATED] token '${name}'`);
}
continue;
}

Expand Down Expand Up @@ -390,6 +396,20 @@ function extractTokenValues(
return out;
}

function extractRenamedTokenValues(json, debug = false) {
const out = {};
const log = typeof debug === 'function' ? debug : () => {};

for (const [name, token] of Object.entries(json)) {
if (token?.deprecated && typeof token?.renamed === 'string') {
out[name] = token.renamed;
log(`[RENAMED-MAP] '${name}' -> '${token.renamed}'`);
}
}

return out;
}

/* -----------------------------------------------------------------------------
* CSS Generation
* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -517,8 +537,44 @@ async function loadAllTokens(prefix, debug = false) {
);
}

async function loadAllTokenData(prefix, debug = false) {
const sources = [
...SPECTRUM_TOKENS.map((t) => ({ ...t, src: 'spectrum' })),
...CUSTOM_TOKENS.map((t) => ({ ...t, src: 'custom' })),
];

const rawFiles = await Promise.all(
sources.map(async (s) => ({
...s,
raw: await loadTokenJson(s.file, s.src),
}))
);

const globalLookup = Object.assign(
{},
...rawFiles.map((f) => buildRawLookup(f.raw))
);

return {
tokens: Object.assign(
{},
...rawFiles.map((f) =>
extractTokenValues(f.raw, f.resolveAliases, prefix, {
debug,
rawLookupOverride: globalLookup,
})
)
),
renamed: Object.assign(
{},
...rawFiles.map((f) => extractRenamedTokenValues(f.raw, debug))
),
};
}

// Cache for loaded tokens (keyed by prefix)
const tokenCache = new Map();
const tokenDataCache = new Map();

// Returns combined total token JSON (cached)
export const allTokens = (prefix, debug = false) => {
Expand All @@ -529,6 +585,15 @@ export const allTokens = (prefix, debug = false) => {
return tokenCache.get(cacheKey);
};

// Returns combined token + renamed metadata JSON (cached)
export const allTokenData = (prefix, debug = false) => {
const cacheKey = `${prefix ?? ''}:${debug}`;
if (!tokenDataCache.has(cacheKey)) {
tokenDataCache.set(cacheKey, loadAllTokenData(prefix, debug));
}
return tokenDataCache.get(cacheKey);
};

// Lookup individual token values for use in component styles
export async function lookupToken(key, prefix) {
const tokens = await allTokens(prefix);
Expand All @@ -553,5 +618,6 @@ export const __test__ = {
normalizePrimitive,
normalizeSetGroup,
extractTokenValues,
extractRenamedTokenValues,
lookupToken,
};
20 changes: 10 additions & 10 deletions 2nd-gen/packages/tools/swc-tokens/src/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ function getPatchedTokenName(typeVar, suffix, mode) {
}

function tokenRefFromName(name) {
return name ? `token('${name}')` : null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just updating to double-quotes

return name ? `token("${name}")` : null;
}

function tokenExists(tokens, name) {
return Boolean(tokens?.[name]);
}

function tokenRefIfExists(tokens, name) {
return tokenExists(tokens, name) ? `token('${name}')` : null;
return tokenExists(tokens, name) ? `token("${name}")` : null;
}

function warnMissing(typeVar, what, name, debug) {
Expand All @@ -175,7 +175,7 @@ function warnMissing(typeVar, what, name, debug) {
}

/**
* Get a token('...') reference by name and warn if missing.
* Get a token("...") reference by name and warn if missing.
* Use for non-variant tokens (e.g. derived line-height-*, cjk-line-height-*, etc.)
*/
function tokenRefOrWarn(tokens, typeVar, what, tokenName, debug) {
Expand Down Expand Up @@ -498,7 +498,7 @@ export async function generateTypographyCssString(options = {}) {

// Separate :lang() rule once for font-family only
out += `${langSelectorList({
'font-family': `token('${fontTokens.cjk}')`,
'font-family': `token("${fontTokens.cjk}")`,
})}\n`;

for (const typeVar of variants) {
Expand Down Expand Up @@ -612,10 +612,10 @@ export async function generateTypographyCssString(options = {}) {
}),
pickValidDecls({
color: `var(--${cpBase}-font-color, ${colorRef})`,
'font-family': `var(--${cpBase}-font-family, token('${defaultFont}'))`,
'font-family': `var(--${cpBase}-font-family, token("${defaultFont}"))`,
'font-weight': sansWeightRef
? `var(--${cpBase}-font-weight, ${sansWeightRef})`
: `var(--${cpBase}-font-weight, token('regular-font-weight'))`,
: `var(--${cpBase}-font-weight, token("regular-font-weight"))`,
'font-size': mSizeRef
? `var(--${cpBase}-font-size, ${mSizeRef})`
: null,
Expand Down Expand Up @@ -741,16 +741,16 @@ export async function generateTypographyCssString(options = {}) {
// Serif modifier (cascade order wins; no compounding)
if (tokens[serifWeightTokenName]?.value) {
out += cssBlock(`.${className}--serif`, {
[`--${cpBase}-font-family`]: `token('${fontTokens.serif}')`,
[`--${cpBase}-font-weight`]: `token('${serifWeightTokenName}')`,
[`--${cpBase}-font-family`]: `token("${fontTokens.serif}")`,
[`--${cpBase}-font-weight`]: `token("${serifWeightTokenName}")`,
});
out += '\n';
}

// Heavy modifier (optional)
if (tokens[sansHeavyWeightTokenName]?.value) {
out += cssBlock(`.${className}--heavy`, {
[`--${cpBase}-font-weight`]: `token('${sansHeavyWeightTokenName}')`,
[`--${cpBase}-font-weight`]: `token("${sansHeavyWeightTokenName}")`,
});
out += '\n';
}
Expand All @@ -762,7 +762,7 @@ export async function generateTypographyCssString(options = {}) {
out += `/* =========================\n Modifiers\n ========================= */\n`;

out += `.${prefix}-Typography--emphasized:not(${CJK_NOT_LIST}) {
font-style: token('italic-font-style');
font-style: token("italic-font-style");
}\n`;

return out;
Expand Down
26 changes: 26 additions & 0 deletions 2nd-gen/packages/tools/swc-tokens/tests/tokenExtraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,32 @@ describe('extractTokenValues', () => {
});
});

describe('extractRenamedTokenValues', () => {
const { extractRenamedTokenValues } = __test__;

it('collects renamed mapping for deprecated tokens only', () => {
const json = {
oldToken: {
deprecated: true,
renamed: 'new-token',
value: '1rem',
},
notDeprecated: {
renamed: 'ignored',
value: '2rem',
},
deprecatedWithoutRename: {
deprecated: true,
value: '3rem',
},
};

expect(extractRenamedTokenValues(json)).toEqual({
oldToken: 'new-token',
});
});
});

describe('buildRawLookup', () => {
const { buildRawLookup } = __test__;

Expand Down
6 changes: 4 additions & 2 deletions 2nd-gen/packages/tools/swc-vscode-token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ VS Code extension providing autocomplete and diagnostics for `token('...')` valu
- Partial, case‑insensitive autocomplete for `token('...')`
- Quote balancing and automatic trimming of trailing whitespace
- Completions resume after editing inside an existing token
- Hover message for unknown tokens with suggestions
- Deprecated token detection with "renamed to..." diagnostics
- Hover guidance that shows replacement tokens
- Improved unknown-token suggestions that can include renamed-token candidates
- Diagnostic messages as displayed on hover and in "Problems"

### Supported file types/languages
Expand Down Expand Up @@ -63,7 +65,7 @@ Deploy to build and package updated VSIX file required for VSCode to load the ex
yarn deploy
```

Post-build, will require uninstalling and re-installing the extension to see changes take affect.
Post-build, will require uninstalling and re-installing the extension to see changes take effect.

### Updating extension logic

Expand Down
2 changes: 1 addition & 1 deletion 2nd-gen/packages/tools/swc-vscode-token/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"displayName": "SWC token() Intellisense",
"engines": {
"vscode": "1.1.37"
"vscode": "^1.109.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were compat issues with a locked version, but this is entirely separate from our library since it is exclusive to the extension

},
"homepage": "https://opensource.adobe.com/spectrum-web-components/",
"icon": "resources/icon.png",
Expand Down
Loading
Loading