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

WIP: Token map perf #1427

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/ninety-adults-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'style-dictionary': minor
---

Add `tokenMap` properties to Dictionary, which is a JavaScript Map structure of the tokens, which makes it easy to iterate as well as access tokens. Also add `convertTokenData` utility that allows to seemlessly convert between Map, Object or Array of tokens, and deprecate the `flattenTokens` utility in favor of that one.
7 changes: 7 additions & 0 deletions .changeset/three-weeks-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'style-dictionary': major
---

No longer allow references to non-token leaf nodes. References only work when referencing a Design Token (its value).
Non-token nodes will also not make it to the output, because they are filtered out during the flattening process to `tokenMap` and `tokenArray`.
Remove allowing references with `.value` suffix.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ This tells the style dictionary build system how and what to build. The default
"small": { "value": "10px" },
"medium": { "value": "16px" },
"large": { "value": "24px" },
"base": { "value": "{size.font.medium.value}" }
"base": { "value": "{size.font.medium}" }
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions __integration__/__snapshots__/customFileHeader.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ module.exports = {
color: {
red: {
value: "#ff0000",
key: "{color.red}",
original: {
value: "#ff0000",
key: "{color.red}",
},
name: "ColorRed",
attributes: {
Expand All @@ -66,8 +68,10 @@ snapshots["integration valid custom file headers platform options showFileHeader
color: {
red: {
value: "#ff0000",
key: "{color.red}",
original: {
value: "#ff0000",
key: "{color.red}",
},
name: "ColorRed",
attributes: {
Expand All @@ -90,8 +94,10 @@ module.exports = {
color: {
red: {
value: "#ff0000",
key: "{color.red}",
original: {
value: "#ff0000",
key: "{color.red}",
},
name: "ColorRed",
attributes: {
Expand Down
Loading
Loading