UNPKG

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

Version:

Figma-specific nodes for the graph engine

57 lines 1.93 kB
import { BooleanSchema, Node } 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 = 'Scope String'; static type = 'studio.tokens.figma.scopeString'; static description = 'Defines string variable scopes for Figma'; constructor(props) { super(props); this.addInput('token', { type: { ...TokenSchema, description: 'The design token to add scopes to' } }); this.addInput('fontFamily', { type: { ...BooleanSchema, default: false, description: 'Include font family scope' } }); this.addInput('fontStyle', { type: { ...BooleanSchema, default: false, description: 'Include font weight or style scope' } }); this.addInput('textContent', { type: { ...BooleanSchema, default: false, description: 'Include text content scope' } }); this.addOutput('token', { type: TokenSchema }); } execute() { const inputs = this.getAllInputs(); const newScopes = []; // Map inputs to corresponding scopes if (inputs.fontFamily) newScopes.push('FONT_FAMILY'); if (inputs.fontStyle) newScopes.push('FONT_STYLE'); if (inputs.textContent) newScopes.push('TEXT_CONTENT'); const modifiedToken = mergeTokenExtensions(inputs.token, { scopes: newScopes }); this.outputs.token.set(modifiedToken); } } //# sourceMappingURL=scopeString.js.map