|
1 | 1 | <script lang="ts"> |
| 2 | + import type { Snippet } from "svelte"; |
2 | 3 | import { titleCase } from "title-case"; |
3 | 4 | import { noCase } from "change-case"; |
4 | 5 | import type { HTMLAttributes } from "svelte/elements"; |
5 | 6 | import type { SvelteSet } from "svelte/reactivity"; |
6 | 7 | import { Plus, X } from "@lucide/svelte"; |
| 8 | + import type { ChangeDetail } from "hdr-color-input"; |
7 | 9 | import { |
8 | 10 | treeState, |
9 | 11 | resolveTokenValue, |
|
25 | 27 | import GradientEditor from "./gradient-editor.svelte"; |
26 | 28 | import AliasToken from "./alias-token.svelte"; |
27 | 29 | import type { TreeNode } from "./store"; |
28 | | - import type { Snippet } from "svelte"; |
29 | 30 |
|
30 | 31 | let { |
31 | 32 | id, |
|
523 | 524 | {/if} |
524 | 525 |
|
525 | 526 | {#if rawValue?.type === "color"} |
| 527 | + <!-- Store in separate derived to cache and avoid infinite cycle --> |
| 528 | + {@const colorValue = serializeColor(rawValue.value)} |
526 | 529 | <div class="form-group"> |
527 | 530 | <!-- svelte-ignore a11y_label_has_associated_control --> |
528 | 531 | <label class="a-label">Color</label> |
529 | 532 | <color-input |
530 | | - value={serializeColor(rawValue.value)} |
531 | | - onopen={(event: InputEvent) => { |
532 | | - // track both open and close because of bug in css-color-component |
533 | | - const input = event.target as HTMLInputElement; |
534 | | - updateMeta({ value: parseColor(input.value) }); |
535 | | - }} |
536 | | - onclose={(event: InputEvent) => { |
537 | | - const input = event.target as HTMLInputElement; |
538 | | - updateMeta({ value: parseColor(input.value) }); |
| 533 | + value={colorValue} |
| 534 | + onchange={(event: CustomEvent<ChangeDetail>) => { |
| 535 | + updateMeta({ value: parseColor(event.detail.value) }); |
539 | 536 | }} |
540 | 537 | ></color-input> |
541 | 538 | </div> |
|
0 commit comments