Skip to content

Commit 4b4e077

Browse files
committed
Update shadcn-svelte components
1 parent 25b4c8b commit 4b4e077

File tree

6 files changed

+55
-50
lines changed

6 files changed

+55
-50
lines changed
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
<script lang="ts">
2-
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChild } from "bits-ui";
2+
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChildrenOrChild } from "bits-ui";
33
import Check from "lucide-svelte/icons/check";
44
import Minus from "lucide-svelte/icons/minus";
55
import { cn } from "$lib/utils.js";
6+
import type { Snippet } from "svelte";
67
78
let {
89
ref = $bindable(null),
910
checked = $bindable(false),
11+
indeterminate = $bindable(false),
1012
class: className,
1113
children: childrenProp,
1214
...restProps
13-
}: WithoutChild<DropdownMenuPrimitive.CheckboxItemProps> = $props();
15+
}: WithoutChildrenOrChild<DropdownMenuPrimitive.CheckboxItemProps> & {
16+
children?: Snippet;
17+
} = $props();
1418
</script>
1519

1620
<DropdownMenuPrimitive.CheckboxItem
1721
bind:ref
1822
bind:checked
23+
bind:indeterminate
1924
class={cn(
2025
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
2126
className
2227
)}
2328
{...restProps}
2429
>
25-
{#snippet children({ checked })}
30+
{#snippet children({ checked, indeterminate })}
2631
<span class="absolute left-2 flex size-3.5 items-center justify-center">
27-
{#if checked === "indeterminate"}
32+
{#if indeterminate}
2833
<Minus class="size-4" />
2934
{:else}
3035
<Check class={cn("size-4", !checked && "text-transparent")} />
3136
{/if}
3237
</span>
33-
{@render childrenProp?.({ checked })}
38+
{@render childrenProp?.()}
3439
{/snippet}
3540
</DropdownMenuPrimitive.CheckboxItem>
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
<script lang="ts">
2-
import { Menubar as MenubarPrimitive, type WithoutChild } from "bits-ui";
2+
import { Menubar as MenubarPrimitive, type WithoutChildrenOrChild } from "bits-ui";
33
import Check from "lucide-svelte/icons/check";
44
import Minus from "lucide-svelte/icons/minus";
55
import { cn } from "$lib/utils.js";
6+
import type { Snippet } from "svelte";
67
78
let {
89
ref = $bindable(null),
910
class: className,
1011
checked = $bindable(false),
12+
indeterminate = $bindable(false),
1113
children: childrenProp,
1214
...restProps
13-
}: WithoutChild<MenubarPrimitive.CheckboxItemProps> = $props();
15+
}: WithoutChildrenOrChild<MenubarPrimitive.CheckboxItemProps> & {
16+
children?: Snippet;
17+
} = $props();
1418
</script>
1519

1620
<MenubarPrimitive.CheckboxItem
1721
bind:ref
1822
bind:checked
23+
bind:indeterminate
1924
class={cn(
2025
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
2126
className
2227
)}
2328
{...restProps}
2429
>
25-
{#snippet children({ checked })}
30+
{#snippet children({ checked, indeterminate })}
2631
<span class="absolute left-2 flex size-3.5 items-center justify-center">
27-
{#if checked === "indeterminate"}
32+
{#if indeterminate}
2833
<Minus class="size-4" />
2934
{:else}
3035
<Check class={cn("size-4", !checked && "text-transparent")} />
3136
{/if}
3237
</span>
33-
{@render childrenProp?.({ checked })}
38+
{@render childrenProp?.()}
3439
{/snippet}
3540
</MenubarPrimitive.CheckboxItem>

src/lib/components/ui/menubar/menubar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
<MenubarPrimitive.Root
1313
bind:ref
14-
class={cn("bg-background flex h-16 items-center space-x-1 rounded-md border p-1", className)}
14+
class={cn("bg-background flex h-10 items-center space-x-1 rounded-md border p-1", className)}
1515
{...restProps}
1616
/>
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<script lang="ts">
2-
import { Toaster as Sonner, type ToasterProps as SonnerProps } from 'svelte-sonner';
3-
import { ColorSchemeStore } from '$lib/stores/ColorSchemeStore';
2+
import { Toaster as Sonner, type ToasterProps as SonnerProps } from "svelte-sonner";
3+
import { ColorSchemeStore } from '$lib/stores/ColorSchemeStore';
44
5-
let restProps: SonnerProps = $props();
5+
let restProps: SonnerProps = $props();
66
</script>
77

88
<Sonner
9-
theme={$ColorSchemeStore}
10-
class="toaster group"
11-
toastOptions={{
12-
classes: {
13-
toast:
14-
'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
15-
description: 'group-[.toast]:text-muted-foreground',
16-
actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
17-
cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
18-
},
19-
}}
20-
{...restProps}
9+
theme={$ColorSchemeStore}
10+
class="toaster group"
11+
toastOptions={{
12+
classes: {
13+
toast: "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
14+
description: "group-[.toast]:text-muted-foreground",
15+
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
16+
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
17+
},
18+
}}
19+
{...restProps}
2120
/>

src/lib/components/ui/table/table-footer.svelte

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
}: WithElementRef<HTMLAttributes<HTMLTableSectionElement>> = $props();
1212
</script>
1313

14-
<tfoot
15-
bind:this={ref}
16-
class={cn("bg-muted/50 text-primary-foreground font-medium", className)}
17-
{...restProps}
18-
>
14+
<tfoot bind:this={ref} class={cn("bg-muted/50 font-medium", className)} {...restProps}>
1915
{@render children?.()}
2016
</tfoot>

src/lib/hooks/is-mobile.svelte.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ import { untrack } from "svelte";
33
const MOBILE_BREAKPOINT = 768;
44

55
export class IsMobile {
6-
#current = $state<boolean>(false);
6+
#current = $state<boolean>(false);
77

8-
constructor() {
9-
$effect(() => {
10-
return untrack(() => {
11-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
12-
const onChange = () => {
13-
this.#current = window.innerWidth < MOBILE_BREAKPOINT;
14-
};
15-
mql.addEventListener("change", onChange);
16-
onChange();
17-
return () => {
18-
mql.removeEventListener("change", onChange);
19-
};
20-
});
21-
});
22-
}
8+
constructor() {
9+
$effect(() => {
10+
return untrack(() => {
11+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
12+
const onChange = () => {
13+
this.#current = window.innerWidth < MOBILE_BREAKPOINT;
14+
};
15+
mql.addEventListener("change", onChange);
16+
onChange();
17+
return () => {
18+
mql.removeEventListener("change", onChange);
19+
};
20+
});
21+
});
22+
}
2323

24-
get current() {
25-
return this.#current;
26-
}
24+
get current() {
25+
return this.#current;
26+
}
2727
}

0 commit comments

Comments
 (0)