diff --git a/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte b/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte index 2ae31385aa..27b5e20b5b 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte @@ -13,16 +13,18 @@ import Palette from "./Palette.svelte" import ButtonGroup from "./ButtonGroup.svelte" import Input from "./Input.svelte" + import Portal from "./Portal.svelte" export let value = "#3ec1d3ff" + export let open = false; export let swatches = [] //TODO: Safe swatches - limit to 12. warn in console export let disableSwatches = false export let format = "hexa" - export let open = false - + export let style = "" export let pickerHeight = 0 export let pickerWidth = 0 + let colorPicker = null let adder = null let h = null @@ -38,6 +40,10 @@ getRecentColors() } + if(colorPicker) { + colorPicker.focus() + } + if (format) { convertAndSetHSVA() } @@ -50,6 +56,12 @@ } } + function handleEscape(e) { + if(open && e.key === "Escape") { + open = false + } + } + function setRecentColor(color) { if (swatches.length === 12) { swatches.splice(0, 1) @@ -145,85 +157,97 @@ } $: border = v > 90 && s < 5 ? "1px dashed #dedada" : "" - $: style = buildStyle({ background: value, border }) + $: selectedColorStyle = buildStyle({ background: value, border }) $: shrink = swatches.length > 0 + -
-
- -
+ +
-
-
-
- -
- -
-
- setHue(hue.detail)} - on:dragend={dispatchValue} /> +
+ +
- +
+
+
+ +
+ +
+
setAlpha(alpha.detail, isDrag)} + type="hue" + value={h} + on:change={hue => setHue(hue.detail)} on:dragend={dispatchValue} /> - + + setAlpha(alpha.detail, isDrag)} + on:dragend={dispatchValue} /> + + +
+
+ + {#if !disableSwatches} +
+ {#if swatches.length > 0} + {#each swatches as color, idx} + applySwatch(color)} + on:removeswatch={() => removeSwatch(idx)} /> + {/each} + {/if} + {#if swatches.length !== 12} +
+ + +
+ {/if} +
+ {/if} + +
+ + handleColorInput(event.target.value)} + on:change={dispatchInputChange} />
- {#if !disableSwatches} -
- {#if swatches.length > 0} - {#each swatches as color, idx} - applySwatch(color)} - on:removeswatch={() => removeSwatch(idx)} /> - {/each} - {/if} - {#if swatches.length !== 12} -
- + -
- {/if} -
- {/if} - -
- - handleColorInput(event.target.value)} - on:change={dispatchInputChange} /> -
- -
+