-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: references inside color modifiers (#252)
* chore: failing test for color modifier references * fix: references inside color modifiers
- Loading branch information
1 parent
173e7fd
commit 8bde22d
Showing
17 changed files
with
152 additions
and
24 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': patch | ||
--- | ||
|
||
Support references in color modifiers now that style-dictionary transformers can defer themselves. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import type StyleDictionary from 'style-dictionary'; | ||
import { expect } from '@esm-bundle/chai'; | ||
import { promises } from 'node:fs'; | ||
import path from 'node: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/color-modifier-references.tokens.json'], | ||
platforms: { | ||
css: { | ||
transformGroup: 'tokens-studio', | ||
prefix: 'sd', | ||
buildPath: outputDir, | ||
files: [ | ||
{ | ||
destination: outputFileName, | ||
format: 'css/variables', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
let dict: StyleDictionary | undefined; | ||
|
||
describe('typography references', () => { | ||
beforeEach(async () => { | ||
if (dict) { | ||
cleanup(dict); | ||
} | ||
dict = await init(cfg); | ||
}); | ||
|
||
afterEach(async () => { | ||
if (dict) { | ||
await cleanup(dict); | ||
} | ||
}); | ||
|
||
it('supports references inside color modifiers', async () => { | ||
const file = await promises.readFile(outputFilePath, 'utf-8'); | ||
expect(file).to.include( | ||
`--sdAlpha: 0.3; | ||
--sdColor: #ffffff4d;`, | ||
); | ||
}); | ||
|
||
it('supports color modifier that is a reference itself, containing another reference', async () => { | ||
const file = await promises.readFile(outputFilePath, 'utf-8'); | ||
expect(file).to.include(`--sdColor2: #0000004d;`); | ||
}); | ||
}); |
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
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
37 changes: 37 additions & 0 deletions
37
test/integration/tokens/color-modifier-references.tokens.json
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,37 @@ | ||
{ | ||
"alpha": { | ||
"value": 0.3, | ||
"type": "other" | ||
}, | ||
"color": { | ||
"value": "#FFFFFF", | ||
"type": "color", | ||
"$extensions": { | ||
"studio.tokens": { | ||
"modify": { | ||
"type": "alpha", | ||
"value": "{alpha}", | ||
"space": "srgb", | ||
"format": "hex" | ||
} | ||
} | ||
} | ||
}, | ||
"modifier": { | ||
"value": { | ||
"type": "alpha", | ||
"value": "{alpha}", | ||
"space": "srgb", | ||
"format": "hex" | ||
} | ||
}, | ||
"color2": { | ||
"value": "#000000", | ||
"type": "color", | ||
"$extensions": { | ||
"studio.tokens": { | ||
"modify": "{modifier}" | ||
} | ||
} | ||
} | ||
} |
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