Skip to content

Commit 5031694

Browse files
committed
Update Shadcn components
1 parent 5f6e5b7 commit 5031694

171 files changed

Lines changed: 798 additions & 611 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://shadcn-svelte.com/schema.json",
33
"tailwind": {
4-
"css": "src\\app.css",
4+
"css": "src/app.css",
55
"baseColor": "neutral"
66
},
77
"aliases": {

scripts/update-shadcn.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ for dep in "${UNWANTED_DEPS[@]}"; do
5555
pnpm remove "$dep"
5656
fi
5757
done
58-
pnpm up --latest
5958

6059
# Format to reduce diff noise
6160
echo "Formatting..."
@@ -67,15 +66,15 @@ echo "Applying custom modifications..."
6766
# Sidebar: ease-in-out and duration-300
6867
sed -i 's/duration-200 ease-linear/duration-300 ease-in-out/g' "$UI_DIR/sidebar/sidebar.svelte"
6968

70-
# Sidebar submenu: ml-* instead of mx-*
69+
# Sidebar submenu: ml-* instead of mx-*, pl-* instead of px-*
7170
sed -i 's/mx-3\.5\(.*\)px-2\.5/ml-3.5\1pl-2.5/g' "$UI_DIR/sidebar/sidebar-menu-sub.svelte"
7271

7372
# Sonner: use color-scheme-state instead of mode-watcher
7473
sed -i "s|import { mode } from \"mode-watcher\";|import { colorScheme } from '\$lib/state/color-scheme-state.svelte';|" "$UI_DIR/sonner/sonner.svelte"
7574
sed -i 's|theme={mode\.current}|theme={colorScheme.value}|' "$UI_DIR/sonner/sonner.svelte"
7675

7776
# Slider: add cursor-w-resize to thumb
78-
sed -i 's/focus-visible:outline-hidden disabled:pointer/focus-visible:outline-hidden cursor-w-resize disabled:pointer/' "$UI_DIR/slider/slider.svelte"
77+
sed -i 's/select-none disabled:pointer/cursor-w-resize select-none disabled:pointer/' "$UI_DIR/slider/slider.svelte"
7978

8079
# Toggle group: suppress state_referenced_locally warnings
8180
sed -i 's/\tsetToggleGroupCtx/\t\/\/ svelte-ignore state_referenced_locally\n\tsetToggleGroupCtx/' "$UI_DIR/toggle-group/toggle-group.svelte"

src/app.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,71 @@
182182
opacity: 0;
183183
}
184184
}
185+
186+
@custom-variant data-open {
187+
&:where([data-state='open']),
188+
&:where([data-open]:not([data-open='false'])) {
189+
@slot;
190+
}
191+
}
192+
193+
@custom-variant data-closed {
194+
&:where([data-state='closed']),
195+
&:where([data-closed]:not([data-closed='false'])) {
196+
@slot;
197+
}
198+
}
199+
200+
@custom-variant data-checked {
201+
&:where([data-state='checked']),
202+
&:where([data-checked]:not([data-checked='false'])) {
203+
@slot;
204+
}
205+
}
206+
207+
@custom-variant data-unchecked {
208+
&:where([data-state='unchecked']),
209+
&:where([data-unchecked]:not([data-unchecked='false'])) {
210+
@slot;
211+
}
212+
}
213+
214+
@custom-variant data-selected {
215+
&:where([data-selected]) {
216+
@slot;
217+
}
218+
}
219+
220+
@custom-variant data-disabled {
221+
&:where([data-disabled='true']),
222+
&:where([data-disabled]:not([data-disabled='false'])) {
223+
@slot;
224+
}
225+
}
226+
227+
@custom-variant data-active {
228+
&:where([data-state='active']),
229+
&:where([data-active]:not([data-active='false'])) {
230+
@slot;
231+
}
232+
}
233+
234+
@custom-variant data-horizontal {
235+
&:where([data-orientation='horizontal']) {
236+
@slot;
237+
}
238+
}
239+
240+
@custom-variant data-vertical {
241+
&:where([data-orientation='vertical']) {
242+
@slot;
243+
}
244+
}
245+
246+
@utility no-scrollbar {
247+
-ms-overflow-style: none;
248+
scrollbar-width: none;
249+
&::-webkit-scrollbar {
250+
display: none;
251+
}
252+
}

src/lib/components/ui/accordion/accordion-content.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
<AccordionPrimitive.Content
1414
bind:ref
1515
data-slot="accordion-content"
16-
class="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
16+
class="data-open:animate-accordion-down data-closed:animate-accordion-up text-sm overflow-hidden"
1717
{...restProps}
1818
>
19-
<div class={cn("pt-0 pb-4", className)}>
19+
<div
20+
class={cn(
21+
"pt-0 pb-2.5 [&_a]:hover:text-foreground [&_a]:underline [&_a]:underline-offset-3 [&_p:not(:last-child)]:mb-4",
22+
className
23+
)}
24+
>
2025
{@render children?.()}
2126
</div>
2227
</AccordionPrimitive.Content>

src/lib/components/ui/accordion/accordion-item.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
<AccordionPrimitive.Item
1313
bind:ref
1414
data-slot="accordion-item"
15-
class={cn("border-b last:border-b-0", className)}
15+
class={cn("not-last:border-b", className)}
1616
{...restProps}
1717
/>

src/lib/components/ui/accordion/accordion-trigger.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script lang="ts">
22
import { Accordion as AccordionPrimitive } from "bits-ui";
3-
import ChevronDownIcon from "@lucide/svelte/icons/chevron-down";
43
import { cn, type WithoutChild } from "$lib/utils/shadcn.js";
4+
import ChevronDownIcon from '@lucide/svelte/icons/chevron-down';
5+
import ChevronUpIcon from '@lucide/svelte/icons/chevron-up';
56
67
let {
78
ref = $bindable(null),
@@ -19,14 +20,13 @@
1920
data-slot="accordion-trigger"
2021
bind:ref
2122
class={cn(
22-
"focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-start text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
23+
"focus-visible:ring-ring/50 focus-visible:border-ring focus-visible:after:border-ring **:data-[slot=accordion-trigger-icon]:text-muted-foreground rounded-lg py-2.5 text-left text-sm font-medium hover:underline focus-visible:ring-3 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 group/accordion-trigger relative flex flex-1 items-start justify-between border border-transparent transition-all outline-none disabled:pointer-events-none disabled:opacity-50",
2324
className
2425
)}
2526
{...restProps}
2627
>
2728
{@render children?.()}
28-
<ChevronDownIcon
29-
class="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"
30-
/>
29+
<ChevronDownIcon data-slot="accordion-trigger-icon" class="cn-accordion-trigger-icon pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden" />
30+
<ChevronUpIcon data-slot="accordion-trigger-icon" class="cn-accordion-trigger-icon pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline" />
3131
</AccordionPrimitive.Trigger>
3232
</AccordionPrimitive.Header>

src/lib/components/ui/accordion/accordion.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<script lang="ts">
22
import { Accordion as AccordionPrimitive } from "bits-ui";
3+
import { cn } from "$lib/utils/shadcn.js";
34
45
let {
56
ref = $bindable(null),
67
value = $bindable(),
8+
class: className,
79
...restProps
810
}: AccordionPrimitive.RootProps = $props();
911
</script>
@@ -12,5 +14,6 @@
1214
bind:ref
1315
bind:value={value as never}
1416
data-slot="accordion"
17+
class={cn("cn-accordion flex w-full flex-col", className)}
1518
{...restProps}
1619
/>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script lang="ts">
2+
import type { HTMLAttributes } from "svelte/elements";
3+
import { cn, type WithElementRef } from "$lib/utils/shadcn.js";
4+
5+
let {
6+
ref = $bindable(null),
7+
class: className,
8+
children,
9+
...restProps
10+
}: WithElementRef<HTMLAttributes<HTMLSpanElement>> = $props();
11+
</script>
12+
13+
<span
14+
bind:this={ref}
15+
data-slot="avatar-badge"
16+
class={cn(
17+
"bg-primary text-primary-foreground ring-background absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-blend-color ring-2 select-none",
18+
"group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
19+
"group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
20+
"group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
21+
className
22+
)}
23+
{...restProps}
24+
>
25+
{@render children?.()}
26+
</span>

src/lib/components/ui/avatar/avatar-fallback.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<AvatarPrimitive.Fallback
1313
bind:ref
1414
data-slot="avatar-fallback"
15-
class={cn("bg-muted flex size-full items-center justify-center rounded-full", className)}
15+
class={cn(
16+
"bg-muted text-muted-foreground rounded-full flex size-full items-center justify-center text-sm group-data-[size=sm]/avatar:text-xs",
17+
className
18+
)}
1619
{...restProps}
1720
/>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script lang="ts">
2+
import type { HTMLAttributes } from "svelte/elements";
3+
import { cn, type WithElementRef } from "$lib/utils/shadcn.js";
4+
5+
let {
6+
ref = $bindable(null),
7+
class: className,
8+
children,
9+
...restProps
10+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11+
</script>
12+
13+
<div
14+
bind:this={ref}
15+
data-slot="avatar-group-count"
16+
class={cn(
17+
"bg-muted text-muted-foreground size-8 rounded-full text-sm group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3 ring-background relative flex shrink-0 items-center justify-center ring-2",
18+
className
19+
)}
20+
{...restProps}
21+
>
22+
{@render children?.()}
23+
</div>

0 commit comments

Comments
 (0)