diff --git a/apps/color-buddy/src/controls/SetColorSpace.svelte b/apps/color-buddy/src/controls/SetColorSpace.svelte index e9abb51..4303892 100644 --- a/apps/color-buddy/src/controls/SetColorSpace.svelte +++ b/apps/color-buddy/src/controls/SetColorSpace.svelte @@ -3,7 +3,7 @@ import configStore from "../stores/config-store"; - import { colorPickerConfig } from "../lib/utils"; + import { colorPickerConfig, titleCase } from "../lib/utils"; import Tooltip from "../components/Tooltip.svelte"; import Nav from "../components/Nav.svelte"; import Check from "virtual:icons/fa6-solid/check"; @@ -12,18 +12,26 @@ export let colorSpace: string; export let onChange: (e: any) => void; export let showDragPicker: boolean; - const notAllowed = new Set(["rgb"]); - $: basicOptions = Object.keys(colorPickerConfig) - .filter((x) => !notAllowed.has(x) && !colorPickerConfig[x].advancedSpace) - .sort((a, b) => { - if (a === "lab") return -1; - if (b === "lab") return 1; - return a.localeCompare(b); - }); - - $: advancedSpaceOptions = Object.keys(colorPickerConfig) - .filter((x) => !notAllowed.has(x) && colorPickerConfig[x].advancedSpace) - .filter((x) => x.toLowerCase() !== "srgb"); + const notAllowed = new Set([ + "rgb", + // "srgb", + ]); + $: spaceGroups = Object.keys(colorPickerConfig) + .filter((x) => !notAllowed.has(x.toLowerCase())) + .reduce( + (acc, x) => { + const group = colorPickerConfig[x].spaceType; + if (!acc[group]) acc[group] = []; + acc[group].push(x); + return acc; + }, + {} as Record + ); + const groupOrder = [ + "perceptually uniform", + "rgb based", + "other interesting spaces", + ]; $: showBg = $configStore.showColorBackground; const showTypes = ["show on drag", "always show", "never show"] as Parameters< @@ -34,66 +42,43 @@
Color space
-
-
Basic color spaces
- {#each basicOptions as space} - - {/each} -
-
Advanced color spaces
- - {#each advancedSpaceOptions as space} -
- + + {/each} +
{/each} {#if showDragPicker} diff --git a/apps/color-buddy/src/lib/utils.ts b/apps/color-buddy/src/lib/utils.ts index af77028..07e1f60 100644 --- a/apps/color-buddy/src/lib/utils.ts +++ b/apps/color-buddy/src/lib/utils.ts @@ -27,15 +27,14 @@ type ColorSpace = keyof typeof ColorSpaceDirectory; export const colorPickerConfig = Object.fromEntries( (Object.keys(ColorSpaceDirectory) as ColorSpace[]).map((name: ColorSpace) => { const space = (ColorSpaceDirectory as any)[name] as typeof Color; - const exampleColor = new (ColorSpaceDirectory as any)[name]() as Color; const { x, y, z } = space.dimensionToChannel; return [ name, { - advancedSpace: space.advancedSpace, axisLabel: space.axisLabel, description: space.description, isPolar: space.isPolar, + spaceType: space.spaceType, title: space.name, xChannel: x, xChannelIndex: space.channelNames.indexOf(x), diff --git a/apps/color-buddy/src/scatterplot/ColorScatterPlotPolarGuide.svelte b/apps/color-buddy/src/scatterplot/ColorScatterPlotPolarGuide.svelte index 4d49610..ab74dea 100644 --- a/apps/color-buddy/src/scatterplot/ColorScatterPlotPolarGuide.svelte +++ b/apps/color-buddy/src/scatterplot/ColorScatterPlotPolarGuide.svelte @@ -1,5 +1,5 @@