From 197b4fabd1f91773ffef29516fe23f5880e05c8a Mon Sep 17 00:00:00 2001 From: Andrew Michael McNutt Date: Thu, 11 Jan 2024 13:46:50 -0800 Subject: [PATCH] Rework color storage --- src/components/ColorScatterPlot.svelte | 4 +- src/components/KeyboardHooks.svelte | 2 +- src/content-modules/Background.svelte | 2 +- src/content-modules/SetColorSpace.svelte | 13 ++-- .../SwatchTooltipContent.svelte | 2 +- .../context-free-tools/AddFamiliarPal.svelte | 4 +- .../GetColorsFromString.svelte | 2 +- .../context-free-tools/SuggestColorPal.svelte | 3 +- .../contextual-tools/AddColor.svelte | 2 +- .../contextual-tools/AdjustColor.svelte | 2 +- .../contextual-tools/AlignSelection.svelte | 2 +- .../contextual-tools/DistributePoints.svelte | 2 +- .../contextual-tools/Rotate.svelte | 2 +- .../SuggestionModificationToSelection.svelte | 3 +- src/lib/Color.test.ts | 22 +++++++ src/lib/Color.ts | 60 +++++++++++++++---- src/lib/ColorLint.test.ts | 1 + src/lib/lints/background-differentiability.ts | 3 +- src/stores/color-store.ts | 58 +++++++++++------- 19 files changed, 133 insertions(+), 56 deletions(-) create mode 100644 src/lib/Color.test.ts diff --git a/src/components/ColorScatterPlot.svelte b/src/components/ColorScatterPlot.svelte index 4dfd3a8e..530cfa22 100644 --- a/src/components/ColorScatterPlot.svelte +++ b/src/components/ColorScatterPlot.svelte @@ -403,7 +403,7 @@ fill={color.toHex()} /> {/if} - + {/if} {/each} {#each blindColors as blindColor, i} diff --git a/src/components/KeyboardHooks.svelte b/src/components/KeyboardHooks.svelte index 709da97d..d8c7c165 100644 --- a/src/components/KeyboardHooks.svelte +++ b/src/components/KeyboardHooks.svelte @@ -4,7 +4,7 @@ import focusStore from "../stores/focus-store"; $: focusedSet = new Set($focusStore.focusedColors); $: copiedData = [] as Color[]; - $: colorSpace = $colorStore.currentPal.colors[0].spaceName; + $: colorSpace = $colorStore.currentPal.colorSpace; $: [_zStep, xStep, yStep] = stepSize[colorSpace]; function onKeyDown(e: any) { if (e.target.tagName.toLowerCase() === "input") { diff --git a/src/content-modules/Background.svelte b/src/content-modules/Background.svelte index f4c0d33b..9c8f7928 100644 --- a/src/content-modules/Background.svelte +++ b/src/content-modules/Background.svelte @@ -5,7 +5,7 @@ import ColorChannelPicker from "../components/ColorChannelPicker.svelte"; import Tooltip from "../components/Tooltip.svelte"; $: bg = $colorStore.currentPal.background; - $: colorSpace = $colorStore.currentPal.colors[0].spaceName || "lab"; + $: colorSpace = $colorStore.currentPal.colorSpace; function onChange(color: Color) { colorStore.setBackground(color); } diff --git a/src/content-modules/SetColorSpace.svelte b/src/content-modules/SetColorSpace.svelte index dac41406..c0f8d0be 100644 --- a/src/content-modules/SetColorSpace.svelte +++ b/src/content-modules/SetColorSpace.svelte @@ -1,7 +1,7 @@ @@ -9,13 +9,10 @@