From 520a909b01732a8aa2d2a907665cfcf2c0d05fbe Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Wed, 2 Jul 2025 09:51:32 -0700 Subject: [PATCH] add checkbox component --- src/app.css | 2 + src/app.html | 7 ++++ src/lib/Checkbox.svelte | 91 +++++++++++++++++++++++++++++++++++++++++ src/routes/+page.svelte | 33 ++++++++++++--- 4 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 src/lib/Checkbox.svelte diff --git a/src/app.css b/src/app.css index d7eaddb..aa70351 100644 --- a/src/app.css +++ b/src/app.css @@ -1 +1,3 @@ @import '$lib/styles/theme.css'; + +@custom-variant dark (&:where(.dark, .dark *)); diff --git a/src/app.html b/src/app.html index f22aeaa..1deb5b4 100644 --- a/src/app.html +++ b/src/app.html @@ -4,6 +4,13 @@ + + + + %sveltekit.head% diff --git a/src/lib/Checkbox.svelte b/src/lib/Checkbox.svelte new file mode 100644 index 0000000..a69bb3b --- /dev/null +++ b/src/lib/Checkbox.svelte @@ -0,0 +1,91 @@ + + + + +
+ { + if (required && value !== true) { + return false; + } + return true; + } + }} + onvalidate={(e) => { + valid = e.detail.valid; + }} + /> + + + + {#if children} + + {/if} +
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ec52a66..b1eea1f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,5 +1,6 @@ @@ -12,14 +13,18 @@

Component Library

-

Button

-
- - +
+

Button

+
+ + +
-

Combobox

+

Combobox

+
+

Checkbox

+ + console.log('Checkbox value:', value)} + > + Agree to terms and conditions + +
+