1
0
Fork 0
mirror of synced 2024-10-01 01:28:51 +13:00

Palette Drag, Debounce and Tidyup

This commit is contained in:
cmack 2020-07-10 11:40:53 +01:00
parent 39ee12c390
commit 4d11f9c25c
3 changed files with 8 additions and 5 deletions

View file

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

View file

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

View file

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