aboutsummaryrefslogtreecommitdiff
path: root/fe/src/lib/PreferencesForm.svelte
blob: 95e04c10d7a21ae9973a5995c3d3506b7972d3b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script lang="ts">
    import { preferences } from '../stores/auth';
    import type { Size, Preference } from '../types';
    import { createEventDispatcher } from 'svelte';
   export let open: boolean; 

    let preference: Preference = {
        color: "#00FF00",
        size: {
            size: 8,
            unit: 'oz'
        }
    }

    const dispatch = createEventDispatcher();
    
    preferences.subscribe((value) => {
        preference = value;
    });

    function onPreferencesSave(): void {
        preferences.set(preference);
        dispatch('close')
    }

</script>
<dialog {open} on:submit|preventDefault={onPreferencesSave}>
    <h2>User Preferences</h2>
    <form method="dialog">
        <div class="form input group">
            <label for="color">Color</label>
            <input id="color" name="color" type="color" bind:value={preference.color}/>
        </div>
        <div class="form input group">
            <label for="size">Bottle Size</label>
            <input id="size" name="size" type="number" min="8" max="48" step="8" bind:value={preference.size.size}/>
        </div>
        <button type="submit">Save</button>
    </form>
</dialog>
<style>
dialog {
    background: white;
    color: black;
}

input[type="color"] {
   width: 100%;
   height: 100%;
}
</style>