Skip to content

Commit

Permalink
docs: fix checkbox form examples (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Feb 21, 2024
1 parent c11d65b commit 2e50bfd
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 103 deletions.
10 changes: 0 additions & 10 deletions .editorconfig

This file was deleted.

38 changes: 0 additions & 38 deletions .eslintrc.cjs

This file was deleted.

19 changes: 0 additions & 19 deletions .prettierignore

This file was deleted.

8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

10 changes: 5 additions & 5 deletions apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test:unit": "vitest",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write .",
"format:check": "prettier --plugin-search-dir . --check ."
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"devDependencies": {
"@faker-js/faker": "^8.0.2",
Expand Down Expand Up @@ -53,8 +53,8 @@
"postcss": "^8.4.31",
"postcss-load-config": "^4.0.1",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"prettier-plugin-tailwindcss": "^0.5.9",
"prettier-plugin-svelte": "^3.2.1",
"prettier-plugin-tailwindcss": "^0.5.11",
"rehype-pretty-code": "^0.13.0",
"rehype-slug": "^6.0.0",
"remark-code-import": "^1.2.0",
Expand Down
18 changes: 9 additions & 9 deletions apps/www/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@
{@const checked = $formData.items.includes(item.id)}
<div class="flex flex-row items-start space-x-3">
<Form.Control let:attrs>
<!-- We pull out the name so it doesn't get used on the `Checkbox` underlying checkbox hidden input -->
{@const { name, ...rest } = attrs}
<Checkbox
{...rest}
{...attrs}
{checked}
onCheckedChange={(v) => {
if (v) {
Expand All @@ -98,8 +96,7 @@
<Form.Label class="font-normal">
{item.label}
</Form.Label>
<!-- Custom input since we are not using the standard `boolean` value -->
<input hidden type="checkbox" {name} value={item.id} {checked} />
<input hidden type="checkbox" name={attrs.name} value={item.id} {checked} />
</Form.Control>
</div>
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
> page.
</Form.Description>
</div>
<input name={attrs.name} value={$formData.mobile} hidden />
</Form.Control>
</Form.Field>
<Form.Button>Submit</Form.Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@
{@const checked = $formData.items.includes(item.id)}
<div class="flex flex-row items-start space-x-3">
<Form.Control let:attrs>
<!-- We pull out the name so it doesn't get used on the `Checkbox` underlying checkbox hidden input -->
{@const { name, ...rest } = attrs}
<Checkbox
{...rest}
{...attrs}
{checked}
onCheckedChange={(v) => {
if (v) {
Expand All @@ -97,8 +95,7 @@
<Form.Label class="text-sm font-normal">
{item.label}
</Form.Label>
<!-- Custom input since we are not using the standard `boolean` value -->
<input hidden type="checkbox" {name} value={item.id} {checked} />
<input hidden type="checkbox" name={attrs.name} value={item.id} {checked} />
</Form.Control>
</div>
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
> page.
</Form.Description>
</div>
<input name={attrs.name} value={$formData.mobile} hidden />
</Form.Control>
</Form.Field>
<Form.Button>Submit</Form.Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"Select a language"}
<CaretSort class="ml-2 size-4 shrink-0 opacity-50" />
</Popover.Trigger>
<input hidden bind:value={$formData.language} name={attrs.name} />
<input hidden value={$formData.language} name={attrs.name} />
</Form.Control>
<Popover.Content class="w-[200px] p-0">
<Command.Root>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import SuperDebug, { type SuperValidated, type Infer, superForm } from "sveltekit-superforms";
import * as Form from "@/registry/new-york/ui/form";
import * as RadioGroup from "@/registry/new-york/ui/radio-group";
import Label from "@/registry/new-york/ui/label/label.svelte";
import { Label } from "@/registry/new-york/ui/label";
import { zodClient } from "sveltekit-superforms/adapters";
import { cn } from "$lib/utils";
import { buttonVariants } from "@/registry/new-york/ui/button";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import * as RadioGroup from "@/registry/new-york/ui/radio-group";
import { Switch } from "@/registry/new-york/ui/switch";
import { zodClient } from "sveltekit-superforms/adapters";
import Checkbox from "@/registry/new-york/ui/checkbox/checkbox.svelte";
import { Checkbox } from "@/registry/new-york/ui/checkbox";
import { browser } from "$app/environment";
export let data: SuperValidated<Infer<NotificationFormSchema>>;
Expand Down Expand Up @@ -134,7 +134,7 @@
> page.
</Form.Description>
</div>
<input name={attrs.name} bind:value={$formData.mobile} hidden />
<input name={attrs.name} value={$formData.mobile} hidden />
</Form.Control>
</Form.Field>
<Form.Button>Update notifications</Form.Button>
Expand Down

0 comments on commit 2e50bfd

Please sign in to comment.