From 4b4e07747cc3650258d400a5e73c9f597459556c Mon Sep 17 00:00:00 2001 From: hhvrc Date: Mon, 11 Nov 2024 11:17:47 +0100 Subject: [PATCH] Update shadcn-svelte components --- .../dropdown-menu-checkbox-item.svelte | 15 +++++--- .../ui/menubar/menubar-checkbox-item.svelte | 15 +++++--- src/lib/components/ui/menubar/menubar.svelte | 2 +- src/lib/components/ui/sonner/sonner.svelte | 29 +++++++------- .../components/ui/table/table-footer.svelte | 6 +-- src/lib/hooks/is-mobile.svelte.ts | 38 +++++++++---------- 6 files changed, 55 insertions(+), 50 deletions(-) diff --git a/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte b/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte index f5f9db4..20e3777 100644 --- a/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +++ b/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte @@ -1,35 +1,40 @@ - {#snippet children({ checked })} + {#snippet children({ checked, indeterminate })} - {#if checked === "indeterminate"} + {#if indeterminate} {:else} {/if} - {@render childrenProp?.({ checked })} + {@render childrenProp?.()} {/snippet} diff --git a/src/lib/components/ui/menubar/menubar-checkbox-item.svelte b/src/lib/components/ui/menubar/menubar-checkbox-item.svelte index e63c028..9f7646a 100644 --- a/src/lib/components/ui/menubar/menubar-checkbox-item.svelte +++ b/src/lib/components/ui/menubar/menubar-checkbox-item.svelte @@ -1,35 +1,40 @@ - {#snippet children({ checked })} + {#snippet children({ checked, indeterminate })} - {#if checked === "indeterminate"} + {#if indeterminate} {:else} {/if} - {@render childrenProp?.({ checked })} + {@render childrenProp?.()} {/snippet} diff --git a/src/lib/components/ui/menubar/menubar.svelte b/src/lib/components/ui/menubar/menubar.svelte index 3f63eef..55c34c6 100644 --- a/src/lib/components/ui/menubar/menubar.svelte +++ b/src/lib/components/ui/menubar/menubar.svelte @@ -11,6 +11,6 @@ diff --git a/src/lib/components/ui/sonner/sonner.svelte b/src/lib/components/ui/sonner/sonner.svelte index 92bf36e..c2f965c 100644 --- a/src/lib/components/ui/sonner/sonner.svelte +++ b/src/lib/components/ui/sonner/sonner.svelte @@ -1,21 +1,20 @@ diff --git a/src/lib/components/ui/table/table-footer.svelte b/src/lib/components/ui/table/table-footer.svelte index 68266ce..0267c47 100644 --- a/src/lib/components/ui/table/table-footer.svelte +++ b/src/lib/components/ui/table/table-footer.svelte @@ -11,10 +11,6 @@ }: WithElementRef> = $props(); - + {@render children?.()} diff --git a/src/lib/hooks/is-mobile.svelte.ts b/src/lib/hooks/is-mobile.svelte.ts index df3778d..87bea4b 100644 --- a/src/lib/hooks/is-mobile.svelte.ts +++ b/src/lib/hooks/is-mobile.svelte.ts @@ -3,25 +3,25 @@ import { untrack } from "svelte"; const MOBILE_BREAKPOINT = 768; export class IsMobile { - #current = $state(false); + #current = $state(false); - constructor() { - $effect(() => { - return untrack(() => { - const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`); - const onChange = () => { - this.#current = window.innerWidth < MOBILE_BREAKPOINT; - }; - mql.addEventListener("change", onChange); - onChange(); - return () => { - mql.removeEventListener("change", onChange); - }; - }); - }); - } + constructor() { + $effect(() => { + return untrack(() => { + const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`); + const onChange = () => { + this.#current = window.innerWidth < MOBILE_BREAKPOINT; + }; + mql.addEventListener("change", onChange); + onChange(); + return () => { + mql.removeEventListener("change", onChange); + }; + }); + }); + } - get current() { - return this.#current; - } + get current() { + return this.#current; + } }