Skip to content

Commit

Permalink
Merge pull request #592 from tokens-studio/add-hex
Browse files Browse the repository at this point in the history
add hex to color space
  • Loading branch information
mck authored Dec 17, 2024
2 parents 3a5a336 + 24b4d27 commit 5869a22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-lobsters-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tokens-studio/graph-engine": patch
---

Add hex to color space selector
11 changes: 5 additions & 6 deletions packages/graph-engine/src/nodes/color/colorToString.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Black, toColor } from './lib/utils.js';
import { ColorSchema, StringSchema } from '../../schemas/index.js';
import { ColorSpaces } from './lib/spaces.js';
import { type ColorSpace, ColorSpaces } from './lib/spaces.js';
import { Color as ColorType } from '../../types.js';
import { INodeDefinition, ToInput, ToOutput } from '../../index.js';
import { Node } from '../../programmatic/node.js';
Expand All @@ -12,7 +12,7 @@ export default class NodeDefinition extends Node {

declare inputs: ToInput<{
color: ColorType;
space: 'srgb' | 'hsl' | 'hex';
space: ColorSpace | 'hex';
}>;
declare outputs: ToOutput<{
value: string;
Expand All @@ -29,10 +29,9 @@ export default class NodeDefinition extends Node {
this.addInput('space', {
type: {
...StringSchema,
enum: ColorSpaces,
enum: ['hex', ...ColorSpaces],
default: 'hex'
},
visible: false
}
});
this.addOutput('value', {
type: StringSchema
Expand All @@ -43,7 +42,7 @@ export default class NodeDefinition extends Node {
// eslint-disable-next-line prefer-const
const { color, space } = this.getAllInputs();

let adjustedSpace: string = space;
let adjustedSpace: string = space as string;
let format: { format: string } | undefined = undefined;

if (space == 'hex') {
Expand Down

0 comments on commit 5869a22

Please sign in to comment.