Skip to content

Commit 7329865

Browse files
add typo to figma build (#892)
1 parent 47bb2bf commit 7329865

File tree

7 files changed

+38
-2
lines changed

7 files changed

+38
-2
lines changed

scripts/buildFigma.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ const buildFigma = (buildOptions: ConfigGeneratorOptions): void => {
7373
},
7474
}).buildAllPlatforms()
7575

76+
/** -----------------------------------
77+
* Typography
78+
* ----------------------------------- */
79+
//
80+
PrimerStyleDictionary.extend({
81+
source: ['src/tokens/base/typography/typography.json', 'src/tokens/functional/typography/typography.json'],
82+
include: [],
83+
platforms: {
84+
figma: figma(`figma/typography/typography.json`, buildOptions.prefix, buildOptions.buildPath),
85+
},
86+
}).buildAllPlatforms()
87+
7688
/** -----------------------------------
7789
* Shadow tokens
7890
* ----------------------------------- */

src/formats/jsonFigma.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const getFigmaType = (type: string): string => {
2727
const validTypes = {
2828
color: 'COLOR',
2929
dimension: 'FLOAT',
30+
fontWeight: 'FLOAT',
31+
fontFamily: 'STRING',
3032
}
3133
if (type in validTypes) return validTypes[type as keyof typeof validTypes]
3234
throw new Error(`Invalid type: ${type}`)

src/platforms/figma.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {PlatformInitializer} from '../types/PlatformInitializer'
33
import {isSource} from '../filters'
44

55
const validFigmaToken = (token: StyleDictionary.TransformedToken) => {
6-
const validTypes = ['color', 'dimension', 'shadow']
6+
const validTypes = ['color', 'dimension', 'shadow', 'fontWeight', 'fontFamily']
77
// is a siource token, not an included one
88
if (!isSource(token)) return false
99
// has a collection attribute

src/schemas/collections.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ type Collections =
88
| 'base/color/dark'
99
| 'base/color/dark-dimmed'
1010
| 'base/color/dark-high-contrast'
11+
| 'base/typography'
1112
| 'mode'
1213
| 'pattern/mode'
1314
| 'base/size'
1415
| 'functional/size'
1516
| 'pattern/size'
17+
| 'typography'
1618

1719
export const collection = (collections: Collections[]) => {
1820
return z.string().refine(

src/schemas/dimensionToken.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const dimensionToken = baseToken
1313
$extensions: z
1414
.object({
1515
'org.primer.figma': z.object({
16-
collection: collection(['base/size', 'functional/size', 'pattern/size']),
16+
collection: collection(['base/size', 'functional/size', 'pattern/size', 'typography']),
1717
scopes: scopes(['all', 'size', 'gap', 'radius', 'borderColor']),
1818
}),
1919
})

src/schemas/fontFamilyToken.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@ import {z} from 'zod'
22
import {referenceValue} from './referenceValue'
33
import {baseToken} from './baseToken'
44
import {tokenType} from './tokenType'
5+
import {collection} from './collections'
6+
import {scopes} from './scopes'
57

68
export const fontFamilyToken = baseToken
79
.extend({
810
$value: z.union([z.string(), referenceValue]),
911
$type: tokenType('fontFamily'),
12+
$extensions: z
13+
.object({
14+
'org.primer.figma': z.object({
15+
collection: collection(['base/typography', 'typography']).optional(),
16+
scopes: scopes(['all']).optional(),
17+
}),
18+
})
19+
.optional(),
1020
})
1121
.strict()

src/schemas/fontWeightToken.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ import {fontWeightValue} from './fontWeightValue'
33
import {referenceValue} from './referenceValue'
44
import {baseToken} from './baseToken'
55
import {tokenType} from './tokenType'
6+
import {collection} from './collections'
7+
import {scopes} from './scopes'
68

79
export const fontWeightToken = baseToken
810
.extend({
911
$type: tokenType('fontWeight'),
1012
$value: z.union([fontWeightValue, referenceValue]),
13+
$extensions: z
14+
.object({
15+
'org.primer.figma': z.object({
16+
collection: collection(['base/typography', 'typography']).optional(),
17+
scopes: scopes(['all']).optional(),
18+
}),
19+
})
20+
.optional(),
1121
})
1222
.strict()

0 commit comments

Comments
 (0)