Ron Au commited on
Commit
153471c
·
1 Parent(s): ca5bd83

feat(ui): Connect inputs to stores

Browse files
source/ui/src/lib/DensityOptions.svelte CHANGED
@@ -1,29 +1,30 @@
1
  <script lang="ts">
 
2
  import Radio from './Radio.svelte';
 
3
  const options = ['Low', 'Medium', 'High'];
4
- const type: string = 'density';
5
  </script>
6
 
7
  <div>
8
- <fieldset>
9
- <legend>Note density</legend>
10
- <Radio {options} {type} />
11
- </fieldset>
12
  </div>
13
 
14
  <style>
15
  fieldset {
16
- padding: 0;
17
- border: none;
18
- margin-top: 1rem;
19
  }
20
 
21
  legend {
22
- text-align: center;
23
- font-size: 1.25rem;
24
- font-weight: 700;
25
- padding: 0;
26
- margin-bottom: 1rem;
27
-
28
  }
29
  </style>
 
1
  <script lang="ts">
2
+ import { density } from './stores';
3
  import Radio from './Radio.svelte';
4
+
5
  const options = ['Low', 'Medium', 'High'];
6
+ const type = 'density';
7
  </script>
8
 
9
  <div>
10
+ <fieldset>
11
+ <legend>Note density</legend>
12
+ <Radio bind:selection={$density} {options} {type} />
13
+ </fieldset>
14
  </div>
15
 
16
  <style>
17
  fieldset {
18
+ padding: 0;
19
+ border: none;
20
+ margin-top: 1rem;
21
  }
22
 
23
  legend {
24
+ text-align: center;
25
+ font-size: 1.25rem;
26
+ font-weight: 700;
27
+ padding: 0;
28
+ margin-bottom: 1rem;
 
29
  }
30
  </style>
source/ui/src/lib/Radio.svelte CHANGED
@@ -1,7 +1,7 @@
1
  <script lang="ts">
2
  export let options: string[];
3
  export let type: string;
4
- let selection: string = options[1];
5
  </script>
6
 
7
  <div class="options">
 
1
  <script lang="ts">
2
  export let options: string[];
3
  export let type: string;
4
+ export let selection: string = options[1];
5
  </script>
6
 
7
  <div class="options">
source/ui/src/lib/StyleOptions.svelte CHANGED
@@ -1,21 +1,19 @@
1
  <script lang="ts">
 
2
  import stylesConfig from '../config/styles.json';
3
- import StyleOptionsButton from './StyleOptionsButton.svelte';
4
 
5
  const keys: string[] = Object.keys(stylesConfig);
6
-
7
- let selection: string = 'synth';
8
  </script>
9
 
10
  <fieldset>
11
- <legend>{stylesConfig[selection] || 'Synthesizer'}</legend>
12
  <div class="grid">
13
  {#each keys as key, i}
14
- <label data-selected={selection === key}>
15
  <div>
16
  <img src={`${key}.svg`} alt={stylesConfig[key]} />
17
  </div>
18
- <input type="radio" bind:group={selection} value={key} />
19
  </label>
20
  {/each}
21
  </div>
 
1
  <script lang="ts">
2
+ import { style } from './stores';
3
  import stylesConfig from '../config/styles.json';
 
4
 
5
  const keys: string[] = Object.keys(stylesConfig);
 
 
6
  </script>
7
 
8
  <fieldset>
9
+ <legend>{stylesConfig[$style] || 'Synthesizer'}</legend>
10
  <div class="grid">
11
  {#each keys as key, i}
12
+ <label data-selected={$style === key}>
13
  <div>
14
  <img src={`${key}.svg`} alt={stylesConfig[key]} />
15
  </div>
16
+ <input type="radio" bind:group={$style} value={key} />
17
  </label>
18
  {/each}
19
  </div>
source/ui/src/lib/TemperatureOptions.svelte CHANGED
@@ -1,28 +1,30 @@
1
  <script lang="ts">
 
2
  import Radio from './Radio.svelte';
3
- const options: string[] = ['Low', 'Medium', 'High', 'Very High'];
4
- const type: string = 'temperature';
 
5
  </script>
6
 
7
  <div>
8
- <fieldset>
9
- <legend>Temperature</legend>
10
- <Radio {options} {type} />
11
- </fieldset>
12
  </div>
13
 
14
  <style>
15
  fieldset {
16
- padding: 0;
17
- border: none;
18
- margin-top: 1rem;
19
  }
20
 
21
  legend {
22
- text-align: center;
23
- font-size: 1.25rem;
24
- font-weight: 700;
25
- padding: 0;
26
- margin-bottom: 1rem;
27
  }
28
  </style>
 
1
  <script lang="ts">
2
+ import { temperature } from './stores';
3
  import Radio from './Radio.svelte';
4
+
5
+ const options = ['Low', 'Medium', 'High', 'Very High'];
6
+ const type = 'temperature';
7
  </script>
8
 
9
  <div>
10
+ <fieldset>
11
+ <legend>Temperature</legend>
12
+ <Radio bind:selection={$temperature} {options} {type} />
13
+ </fieldset>
14
  </div>
15
 
16
  <style>
17
  fieldset {
18
+ padding: 0;
19
+ border: none;
20
+ margin-top: 1rem;
21
  }
22
 
23
  legend {
24
+ text-align: center;
25
+ font-size: 1.25rem;
26
+ font-weight: 700;
27
+ padding: 0;
28
+ margin-bottom: 1rem;
29
  }
30
  </style>
source/ui/src/lib/stores.ts CHANGED
@@ -4,3 +4,6 @@ import type { Writable } from 'svelte/store';
4
 
5
  export const loading: Writable<boolean> = writable(false);
6
  export const playing: Writable<boolean> = writable(true);
 
 
 
 
4
 
5
  export const loading: Writable<boolean> = writable(false);
6
  export const playing: Writable<boolean> = writable(true);
7
+ export const style: Writable<string> = writable('synth');
8
+ export const density: Writable<string> = writable('Medium');
9
+ export const temperature: Writable<string> = writable('Medium');