Skip to content

Commit

Permalink
rename $extension to $extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Jul 12, 2023
1 parent deed9d6 commit 01337ea
Show file tree
Hide file tree
Showing 18 changed files with 1,199 additions and 948 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,32 @@ A `mix` proprty must always have a `color` and a `weight` child. `color` can be
}
```

#### Extensions property

According to the [w3c design token specs](https://design-tokens.github.io/community-group/format/#design-token), the [`$extensions`](https://design-tokens.github.io/community-group/format/#extensions) property is used for additional meta data.

For our Figma export we use the following meta data:

- `collection` the collection that the token is added to within Figma
- `mode` the mode that the token is added to within the collection in Figma
- `scopes` the scopes that are assigned to the token in Figma, the actual Figma compatible `scopes` are retreive from an object in the [figmaAttributes transformer](./src/transformers/figmaAttributes.ts)

Code example

```js
bgColor: {
$value: '{borderColor.accent.muted}',
$type: 'color',
$extensions: {
'org.primer.figma': {
collection: 'pattern/mode',
mode: 'light',
scopes: ['bgColor'],
},
},
}
```

## License

[MIT](./LICENSE) © [GitHub](https://github.com/)
Expand Down
6 changes: 3 additions & 3 deletions src/platforms/figma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const validFigmaToken = (token: StyleDictionary.TransformedToken) => {
if (!isSource(token)) return false
// has a collection attribute
if (
!('$extension' in token) ||
!('org.primer.figma' in token.$extension) ||
!('collection' in token.$extension['org.primer.figma'])
!('$extensions' in token) ||
!('org.primer.figma' in token.$extensions) ||
!('collection' in token.$extensions['org.primer.figma'])
)
return false
// is a color or dimension type
Expand Down
Loading

0 comments on commit 01337ea

Please sign in to comment.