-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING: use preprocessors if the passed SD is prerelease.2 or higher
- Loading branch information
1 parent
fd9710a
commit e879b66
Showing
11 changed files
with
134 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@tokens-studio/sd-transforms': minor | ||
--- | ||
|
||
Will now use preprocessors instead of parsers when user Style-Dictionary is v4.0.0-prerelease.2 or higher. Fixes an issue with multi-file references not being resolvable when running composite token expansion or add font style utilities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type StyleDictionary from 'style-dictionary'; | ||
import { expect } from '@esm-bundle/chai'; | ||
import { promises } from 'fs'; | ||
import path from 'path'; | ||
import { cleanup, init } from './utils.js'; | ||
|
||
const outputDir = 'test/integration/tokens/'; | ||
const outputFileName = 'vars.css'; | ||
const outputFilePath = path.resolve(outputDir, outputFileName); | ||
|
||
const cfg = { | ||
source: ['test/integration/tokens/cross-file-refs-*.tokens.json'], | ||
platforms: { | ||
css: { | ||
transformGroup: 'tokens-studio', | ||
prefix: 'sd', | ||
buildPath: outputDir, | ||
files: [ | ||
{ | ||
destination: outputFileName, | ||
format: 'css/variables', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
let dict: StyleDictionary | undefined; | ||
|
||
describe('cross file references', () => { | ||
beforeEach(async () => { | ||
cleanup(dict); | ||
dict = await init(cfg, { expand: { typography: true } }); | ||
}); | ||
|
||
afterEach(async () => { | ||
await cleanup(dict); | ||
}); | ||
|
||
it('supports cross file references e.g. expanding typography', async () => { | ||
const file = await promises.readFile(outputFilePath, 'utf-8'); | ||
console.log(file); | ||
expect(file).to.include(` | ||
--sdTypoFontWeight: 400; | ||
--sdTypoFontStyle: italic; | ||
--sdWeight: 400 italic; | ||
--sdTypoAliasFontWeight: 400; | ||
--sdTypoAliasFontStyle: italic; | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"typo": { | ||
"value": { | ||
"fontWeight": "{weight}" | ||
}, | ||
"type": "typography" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"weight": { | ||
"value": "Regular italic", | ||
"type": "fontWeights" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"typo-alias": { | ||
"value": "{typo}", | ||
"type": "typography" | ||
} | ||
} |