diff --git a/src/App.svelte b/src/App.svelte index d80452e0..12b76af1 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -137,7 +137,4 @@ .main-content { min-width: 0; } - .top-bar { - min-height: 50px !important; - } diff --git a/src/controls/GetColorsFromString.svelte b/src/controls/GetColorsFromString.svelte index 498ccbbd..dded94bb 100644 --- a/src/controls/GetColorsFromString.svelte +++ b/src/controls/GetColorsFromString.svelte @@ -2,33 +2,30 @@ import { Color } from "../lib/Color"; import type { ColorWrap } from "../types"; import configStore from "../stores/config-store"; - import { wrapInBlankSemantics } from "../lib/utils"; + import { wrapInBlankSemantics, processBodyTextToColors } from "../lib/utils"; let state: "idle" | "error" = "idle"; export let onChange: (colors: ColorWrap[]) => void; export let colors: ColorWrap[]; export let colorSpace: string; + let errorMsg = ""; function processBodyInput(body: string) { try { - const newColors = body - .split(",") - .map((x) => x.replace(/"/g, "").trim()) - // remove all parens and brackets - .map((x) => x.replace(/[\(\)\[\]]/g, "")) - .filter((x) => x.length > 0) - .map((x) => Color.colorFromString(x, colorSpace as any)) - .map((x, idx) => { + const newColors = processBodyTextToColors(body, colorSpace).map( + (x, idx) => { if (colors[idx]) { return { ...colors[idx], color: x }; } else { return wrapInBlankSemantics(x); } - }); + } + ); onChange(newColors); state = "idle"; } catch (e) { console.error(e); + errorMsg = (e as any)?.message; state = "error"; return; } @@ -38,8 +35,21 @@
+
+ +
+ + configStore.setIncludeQuotes(!includeQuotes)} + /> +
+
{#if state === "error"} -
Error parsing colors
+
Error parsing colors. {errorMsg}
{/if}