Skip to content

Commit

Permalink
feat: add preExpand meta info to expanded tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema committed Jul 8, 2024
1 parent e8aea2f commit 59a1f2e
Show file tree
Hide file tree
Showing 4 changed files with 499 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-scissors-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'style-dictionary': minor
---

When expanding object-value tokens, add some metadata about what type the token belonged to before expanding, and which property. This is useful e.g. for transforms to target specific object-value properties like lineHeights. When expanding, the type is aligned to the `number` type (DTCG), but you may want to transform `lineHeight` (not a known DTCG type) tokens but not all `number` tokens.
120 changes: 120 additions & 0 deletions __tests__/StyleDictionary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,38 @@ Use log.verbosity "verbose" or use CLI option --verbose for more details.
color: {
type: 'color',
value: '#000',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'color',
type: 'border',
},
},
},
},
style: {
type: 'strokeStyle',
value: 'solid',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'style',
type: 'border',
},
},
},
},
width: {
type: 'dimension',
value: '2px',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'width',
type: 'border',
},
},
},
},
},
});
Expand Down Expand Up @@ -547,14 +571,38 @@ Use log.verbosity "verbose" or use CLI option --verbose for more details.
color: {
type: 'color',
value: '#000',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'color',
type: 'border',
},
},
},
},
style: {
type: 'strokeStyle',
value: 'solid',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'style',
type: 'border',
},
},
},
},
width: {
type: 'dimension',
value: '2px',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'width',
type: 'border',
},
},
},
},
},
});
Expand Down Expand Up @@ -605,14 +653,38 @@ Use log.verbosity "verbose" or use CLI option --verbose for more details.
color: {
type: 'color',
value: '#000',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'color',
type: 'border',
},
},
},
},
style: {
type: 'strokeStyle',
value: 'solid',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'style',
type: 'border',
},
},
},
},
width: {
type: 'dimension',
value: '2px',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'width',
type: 'border',
},
},
},
},
},
borderTwo: input.borderTwo,
Expand All @@ -622,28 +694,76 @@ Use log.verbosity "verbose" or use CLI option --verbose for more details.
color: {
type: 'color',
value: '#000',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'color',
type: 'border',
},
},
},
},
style: {
type: 'strokeStyle',
value: 'solid',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'style',
type: 'border',
},
},
},
},
width: {
type: 'dimension',
value: '2px',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'width',
type: 'border',
},
},
},
},
},
borderTwo: {
color: {
type: 'color',
value: '#ccc',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'color',
type: 'border',
},
},
},
},
style: {
type: 'strokeStyle',
value: 'dashed',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'style',
type: 'border',
},
},
},
},
width: {
type: 'dimension',
value: '1px',
$extensions: {
'com.styledictionary': {
preExpand: {
prop: 'width',
type: 'border',
},
},
},
},
},
});
Expand Down
Loading

0 comments on commit 59a1f2e

Please sign in to comment.