From 754aa58b233c57b6fea42a747bc5ed60284cea81 Mon Sep 17 00:00:00 2001 From: Andrew Michael McNutt Date: Sun, 10 Mar 2024 21:08:34 -0700 Subject: [PATCH] everything is running again --- src/controls/NewPal.svelte | 2 +- src/lib/api-calls.ts | 5 ++++- src/lib/utils.ts | 2 +- src/stores/color-store.ts | 7 +++---- src/stores/lint-store.ts | 8 ++++---- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/controls/NewPal.svelte b/src/controls/NewPal.svelte index 7196bd9b..9bd65622 100644 --- a/src/controls/NewPal.svelte +++ b/src/controls/NewPal.svelte @@ -26,7 +26,7 @@ function newPal(newPal: StringPalette) { const colors = newPal.colors.map((x) => { const color = Color.colorFromString(x.color, colorSpace); - return { ...x, color }; + return wrapInBlankSemantics(color); }); const pal = { ...newPal, diff --git a/src/lib/api-calls.ts b/src/lib/api-calls.ts index 2310aae8..21610bb0 100644 --- a/src/lib/api-calls.ts +++ b/src/lib/api-calls.ts @@ -169,7 +169,10 @@ export function lint(pal: Palette, computeMessage: boolean) { content: JSON.stringify({ ...pal, background: pal.background.toString(), - colors: pal.colors.map((x) => x.color.toString()), + colors: pal.colors.map((x) => ({ + ...x, + color: x.color.toString(), + })), }), }).then((x) => { return x as unknown as any[]; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index be7eb929..8e74a4a8 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -249,7 +249,7 @@ export function newGenericPal(name: string): StringPalette { return { ...defaultHexPal, name, - colors: pick(outfits), + colors: pick(outfits).map((x: string) => wrapInBlankStringSemantics(x)), }; } export function makePalFromString( diff --git a/src/stores/color-store.ts b/src/stores/color-store.ts index 2367209b..ea36689e 100644 --- a/src/stores/color-store.ts +++ b/src/stores/color-store.ts @@ -1,6 +1,6 @@ import { writable } from "svelte/store"; import { Color } from "../lib/Color"; -import { deDup, newGenericPal, wrapInBlankStringSemantics } from "../lib/utils"; +import { deDup, newGenericPal, wrapInBlankSemantics } from "../lib/utils"; import type { Palette, @@ -27,12 +27,11 @@ function stringPalToColorPal(pal: StringPalette): Palette { ...pal, background: Color.colorFromString(pal.background, pal.colorSpace), colors: pal.colors.map((x) => { - let colorWrap = x; - const color = Color.colorFromString(x.color, pal.colorSpace); // catch old versions if (typeof x === "string") { - colorWrap = wrapInBlankStringSemantics(x); + return wrapInBlankSemantics(Color.colorFromString(x, pal.colorSpace)); } + const color = Color.colorFromString(x.color, pal.colorSpace); return { ...x, color }; }), }; diff --git a/src/stores/lint-store.ts b/src/stores/lint-store.ts index f9fcdd39..a84ad805 100644 --- a/src/stores/lint-store.ts +++ b/src/stores/lint-store.ts @@ -41,7 +41,7 @@ function serializePalette(pal: Palette): StringPalette { background: pal.background.toString(), colors: pal.colors.map((x) => ({ ...x, - color: x.toString(), + color: x.color.toString(), })), }; } @@ -51,10 +51,10 @@ function deserializePalette(pal: StringPalette): Palette { ...pal, background: Color.colorFromString(pal.background, pal.colorSpace), colors: pal.colors.map((x) => { - const color = Color.colorFromString(x.color, pal.colorSpace); - if (typeof x.color === "string") { - return wrapInBlankSemantics(color); + if (typeof x === "string") { + return wrapInBlankSemantics(Color.colorFromString(x, pal.colorSpace)); } + const color = Color.colorFromString(x.color, pal.colorSpace); return { ...x, color }; }), };