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

Add duration transformer to build flow #751

Merged
merged 1 commit into from
Oct 5, 2023
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
29 changes: 29 additions & 0 deletions scripts/buildTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,29 @@ export const buildDesignTokens = (buildOptions: ConfigGeneratorOptions): void =>
getStyleDictionaryConfig(`base/typography/typography`, [`src/tokens/base/typography/*.json`], [], buildOptions),
).buildAllPlatforms()

/** -----------------------------------
* Motion tokens
* ----------------------------------- */
PrimerStyleDictionary.extend(
getStyleDictionaryConfig(
`functional/motion/motion`,
[`src/tokens/functional/motion/*.json5`],
[`src/tokens/base/motion/*.json5`],
buildOptions,
{
css: css(`css/functional/motion/motion.css`, buildOptions.prefix, buildOptions.buildPath, {
options: {
outputReferences: true,
},
}),
},
),
).buildAllPlatforms()

PrimerStyleDictionary.extend(
getStyleDictionaryConfig(`base/motion/motion`, [`src/tokens/base/motion/*.json5`], [], buildOptions),
).buildAllPlatforms()

/** -----------------------------------
* deprecated tokens
* ----------------------------------- */
Expand Down Expand Up @@ -139,6 +162,12 @@ export const buildDesignTokens = (buildOptions: ConfigGeneratorOptions): void =>
source: [`src/tokens/base/size/*.json`, `src/tokens/functional/size/*.json`],
include: [`src/tokens/base/size/*.json`],
},
// motion
{
filename: 'motion',
source: [`src/tokens/base/motion/*.json5`, `src/tokens/functional/motion/*.json5`],
include: [`src/tokens/base/motion/*.json5`],
},
]
//
for (const {filename, source, include} of deprecatedBuilds) {
Expand Down
1 change: 1 addition & 0 deletions src/platforms/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const css: PlatformInitializer = (outputFile, prefix, buildPath, options)
'color/hexAlpha',
'color/hexMix',
'dimension/rem',
'duration/css',
'shadow/css',
'border/css',
'typography/css',
Expand Down
1 change: 1 addition & 0 deletions src/platforms/scss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const scss: PlatformInitializer = (outputFile, prefix, buildPath): StyleD
'color/hexMix',
'color/hexAlpha',
'dimension/rem',
'duration/css',
'shadow/css',
'border/css',
'typography/css',
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/durationToCss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type StyleDictionary from 'style-dictionary'
export const durationToCss: StyleDictionary.Transform = {
type: `value`,
transitive: true,
matcher: (token: StyleDictionary.TransformedToken) => token.type === `duration`,
matcher: (token: StyleDictionary.TransformedToken) => token.$type === `duration`,
transformer: (token: StyleDictionary.TransformedToken, _options?: StyleDictionary.Platform) => {
// throw an error if token value is not a string or does not end with `ms`
if (typeof token.value !== `string` || !token.value.endsWith(`ms`)) {
Expand Down
Loading