Skip to content

Commit 31019cb

Browse files
feat: --output-references CLI arg for build-tokens, registers filters, and updates CSS vars format
* Exposes `--output-references` CLI argument for `build-tokens` command. Defaults to `true`. Ensures brand package output with the CLI includes references in build output out-of-the-box. * Registers filter(s) `isThemeVariant{"Light"}`, handling future theme variants when implemented (e.g., `isThemeVariantDark`). * Migrates `createCustomCSSVariables` to use `formattedVariables` to rely on out-of-the-box CSS variable formatting. The formatter still supports token-specific overrides of `outputReferences`. If a token has modifications via `modify`, the modified base reference is not included in the output. * Relies on `style-dictionary`'s default `fileHeader`, with opt-in timestamp. * Fixes bug with line-height tokens, switching their `$type` from `dimension` to `number` to resolve typography style regressions. * Updates typography tokens related to font size for more consistent naming structure. * Ensures the "Typography" foundations page properly previews the correct font size for regular "Body" text and includes the missing "HEADING LABEL" example. * Updates to "Colors" page in docs site * Displays token name instead of CSS variable in the color swatch previews (see screenshot below). * Include `accent-a` and `accent-b` alongside other color names, rather than manually rendering `Swatch` for the accents. * Modifies the grid styles for color swatch preview to be more responsive. * Resolves `NaNpx` bug in `MeasuredItem` component on docs site, while computing the measurements to display for an element (e.g., font size). Instead, it renders an empty block while measurements are resolved. * Updates `CodeBlock` styles on docs site to add its border and background color only to the `LivePreview`, not the entire `CodeBlock` example. * Reduces whitespace on docs site homepage. * Simplifies columns on docs site header, ensuring `SiteTitle` is horizontally aligned in the center.
1 parent 0e1ef04 commit 31019cb

Some content is hidden

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

44 files changed

+664
-1167
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.PHONY: build
12
build:
23
rm -rf ./dist
34
tsc --project tsconfig.build.json

bin/paragon-scripts.js

+10
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,21 @@ const COMMANDS = {
8585
description: 'Include only source design tokens in the build.',
8686
defaultValue: false,
8787
},
88+
{
89+
name: '--output-references',
90+
description: 'Include references in the build output.',
91+
defaultValue: true,
92+
},
8893
{
8994
name: '-t, --themes',
9095
description: 'Specify themes to include in the token build.',
9196
defaultValue: 'light',
9297
},
98+
{
99+
name: '-v, --verbose',
100+
description: 'Enable verbose logging.',
101+
defaultValue: false,
102+
},
93103
],
94104
},
95105
'replace-variables': {

lib/build-tokens.js

+38-11
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,37 @@ const { createIndexCssFile } = require('../tokens/utils');
1313
* @param {string|string[]} [commandArgs.themes=['light']] - The themes (variants) for which to build tokens.
1414
*/
1515
async function buildTokensCommand(commandArgs) {
16-
const StyleDictionary = await initializeStyleDictionary();
17-
1816
const defaultParams = {
1917
themes: ['light'],
2018
'build-dir': './build/',
19+
'source-tokens-only': false,
20+
'output-references': true,
21+
verbose: false,
2122
};
2223

2324
const alias = {
2425
'build-dir': 'b',
2526
themes: 't',
27+
verbose: '-v',
2628
};
2729

2830
const {
2931
'build-dir': buildDir,
3032
source: tokensSource,
3133
'source-tokens-only': hasSourceTokensOnly,
34+
'output-references': outputReferences,
3235
themes,
33-
} = minimist(commandArgs, { alias, default: defaultParams, boolean: 'source-tokens-only' });
36+
verbose,
37+
} = minimist(
38+
commandArgs,
39+
{
40+
alias,
41+
default: defaultParams,
42+
boolean: ['source-tokens-only', 'output-references', 'verbose'],
43+
},
44+
);
45+
46+
const StyleDictionary = await initializeStyleDictionary({ themes });
3447

3548
const coreConfig = {
3649
include: [
@@ -52,24 +65,30 @@ async function buildTokensCommand(commandArgs) {
5265
destination: 'core/variables.css',
5366
filter: hasSourceTokensOnly ? 'isSource' : undefined,
5467
options: {
55-
outputReferences: !hasSourceTokensOnly,
68+
outputReferences,
69+
formatting: {
70+
fileHeaderTimestamp: true,
71+
},
5672
},
5773
},
5874
{
5975
format: 'css/custom-media-breakpoints',
6076
destination: 'core/custom-media-breakpoints.css',
6177
filter: hasSourceTokensOnly ? 'isSource' : undefined,
6278
options: {
63-
outputReferences: !hasSourceTokensOnly,
79+
outputReferences,
80+
formatting: {
81+
fileHeaderTimestamp: true,
82+
},
6483
},
6584
},
6685
],
6786
transforms: StyleDictionary.hooks.transformGroups.css.filter(item => item !== 'size/rem').concat('color/sass-color-functions', 'str-replace'),
68-
options: {
69-
fileHeader: 'customFileHeader',
70-
},
7187
},
7288
},
89+
log: {
90+
verbosity: verbose ? 'verbose' : 'default',
91+
},
7392
};
7493

7594
const getStyleDictionaryConfig = (themeVariant) => ({
@@ -104,17 +123,25 @@ async function buildTokensCommand(commandArgs) {
104123
{
105124
format: 'css/custom-variables',
106125
destination: `themes/${themeVariant}/variables.css`,
107-
filter: hasSourceTokensOnly ? 'isSource' : undefined,
126+
filter: hasSourceTokensOnly
127+
? `isThemeVariant${themeVariant.charAt(0).toUpperCase()}${themeVariant.slice(1)}SourceOnly`
128+
: `isThemeVariant${themeVariant.charAt(0).toUpperCase()}${themeVariant.slice(1)}`,
108129
options: {
109-
outputReferences: !hasSourceTokensOnly,
130+
outputReferences,
131+
formatting: {
132+
fileHeaderTimestamp: true,
133+
},
110134
},
111135
},
112136
{
113137
format: 'css/utility-classes',
114138
destination: `themes/${themeVariant}/utility-classes.css`,
115139
filter: hasSourceTokensOnly ? 'isSource' : undefined,
116140
options: {
117-
outputReferences: !hasSourceTokensOnly,
141+
outputReferences,
142+
formatting: {
143+
fileHeaderTimestamp: true,
144+
},
118145
},
119146
},
120147
],

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"prepare": "husky || true",
5353
"build-tokens": "./bin/paragon-scripts.js build-tokens --build-dir ./styles/css",
5454
"replace-variables-usage-with-css": "./bin/paragon-scripts.js replace-variables -p src -t usage",
55-
"replace-variables-definition-with-css": "./bin/paragon-scripts.js replace-variables -p src -t definition"
55+
"replace-variables-definition-with-css": "./bin/paragon-scripts.js replace-variables -p src -t definition",
56+
"cli:help": "./bin/paragon-scripts.js help"
5657
},
5758
"dependencies": {
5859
"@popperjs/core": "^2.11.4",

src/Form/_FormText.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.pgn__form-text {
2-
font-size: var(--pgn-typography-font-size-small-base);
2+
font-size: var(--pgn-typography-font-size-sm);
33
display: flex;
44
align-items: center;
55

src/PageBanner/index.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
min-height: 36px;
55
display: flex;
66
flex-wrap: nowrap;
7-
font-size: var(--pgn-typography-font-size-small-x);
7+
font-size: var(--pgn-typography-font-size-xs);
88
background-color: var(--pgn-page-baner-bg, inherit);
99
color: var(--pgn-page-baner-color, inherit);
1010

1111
@include media-breakpoint-up(md) {
12-
font-size: var(--pgn-typography-font-size-small-base);
12+
font-size: var(--pgn-typography-font-size-sm);
1313
}
1414
}
1515

src/ProgressBar/index.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@
8787
.pgn__progress-hint {
8888
box-sizing: border-box;
8989
padding: 0 var(--pgn-spacing-progress-bar-hint-annotation-gap);
90-
font-size: var(--pgn-typography-font-size-small-base);
90+
font-size: var(--pgn-typography-font-size-sm);
9191
}
9292
}

src/Stepper/index.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
}
5757

5858
.pgn__stepper-header-step-description {
59-
font-size: var(--pgn-typography-font-size-small-x);
59+
font-size: var(--pgn-typography-font-size-xs);
6060
}
6161

6262
&.pgn__stepper-header-step-active ~ .pgn__stepper-header-step {

src/Toast/index.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
padding: 0;
3232

3333
p {
34-
font-size: var(--pgn-typography-font-size-small-base);
34+
font-size: var(--pgn-typography-font-size-sm);
3535
margin: 0;
3636
padding-right: .75rem;
3737
}

styles/css/core/custom-media-breakpoints.css

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/*
2-
* IMPORTANT: This file is the result of assembling design tokens.
3-
* Do not edit directly.
4-
* Generated on Tue, 27 Aug 2024 17:14:44 GMT
1+
/**
2+
* Do not edit directly, this file was auto-generated.
3+
* Generated on Sun, 01 Sep 2024 17:41:21 GMT
54
*/
65

76
@custom-media --pgn-size-breakpoint-min-width-xs (min-width: 0rem);

0 commit comments

Comments
 (0)