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

feat: registers sd-transforms; includes refs in source-tokens-only output; resolves refs warnings #3219

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion lib/build-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const minimist = require('minimist');
const {
initializeStyleDictionary,
getTokensStudioTransforms,
colorTransform,
} = require('../tokens/style-dictionary');
const { createIndexCssFile } = require('../tokens/utils');
Expand Down Expand Up @@ -56,9 +57,14 @@ async function buildTokensCommand(commandArgs) {
source: tokensSource
? [`${tokensSource}/core/**/*.json`, `${tokensSource}/core/**/*.toml`]
: [],
preprocessors: ['pgn-annotate-token-extensions-with-references', 'tokens-studio'],
Copy link
Member Author

Choose a reason for hiding this comment

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

[inform] See docs on preprocessors. pgn-annotate-tokens-with-references is custom.

See sd-transforms README for more information on the tokens-studio preprocessor.

expand: {
typesMap: (await getTokensStudioTransforms()).expandTypesMap,
Copy link
Member Author

Choose a reason for hiding this comment

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

[inform] See sd-transforms README for more information on expandTypesMap for expand.

Copy link
Member Author

@adamstankiewicz adamstankiewicz Sep 8, 2024

Choose a reason for hiding this comment

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

Relates to #3222

},
platforms: {
css: {
prefix: 'pgn',
transformGroup: 'paragon-css',
// NOTE: buildPath must end with a slash
buildPath: buildDir.slice(-1) === '/' ? buildDir : `${buildDir}/`,
options: {
Expand All @@ -82,7 +88,6 @@ async function buildTokensCommand(commandArgs) {
},
},
],
transforms: StyleDictionary.hooks.transformGroups.css.filter(item => item !== 'size/rem').concat('color/sass-color-functions', 'str-replace'),
Copy link
Member Author

@adamstankiewicz adamstankiewicz Sep 7, 2024

Choose a reason for hiding this comment

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

[inform] abstracted into transformGroup: 'paragon-css', although the default CSS transform size/rem is now included, instead of filtered like here.

It seems the primary reason it was filtered out was due to tokens that defined a number while having a $type: "dimension" instead of $type: "number". Ensuring the number type keeps the number value with appending rem as expected, e.g.

--pgn-spacing-card-columns-count: 3;

},
},
log: {
Expand Down
64 changes: 64 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@
"playroom:build": "npm run playroom:build --workspace=www",
"prepare": "husky || true",
"build-tokens": "./bin/paragon-scripts.js build-tokens --build-dir ./styles/css",
"build-tokens:watch": "npx nodemon --ignore styles/css -x \"npm run build-tokens\"",
"replace-variables-usage-with-css": "./bin/paragon-scripts.js replace-variables -p src -t usage",
"replace-variables-definition-with-css": "./bin/paragon-scripts.js replace-variables -p src -t definition",
"cli:help": "./bin/paragon-scripts.js help"
},
"dependencies": {
"@popperjs/core": "^2.11.4",
"@tokens-studio/sd-transforms": "^1.2.4",
"axios": "^0.27.2",
"bootstrap": "^4.6.2",
"chalk": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion styles/css/core/custom-media-breakpoints.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* See <root>/tokens/README.md for more details.
*/

@custom-media --pgn-size-breakpoint-min-width-xs (min-width: 0);
@custom-media --pgn-size-breakpoint-min-width-xs (min-width: 0px);
@custom-media --pgn-size-breakpoint-max-width-xs (max-width: 576px);
@custom-media --pgn-size-breakpoint-min-width-sm (min-width: 576px);
@custom-media --pgn-size-breakpoint-max-width-sm (max-width: 768px);
Expand Down
Loading
Loading