From 25cfd691f95ed0d5bcf1b155652dab9030fae673 Mon Sep 17 00:00:00 2001 From: Davis SHYAKA <87414827+davis-shyaka@users.noreply.github.com> Date: Sat, 5 Oct 2024 11:19:18 +0200 Subject: [PATCH] choicebox draft --- package.json | 2 +- pnpm-lock.yaml | 10 +-- .../ui/choicebox/choicebox-checkbox.svelte | 70 ++++++++++++++++++ .../ui/choicebox/choicebox-radio.svelte | 73 +++++++++++++++++++ .../components/ui/choicebox/choicebox.svelte | 57 +++++++++++++++ src/lib/components/ui/choicebox/index.ts | 12 +++ src/lib/components/ui/radio/radio-item.svelte | 1 - src/lib/config/sitemap.ts | 2 +- src/routes/choicebox/+page.svelte | 27 ++++++- src/routes/choicebox/+page.ts | 22 ++++++ src/routes/choicebox/disabled.svelte | 26 +++++++ src/routes/choicebox/multi-select.svelte | 8 ++ src/routes/choicebox/single-select.svelte | 8 ++ 13 files changed, 309 insertions(+), 9 deletions(-) create mode 100644 src/lib/components/ui/choicebox/choicebox-checkbox.svelte create mode 100644 src/lib/components/ui/choicebox/choicebox-radio.svelte create mode 100644 src/lib/components/ui/choicebox/choicebox.svelte create mode 100644 src/lib/components/ui/choicebox/index.ts create mode 100644 src/routes/choicebox/+page.ts create mode 100644 src/routes/choicebox/disabled.svelte create mode 100644 src/routes/choicebox/multi-select.svelte create mode 100644 src/routes/choicebox/single-select.svelte diff --git a/package.json b/package.json index 5c07ae0..0565fc3 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "type": "module", "dependencies": { - "bits-ui": "1.0.0-next.8", + "bits-ui": "1.0.0-next.9", "clsx": "^2.1.1", "runed": "^0.15.3", "tailwind-merge": "^2.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d14a7fd..6ea5b04 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: bits-ui: - specifier: 1.0.0-next.8 - version: 1.0.0-next.8(svelte@5.0.0-next.260) + specifier: 1.0.0-next.9 + version: 1.0.0-next.9(svelte@5.0.0-next.260) clsx: specifier: ^2.1.1 version: 2.1.1 @@ -541,8 +541,8 @@ packages: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} - bits-ui@1.0.0-next.8: - resolution: {integrity: sha512-3/uViRov9U3joTXBfUVZL+mvOfJTxAszj1kbt2uFqO3jZHbXurL0ZytM8Fxd3kcUzR981FX70vVDQfSSg70K5Q==} + bits-ui@1.0.0-next.9: + resolution: {integrity: sha512-ZFg7PVCY8rf29Mk0pPJ/uRMY6Iz+SJIIsXSw/f5RLTwvv1JHQwDgPoxc4ow26I94X6STNK38l6g3PcN95/f/ig==} engines: {node: '>=18', pnpm: '>=8.7.0'} peerDependencies: svelte: ^5.0.0-next.1 @@ -1872,7 +1872,7 @@ snapshots: binary-extensions@2.3.0: {} - bits-ui@1.0.0-next.8(svelte@5.0.0-next.260): + bits-ui@1.0.0-next.9(svelte@5.0.0-next.260): dependencies: '@floating-ui/core': 1.6.8 '@floating-ui/dom': 1.6.11 diff --git a/src/lib/components/ui/choicebox/choicebox-checkbox.svelte b/src/lib/components/ui/choicebox/choicebox-checkbox.svelte new file mode 100644 index 0000000..10cf46f --- /dev/null +++ b/src/lib/components/ui/choicebox/choicebox-checkbox.svelte @@ -0,0 +1,70 @@ + + + diff --git a/src/lib/components/ui/choicebox/choicebox-radio.svelte b/src/lib/components/ui/choicebox/choicebox-radio.svelte new file mode 100644 index 0000000..259b6b1 --- /dev/null +++ b/src/lib/components/ui/choicebox/choicebox-radio.svelte @@ -0,0 +1,73 @@ + + + + + + diff --git a/src/lib/components/ui/choicebox/choicebox.svelte b/src/lib/components/ui/choicebox/choicebox.svelte new file mode 100644 index 0000000..28646d9 --- /dev/null +++ b/src/lib/components/ui/choicebox/choicebox.svelte @@ -0,0 +1,57 @@ + + +
+ {#if label} + {label} + {/if} + {#if type === 'radio'} + + {@render children?.()} + + {:else if type === 'checkbox'} +
+ {@render children?.()} +
+ {/if} +
diff --git a/src/lib/components/ui/choicebox/index.ts b/src/lib/components/ui/choicebox/index.ts new file mode 100644 index 0000000..960d5c2 --- /dev/null +++ b/src/lib/components/ui/choicebox/index.ts @@ -0,0 +1,12 @@ +import Checkbox from './choicebox-checkbox.svelte'; +import Radio from './choicebox-radio.svelte'; +import Root from './choicebox.svelte'; + +export { + Checkbox, + Checkbox as ChoiceboxCheckbox, + Root as ChoiceboxGroup, + Radio as ChoiceboxGroupRadio, + Radio, + Root +}; diff --git a/src/lib/components/ui/radio/radio-item.svelte b/src/lib/components/ui/radio/radio-item.svelte index 30337d9..d529754 100644 --- a/src/lib/components/ui/radio/radio-item.svelte +++ b/src/lib/components/ui/radio/radio-item.svelte @@ -20,7 +20,6 @@ class_name )} {...rest} - on:click > {#snippet children({ checked })}
diff --git a/src/lib/config/sitemap.ts b/src/lib/config/sitemap.ts index 0852ce8..3ca07d4 100644 --- a/src/lib/config/sitemap.ts +++ b/src/lib/config/sitemap.ts @@ -79,7 +79,7 @@ export const aside_items: Aside = { { title: 'Choicebox', href: '/choicebox', - status: 'soon' + status: 'draft' }, { title: 'Code Block', diff --git a/src/routes/choicebox/+page.svelte b/src/routes/choicebox/+page.svelte index c3039ed..4719e9a 100644 --- a/src/routes/choicebox/+page.svelte +++ b/src/routes/choicebox/+page.svelte @@ -1 +1,26 @@ -

choicebox

+ + + + + + + + + + + + + + + diff --git a/src/routes/choicebox/+page.ts b/src/routes/choicebox/+page.ts new file mode 100644 index 0000000..cce9388 --- /dev/null +++ b/src/routes/choicebox/+page.ts @@ -0,0 +1,22 @@ +import type { MetaTagsProps } from 'svelte-meta-tags'; + +export function load() { + const title = 'Choicebox'; + const description = + 'A larger form of Radio or Checkbox, where the user has a larger tap target and more details.'; + + const pageMetaTags = Object.freeze({ + title, + description, + openGraph: { + title, + description + } + }) satisfies MetaTagsProps; + + return { + pageMetaTags, + title, + description + }; +} diff --git a/src/routes/choicebox/disabled.svelte b/src/routes/choicebox/disabled.svelte new file mode 100644 index 0000000..9e68184 --- /dev/null +++ b/src/routes/choicebox/disabled.svelte @@ -0,0 +1,26 @@ + + +
+ + + + + + + + + +
diff --git a/src/routes/choicebox/multi-select.svelte b/src/routes/choicebox/multi-select.svelte new file mode 100644 index 0000000..9a93f10 --- /dev/null +++ b/src/routes/choicebox/multi-select.svelte @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/routes/choicebox/single-select.svelte b/src/routes/choicebox/single-select.svelte new file mode 100644 index 0000000..5dc9760 --- /dev/null +++ b/src/routes/choicebox/single-select.svelte @@ -0,0 +1,8 @@ + + + + + +