UNPKG

@tokens-studio/graph-engine-nodes-figma

Version:

Figma-specific nodes for the graph engine

55 lines 1.85 kB
import { Node, StringSchema } from '@tokens-studio/graph-engine'; import { TokenSchema } from '@tokens-studio/graph-engine-nodes-design-tokens/schemas/index.js'; import { mergeTokenExtensions } from '../utils/tokenMerge.js'; export default class NodeDefinition extends Node { static title = 'Code Syntax'; static type = 'studio.tokens.figma.codeSyntax'; static description = 'Defines code syntax for different platforms in Figma'; constructor(props) { super(props); this.addInput('token', { type: { ...TokenSchema, description: 'The design token to add code syntax to' } }); this.addInput('web', { type: { ...StringSchema, default: '', description: 'Web platform code syntax' } }); this.addInput('android', { type: { ...StringSchema, default: '', description: 'Android platform code syntax' } }); this.addInput('ios', { type: { ...StringSchema, default: '', description: 'iOS platform code syntax' } }); this.addOutput('token', { type: TokenSchema }); } execute() { const inputs = this.getAllInputs(); const codeSyntax = { ...(inputs.web && { Web: inputs.web }), ...(inputs.android && { Android: inputs.android }), ...(inputs.ios && { iOS: inputs.ios }) }; const modifiedToken = mergeTokenExtensions(inputs.token, { hiddenFromPublishing: false, codeSyntax }); this.outputs.token.set(modifiedToken); } } //# sourceMappingURL=codeSyntax.js.map