Skip to content

Commit

Permalink
Update jsonFigma.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Nov 21, 2023
1 parent 1692331 commit 47e46bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-shrimps-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/primitives': patch
---

adding CodeSyntax to tokens for figma
3 changes: 2 additions & 1 deletion src/formats/jsonFigma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const jsonFigma: StyleDictionary.Formatter = ({dictionary, file: _file, p
// sort tokens by reference
const tokens = dictionary.allTokens.sort(sortByReference(dictionary)).map(token => {
const {attributes, value, $type, comment: description, original, alpha, mix} = token
const {mode, collection, scopes, group} = attributes || {}
const {mode, collection, scopes, group, codeSyntax} = attributes || {}

return {
name: token.name,
Expand All @@ -52,6 +52,7 @@ export const jsonFigma: StyleDictionary.Formatter = ({dictionary, file: _file, p
mode,
group,
scopes,
codeSyntax,
}
})
// add file header and convert output
Expand Down
3 changes: 2 additions & 1 deletion src/transformers/figmaAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ const getScopes = (scopes: string[] | string | undefined): FigmaVariableScope[]
export const figmaAttributes: StyleDictionary.Transform = {
type: `attribute`,
transformer: (token: StyleDictionary.TransformedToken, platform: StyleDictionary.Platform = {}) => {
const {mode, collection, scopes, group} = token.$extensions?.['org.primer.figma'] || {}
const {mode, collection, scopes, group, codeSyntax} = token.$extensions?.['org.primer.figma'] || {}
return {
mode: platform.options?.mode || mode || 'default',
collection,
group: group || collection,
scopes: getScopes(scopes),
codeSyntax,
}
},
}

0 comments on commit 47e46bf

Please sign in to comment.