UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

37 lines 1.25 kB
import { ColorSchema, NumberSchema } from '../../schemas/index.js'; import { Node } from '../../programmatic/node.js'; import { White, toColor, toColorObject } from './lib/utils.js'; export default class NodeDefinition extends Node { static title = 'Darken Color'; static type = 'studio.tokens.color.darken'; static description = 'Darkens a color by a specified value'; constructor(props) { super(props); this.addInput('color', { type: { ...ColorSchema, default: White } }); this.addInput('value', { type: { ...NumberSchema, default: 0.5, description: 'Value to apply to the modifier' } }); this.addOutput('value', { type: ColorSchema }); } execute() { const { value, color } = this.getAllInputs(); const sourceColor = toColor(color); const lightness = sourceColor.oklch.l; const newLightness = lightness * (1 - value); sourceColor.oklch.l = newLightness; const final = toColorObject(sourceColor); this.outputs.value.set(final); } } //# sourceMappingURL=darken.js.map