From 37019dad9e2445ac537f52429e02fb20dff56805 Mon Sep 17 00:00:00 2001 From: Andrew McNutt Date: Thu, 3 Oct 2024 19:57:09 -0600 Subject: [PATCH] Todays ux tweaks (#132) --- apps/color-buddy/src/App.svelte | 29 ++++++++++++++----- .../src/components/ColorBall.svelte | 4 +-- apps/color-buddy/src/controls/DeMetric.svelte | 6 +++- apps/color-buddy/src/controls/Title.svelte | 16 ++++++++-- .../src/linting/GlobalLintConfigModal.svelte | 9 +++++- .../src/__snapshots__/ColorLint.test.ts.snap | 8 ++--- .../src/lints/background-contrast.ts | 2 +- packages/palette/src/Color.ts | 2 +- 8 files changed, 57 insertions(+), 19 deletions(-) diff --git a/apps/color-buddy/src/App.svelte b/apps/color-buddy/src/App.svelte index c8a7ef4..5b5732b 100644 --- a/apps/color-buddy/src/App.svelte +++ b/apps/color-buddy/src/App.svelte @@ -168,13 +168,28 @@ >
{#if tab === "eval"} -
- {$lintStore.currentChecks.filter( - (x) => x.kind === "success" && !x.passes - ).length} -
+ + + + + {$lintStore.currentChecks.filter( + (x) => x.kind === "success" && !x.passes + ).length} + + {/if}
diff --git a/apps/color-buddy/src/components/ColorBall.svelte b/apps/color-buddy/src/components/ColorBall.svelte index ccced90..366df37 100644 --- a/apps/color-buddy/src/components/ColorBall.svelte +++ b/apps/color-buddy/src/components/ColorBall.svelte @@ -96,7 +96,7 @@ {/if} {#if stats[idx] && !statsTypeIsDelta && $configStore.evalDeltaDisplay !== "none"}
- Contrast: {Math.round(stats[idx])} + Contrast: {Math.round(stats[idx] * 10) / 10}
{/if} @@ -104,6 +104,6 @@ {#if stats[idx] && statsTypeIsDelta && $configStore.evalDeltaDisplay !== "none"}
- dE: {Math.round(stats[idx])} + dE: {Math.round(stats[idx] * 10) / 10}
{/if} diff --git a/apps/color-buddy/src/controls/DeMetric.svelte b/apps/color-buddy/src/controls/DeMetric.svelte index d5759ff..37da54c 100644 --- a/apps/color-buddy/src/controls/DeMetric.svelte +++ b/apps/color-buddy/src/controls/DeMetric.svelte @@ -5,6 +5,10 @@ import ChevDown from "virtual:icons/fa6-solid/chevron-down"; import { controlButtonStyle } from "../lib/styles"; import { contrastMetrics, deltaMetrics } from "../constants"; + + const nameMap: Record = { + Lstar: "Delta L*", + }; @@ -47,7 +51,7 @@ class:font-bold={$configStore.evalDeltaDisplay === metric} on:click={() => configStore.setEvalDeltaDisplay(metric)} > - {metric} + {nameMap[metric] || metric} {#if metric === "WCAG21"} (recommended) {/if} diff --git a/apps/color-buddy/src/controls/Title.svelte b/apps/color-buddy/src/controls/Title.svelte index 20981ac..8d56109 100644 --- a/apps/color-buddy/src/controls/Title.svelte +++ b/apps/color-buddy/src/controls/Title.svelte @@ -28,11 +28,23 @@ on:submit|preventDefault={() => colorStore.setCurrentPalName(nameBind)} > - + colorStore.setCurrentPalName(nameBind)} + /> - diff --git a/apps/color-buddy/src/linting/GlobalLintConfigModal.svelte b/apps/color-buddy/src/linting/GlobalLintConfigModal.svelte index b66902d..993a4b1 100644 --- a/apps/color-buddy/src/linting/GlobalLintConfigModal.svelte +++ b/apps/color-buddy/src/linting/GlobalLintConfigModal.svelte @@ -27,6 +27,13 @@ function onClose() { modalState = "closed"; } + $: groupNames = [ + "usability", + "contrast-accessibility", + "color-accessibility", + "design", + "custom", + ].filter((x) => (lintsByGroup[x] || []).length);
- {#each Object.keys(lintGroupNames) as group} + {#each groupNames as group} {#if (lintsByGroup[group] || []).length > 0}
diff --git a/packages/palette-lint/src/__snapshots__/ColorLint.test.ts.snap b/packages/palette-lint/src/__snapshots__/ColorLint.test.ts.snap index bf5b4c4..f017a67 100644 --- a/packages/palette-lint/src/__snapshots__/ColorLint.test.ts.snap +++ b/packages/palette-lint/src/__snapshots__/ColorLint.test.ts.snap @@ -70,13 +70,13 @@ exports[`ColorLint - Contrast (1) GraphicalObjs 1`] = `"These colors () do not h exports[`ColorLint - Contrast (1) GraphicalObjs 2`] = `"These colors (#feed72, #f8f4d2, #eb717b) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; -exports[`ColorLint - Contrast (2) contrastTextAA 1`] = `"These text colors ({{blame}) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; +exports[`ColorLint - Contrast (2) contrastTextAA 1`] = `"These text colors () do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; -exports[`ColorLint - Contrast (2) contrastTextAA 2`] = `"These text colors ({{blame}) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; +exports[`ColorLint - Contrast (2) contrastTextAA 2`] = `"These text colors (#eb717b) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; -exports[`ColorLint - Contrast (3) contrastTextAAA 1`] = `"These text colors ({{blame}) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; +exports[`ColorLint - Contrast (3) contrastTextAAA 1`] = `"These text colors () do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; -exports[`ColorLint - Contrast (3) contrastTextAAA 2`] = `"These text colors ({{blame}) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; +exports[`ColorLint - Contrast (3) contrastTextAAA 2`] = `"These text colors (#af3b4b) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable."`; exports[`ColorLint - Diverging Order 1`] = `""`; diff --git a/packages/palette-lint/src/lints/background-contrast.ts b/packages/palette-lint/src/lints/background-contrast.ts index 8e4cb70..2b01cf1 100644 --- a/packages/palette-lint/src/lints/background-contrast.ts +++ b/packages/palette-lint/src/lints/background-contrast.ts @@ -41,7 +41,7 @@ const lintBase: LintProgram = { level: "error", group: "contrast-accessibility", description: descriptionBase + textPart, - failMessage: `These text colors ({{blame}) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable.`, + failMessage: `These text colors ({{blame}}) do not have a sufficient contrast do not have sufficient contrast with the background to be easily readable.`, id: "background-contrast-built-in", blameMode: "single" as const, subscribedFix: "fixBackgroundDifferentiability", diff --git a/packages/palette/src/Color.ts b/packages/palette/src/Color.ts index a7f73d5..67fc289 100644 --- a/packages/palette/src/Color.ts +++ b/packages/palette/src/Color.ts @@ -445,7 +445,7 @@ class XYZ extends Color { spaceName = "xyz-d65" as const; // static domains = { x: [0, 9504.7], y: [0, 10000], z: [0, 10888.3] } as Domain; // static domains = { x: [0, 100], y: [0, 100], z: [0, 100] } as Domain; - static domains = { x: [0, 1.1], y: [1.1, 0], z: [0, 1.1] } as Domain; + static domains = { x: [0, 1.1], y: [1.1, 0], z: [1.1, 0] } as Domain; static stepSize: Channels = [0.01, 0.01, 0.01]; static dimensionToChannel = { x: "x", y: "z", z: "y" }; static description =