From 1c794a49c5f8357870dca923b3784836668a0a67 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Fri, 24 Sep 2021 20:23:11 -0500 Subject: [PATCH 1/5] fancy new color pickers --- src/locales/en.json | 14 +++ src/p4/ColorPicker.svelte | 191 +++++++++++++++++++++++++++++++++- src/p4/ColorSlider.svelte | 62 +++++++++++ src/p4/PackagerOptions.svelte | 26 ++--- src/p4/color-utils.js | 68 ++++++++++++ test/p4/color-utils.test.js | 27 +++++ 6 files changed, 375 insertions(+), 13 deletions(-) create mode 100644 src/p4/ColorSlider.svelte create mode 100644 src/p4/color-utils.js create mode 100644 test/p4/color-utils.test.js diff --git a/src/locales/en.json b/src/locales/en.json index aa115244..107bdcc1 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -437,6 +437,20 @@ "context": "Prompt to confirm user wants to reset settings" } }, + "color": { + "color": { + "string": "Color", + "context": "Refers to the hue of a color" + }, + "saturation": { + "string": "Saturation", + "context": "Refers to the saturation of a color" + }, + "brightness": { + "string": "Brightness", + "context": "Refers to the brightness of a color" + } + }, "preview": { "loading": { "string": "Loading Preview" diff --git a/src/p4/ColorPicker.svelte b/src/p4/ColorPicker.svelte index 76ec07bd..1b8ffdf0 100644 --- a/src/p4/ColorPicker.svelte +++ b/src/p4/ColorPicker.svelte @@ -1,5 +1,194 @@ - + + + + +
+ + {#if open} +
+
+
+ {$_('color.color')} +
{Math.round(valueAsHsv[0] * 100)}
+
+
+ +
+
+
+
+ {$_('color.saturation')} +
{Math.round(valueAsHsv[1] * 100)}
+
+
+ +
+
+
+
+ {$_('color.brightness')} +
{Math.round(valueAsHsv[2] * 100)}
+
+
+ +
+
+
+ + +
+
+ {/if} +
diff --git a/src/p4/ColorSlider.svelte b/src/p4/ColorSlider.svelte new file mode 100644 index 00000000..090fcc32 --- /dev/null +++ b/src/p4/ColorSlider.svelte @@ -0,0 +1,62 @@ + + + + + + +
+
+
diff --git a/src/p4/PackagerOptions.svelte b/src/p4/PackagerOptions.svelte index 0e112b07..2c2509f4 100644 --- a/src/p4/PackagerOptions.svelte +++ b/src/p4/PackagerOptions.svelte @@ -175,6 +175,11 @@ .group { margin: 12px 0; } + .color { + display: flex; + align-items: center; + margin-bottom: 4px; + } p { margin: 8px 0; } @@ -403,21 +408,18 @@

{$_('options.controlsHelp')}

{$_('options.colors')}

- -