@tfk-samf/figma-to-dtcg
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,2 +0,2 @@ | ||
import { RGB, GetLocalVariablesResponse } from '@figma/rest-api-spec'; | ||
import { RGB, LocalVariable, GetLocalVariablesResponse } from '@figma/rest-api-spec'; | ||
/** | ||
@@ -32,3 +32,4 @@ * Configure this package for the Figma Variables Rest API. | ||
}; | ||
export type DesignTokenType = 'color' | 'number'; | ||
export type DesignTokenType = 'color' | 'number' | 'fontFamily' | 'boolean'; | ||
export type FigmaTokenType = LocalVariable["resolvedType"]; | ||
export type DesignToken = { | ||
@@ -35,0 +36,0 @@ type: DesignTokenType; |
@@ -0,1 +1,7 @@ | ||
const figmaDesignTokenTypeMap = { | ||
'COLOR': 'color', | ||
'FLOAT': 'number', | ||
'STRING': 'fontFamily', | ||
'BOOLEAN': 'boolean' | ||
}; | ||
let getVariableById; | ||
@@ -141,3 +147,3 @@ /** | ||
const value = valuesByMode[keyToId[mode]]; | ||
if (value !== undefined && ['COLOR', 'FLOAT'].includes(resolvedType)) { | ||
if (value !== undefined && ['COLOR', 'FLOAT', 'STRING'].includes(resolvedType)) { | ||
const groups = name.split('/'); | ||
@@ -152,3 +158,3 @@ if (groups.some((group) => isPrivate(group))) | ||
obj.value = await valueToJSON(name, value, resolvedType); | ||
obj.type = (resolvedType === 'COLOR' ? 'color' : 'number'); | ||
obj.type = figmaDesignTokenTypeMap[resolvedType]; | ||
obj.prefix = collectionPrefix; | ||
@@ -184,3 +190,2 @@ } | ||
} | ||
// console.log("tokens", JSON.stringify(tree, null, 2)) | ||
return { | ||
@@ -187,0 +192,0 @@ tokens: tree, |
{ | ||
"name": "@tfk-samf/figma-to-dtcg", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Parse Figma Variables Plugin API and REST API into design tokens.", | ||
@@ -35,3 +35,3 @@ "files": [ | ||
}, | ||
"gitHead": "67a5a2e8eeb01457256a85b76ad319272a820b09" | ||
"gitHead": "2c3d5d013a37c46e3c026fd3f7c75fcdf39a1129" | ||
} |
14236
262