@invopop/popui 0.0.101 → 0.0.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/InputToggle.svelte
CHANGED
|
@@ -5,18 +5,24 @@ import { dispatchWcEvent } from "./wcdispatch.js";
|
|
|
5
5
|
const dispatch = createEventDispatcher();
|
|
6
6
|
const sw = createSwitch({ label: "Set Preference" });
|
|
7
7
|
let rootEl;
|
|
8
|
+
export let id = Math.random().toString(36).slice(2, 7);
|
|
8
9
|
export let checked = false;
|
|
10
|
+
export let label = "";
|
|
9
11
|
$:
|
|
10
12
|
$sw.checked = checked;
|
|
11
13
|
$:
|
|
12
14
|
togleStyles = clsx({ "bg-gray-200": !$sw.checked }, { "bg-workspace-accent": $sw.checked });
|
|
13
15
|
function handleChange() {
|
|
16
|
+
checked = $sw.checked;
|
|
14
17
|
dispatch("change", $sw.checked);
|
|
15
18
|
dispatchWcEvent(rootEl, "change", $sw.checked);
|
|
16
19
|
}
|
|
17
20
|
</script>
|
|
18
21
|
|
|
19
|
-
<
|
|
22
|
+
<label bind:this={rootEl} class="flex w-full items-center justify-between space-x-2">
|
|
23
|
+
{#if label}
|
|
24
|
+
<span class="text-base text-neutral-500">{label}</span>
|
|
25
|
+
{/if}
|
|
20
26
|
<button
|
|
21
27
|
class="{togleStyles} relative inline-flex h-5 w-8 flex-shrink-0 cursor-pointer rounded-md border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-0 focus:ring-offset-0"
|
|
22
28
|
use:sw.toggle
|
|
@@ -30,4 +36,4 @@ function handleChange() {
|
|
|
30
36
|
: 'translate-x-0'} pointer-events-none inline-block h-4 w-4 transform rounded bg-white shadow ring-0 transition duration-200 ease-in-out"
|
|
31
37
|
/>
|
|
32
38
|
</button>
|
|
33
|
-
</
|
|
39
|
+
</label>
|