Skip to content

Commit

Permalink
change: kind prop to type in toggle group (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Nov 14, 2023
1 parent fcfcacb commit b9182d7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-carrots-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

change: `kind` prop to `type` in toggle group
3 changes: 1 addition & 2 deletions src/components/demos/toggle-group-demo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import { toggleVariants } from "@/components/ui/toggle";
let value: string[] | undefined = undefined;
$: console.log(value);
</script>

<ToggleGroup.Root bind:value kind="multiple">
<ToggleGroup.Root bind:value type="multiple">
<ToggleGroup.Item
class={toggleVariants({ variant: "default" })}
aria-label="toggle bold"
Expand Down
6 changes: 3 additions & 3 deletions src/lib/bits/toggle-group/components/ToggleGroup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type T = $$Generic<"single" | "multiple">;
type $$Props = Props<T>;
export let kind: $$Props["kind"] = "single" as T;
export let type: $$Props["type"] = "single" as T;
export let disabled: $$Props["disabled"] = undefined;
export let loop: $$Props["loop"] = undefined;
export let value: $$Props["value"] = undefined;
Expand All @@ -20,7 +20,7 @@
updateOption
} = setCtx<T>({
disabled,
type: kind,
type,
defaultValue: value,
loop,
orientation,
Expand All @@ -43,7 +43,7 @@
$: value !== undefined && localValue.set(value);
$: updateOption("disabled", disabled);
$: updateOption("loop", loop);
$: updateOption("type", kind);
$: updateOption("type", type);
$: updateOption("orientation", orientation);
$: builder = $root;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bits/toggle-group/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import type { HTMLButtonAttributes } from "svelte/elements";
import type { CustomEventHandler } from "$lib/index.js";

type Props<T extends "single" | "multiple"> = Expand<
OmitValue<CreateToggleGroupProps> & {
OmitValue<CreateToggleGroupProps<T>> & {
value?: CreateToggleGroupProps<T>["defaultValue"];
onValueChange?: OnChangeFn<CreateToggleGroupProps<T>["defaultValue"]>;
kind?: T;
type?: T;
}
> &
AsChild &
Expand Down
2 changes: 1 addition & 1 deletion src/tests/toggle-group/ToggleGroupMultipleTest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<main>
<button data-testid="binding" on:click={() => (value = ["4"])}>{value}</button>
<ToggleGroup.Root data-testid="root" bind:value {...$$restProps} kind="multiple">
<ToggleGroup.Root data-testid="root" bind:value {...$$restProps} type="multiple">
{#each items as { value, disabled }}
<ToggleGroup.Item {value} {disabled} data-testid="item-{value}">
{value}
Expand Down

0 comments on commit b9182d7

Please sign in to comment.