From 997efa62b39759ce22711c47bc5bd6b08d7dcb40 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 23 Jun 2021 11:47:07 +0100 Subject: [PATCH] Add wrapper to color picker and fix helper import --- .../bbui/src/ColorPicker/ColorPicker.svelte | 100 ++++++++++-------- packages/bbui/src/utils/helpers.js | 2 + 2 files changed, 57 insertions(+), 45 deletions(-) diff --git a/packages/bbui/src/ColorPicker/ColorPicker.svelte b/packages/bbui/src/ColorPicker/ColorPicker.svelte index 4ccd390619..aeba2eae76 100644 --- a/packages/bbui/src/ColorPicker/ColorPicker.svelte +++ b/packages/bbui/src/ColorPicker/ColorPicker.svelte @@ -5,7 +5,7 @@ import { fly } from "svelte/transition" import Icon from "../Icon/Icon.svelte" import Input from "../Form/Input.svelte" - import { capitalise } from "helpers" + import { capitalise } from "../utils/helpers" export let value @@ -108,55 +108,65 @@ } -
(open = true)} -/> -{#if open} +
(open = false)} - transition:fly={{ y: -20, duration: 200 }} - class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" - > - {#each categories as category} -
-
{category.label}
-
- {#each category.colors as color} -
{ - onChange(`var(--spectrum-global-color-static-${color})`) - }} - class="color" - style="background: var(--spectrum-global-color-static-{color}); color: {checkColor};" - title={prettyPrint(color)} - > - {#if value === `var(--spectrum-global-color-static-${color})`} - - {/if} -
- {/each} + class="preview" + style="background: {color};" + on:click={() => (open = true)} + /> + {#if open} +
(open = false)} + transition:fly={{ y: -20, duration: 200 }} + class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" + > + {#each categories as category} +
+
{category.label}
+
+ {#each category.colors as color} +
{ + onChange(`var(--spectrum-global-color-static-${color})`) + }} + class="color" + style="background: var(--spectrum-global-color-static-{color}); color: {checkColor};" + title={prettyPrint(color)} + > + {#if value === `var(--spectrum-global-color-static-${color})`} + + {/if} +
+ {/each} +
+
+ {/each} +
+
Custom
+
+ + onChange(null)} + />
- {/each} -
-
Custom
-
- - onChange(null)} /> -
-
-{/if} + {/if} +