From 188906ba3d9ec423ecf9bb7be58a28f8f5952363 Mon Sep 17 00:00:00 2001 From: James Stuckey Weber Date: Tue, 15 Aug 2023 14:05:40 -0400 Subject: [PATCH 01/31] Add click to copy behavior --- src/lib/components/colors/Header.svelte | 9 +++++++++ src/lib/components/colors/Output.svelte | 8 ++++++++ src/lib/components/util/Icon.svelte | 2 ++ src/lib/icons/Copy.svelte | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 src/lib/icons/Copy.svelte diff --git a/src/lib/components/colors/Header.svelte b/src/lib/components/colors/Header.svelte index 7e339c1b..fffea928 100644 --- a/src/lib/components/colors/Header.svelte +++ b/src/lib/components/colors/Header.svelte @@ -3,6 +3,7 @@ import type { PlainColorObject } from 'colorjs.io/types/src/color'; import type { Writable } from 'svelte/store'; + import Icon from '$lib/components/util/Icon.svelte'; import type { ColorFormatId } from '$lib/constants'; import { getSpaceFromFormatId } from '$lib/utils'; @@ -63,6 +64,10 @@ break; } }; + + function copyOutput() { + void navigator.clipboard.writeText(display); + }
+ {#if hasError}
Could not parse input as a valid color.
{/if} diff --git a/src/lib/components/colors/Output.svelte b/src/lib/components/colors/Output.svelte index 437698dd..783fc176 100644 --- a/src/lib/components/colors/Output.svelte +++ b/src/lib/components/colors/Output.svelte @@ -3,6 +3,7 @@ import type { PlainColorObject } from 'colorjs.io/types/src/color'; import SupportWarning from '$lib/components/colors/SupportWarning.svelte'; + import Icon from '$lib/components/util/Icon.svelte'; import type { ColorFormatId } from '$lib/constants'; import { getSpaceFromFormatId } from '$lib/utils'; @@ -17,10 +18,17 @@ format, inGamut: false, }); + function copyOutput() { + void navigator.clipboard.writeText(targetColorValue); + }