Browse Source

Palette Drag, Debounce and Tidyup

gh-pages
cmack 6 years ago
parent
commit
67061ca592
  1. 6
      packages/builder/src/components/userInterface/Colorpicker/components/ButtonGroup.svelte
  2. 4
      packages/builder/src/components/userInterface/Colorpicker/components/Colorpicker.svelte
  3. 3
      packages/builder/src/components/userInterface/Colorpicker/components/Colorpreview.svelte

6
packages/builder/src/components/userInterface/Colorpicker/components/ButtonGroup.svelte

@ -1,8 +1,10 @@
<script> <script>
import FlatButton from "./FlatButton.svelte" import FlatButton from "./FlatButton.svelte"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
export let format = "hex" export let format = "hex"
export let onclick = format => {}
let colorFormats = ["hex", "rgb", "hsl"] let colorFormats = ["hex", "rgb", "hsl"]
</script> </script>
@ -12,7 +14,7 @@
<FlatButton <FlatButton
selected={format === text} selected={format === text}
{text} {text}
on:click={() => onclick(text)} /> on:click={() => dispatch('click', text)} />
{/each} {/each}
</div> </div>

4
packages/builder/src/components/userInterface/Colorpicker/components/Colorpicker.svelte

@ -120,7 +120,7 @@
} }
function changeFormatAndConvert(f) { function changeFormatAndConvert(f) {
format = f format = f.detail
value = convertHsvaToFormat([h, s, v, a], format) value = convertHsvaToFormat([h, s, v, a], format)
} }
@ -251,7 +251,7 @@
{/if} {/if}
<div class="format-input-panel"> <div class="format-input-panel">
<ButtonGroup {format} onclick={changeFormatAndConvert} /> <ButtonGroup {format} on:click={changeFormatAndConvert} />
<Input <Input
{value} {value}
on:input={event => handleColorInput(event.target.value)} on:input={event => handleColorInput(event.target.value)}

3
packages/builder/src/components/userInterface/Colorpicker/components/Colorpreview.svelte

@ -47,7 +47,8 @@
function onColorChange(color) { function onColorChange(color) {
value = color.detail value = color.detail
dispatch("change", color.detail) const fn = debounce(() => dispatch("change", color.detail), 300)
fn()
} }
function calculateDimensions() { function calculateDimensions() {

Loading…
Cancel
Save