Skip to content

Commit e9bb74e

Browse files
committed
[playground] Update shadcn components
1 parent 5641c3a commit e9bb74e

26 files changed

+495
-17
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script lang="ts">
2+
import { cn } from "$lib/utils.js";
3+
import type { ComponentProps } from "svelte";
4+
import { Separator } from "$lib/components/ui/separator/index.js";
5+
6+
let {
7+
class: className,
8+
orientation = "vertical",
9+
...restProps
10+
}: ComponentProps<typeof Separator> = $props();
11+
</script>
12+
13+
<Separator
14+
data-slot="button-group-separator"
15+
{orientation}
16+
class={cn("bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto", className)}
17+
{...restProps}
18+
/>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script lang="ts">
2+
import { cn } from "$lib/utils.js";
3+
import type { HTMLAttributes } from "svelte/elements";
4+
import type { Snippet } from "svelte";
5+
6+
let {
7+
class: className,
8+
child,
9+
...restProps
10+
}: HTMLAttributes<HTMLDivElement> & {
11+
child?: Snippet<[{ props: Record<string, unknown> }]>;
12+
} = $props();
13+
14+
const classes = $derived(
15+
cn(
16+
"bg-muted shadow-xs flex items-center gap-2 rounded-md border px-4 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
17+
className
18+
)
19+
);
20+
21+
const mergedProps = $derived({
22+
...restProps,
23+
class: classes,
24+
});
25+
</script>
26+
27+
{#if child}
28+
{@render child({ props: mergedProps })}
29+
{:else}
30+
<div {...mergedProps}>
31+
{@render mergedProps.children?.()}
32+
</div>
33+
{/if}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<script lang="ts" module>
2+
import { tv, type VariantProps } from "tailwind-variants";
3+
4+
const buttonGroupVariants = tv({
5+
base: "flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
6+
variants: {
7+
orientation: {
8+
horizontal:
9+
"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
10+
vertical:
11+
"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",
12+
},
13+
},
14+
defaultVariants: {
15+
orientation: "horizontal",
16+
},
17+
});
18+
19+
export type ButtonGroupOrientation = VariantProps<typeof buttonGroupVariants>["orientation"];
20+
</script>
21+
22+
<script lang="ts">
23+
import { cn } from "$lib/utils.js";
24+
import type { HTMLAttributes } from "svelte/elements";
25+
26+
let {
27+
class: className,
28+
children,
29+
orientation = "horizontal",
30+
...restProps
31+
}: HTMLAttributes<HTMLDivElement> & {
32+
orientation?: ButtonGroupOrientation;
33+
} = $props();
34+
</script>
35+
36+
<div
37+
role="group"
38+
data-slot="button-group"
39+
data-orientation={orientation}
40+
class={cn(buttonGroupVariants({ orientation }), className)}
41+
{...restProps}
42+
>
43+
{@render children?.()}
44+
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Root from "./button-group.svelte";
2+
import Text from "./button-group-text.svelte";
3+
import Separator from "./button-group-separator.svelte";
4+
5+
export {
6+
Root,
7+
Text,
8+
Separator,
9+
//
10+
Root as ButtonGroup,
11+
Text as ButtonGroupText,
12+
Separator as ButtonGroupSeparator,
13+
};

apps/playground2/src/lib/components/ui/button/button.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
2222
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
2323
icon: "size-9",
24+
"icon-sm": "size-8",
25+
"icon-lg": "size-10",
2426
},
2527
},
2628
defaultVariants: {

apps/playground2/src/lib/components/ui/command/command-input.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}: CommandPrimitive.InputProps = $props();
1212
</script>
1313

14-
<div class="flex h-9 items-center gap-2 border-b px-3" data-slot="command-input-wrapper">
14+
<div class="flex h-9 items-center gap-2 border-b pl-3 pr-8" data-slot="command-input-wrapper">
1515
<SearchIcon class="size-4 shrink-0 opacity-50" />
1616
<CommandPrimitive.Input
1717
data-slot="command-input"

apps/playground2/src/lib/components/ui/command/command-item.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
bind:ref
1414
data-slot="command-item"
1515
class={cn(
16-
"aria-selected:bg-accent aria-selected:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
16+
"aria-selected:bg-accent aria-selected:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
1717
className
1818
)}
1919
{...restProps}

apps/playground2/src/lib/components/ui/dialog/dialog-content.svelte

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
class: className,
1111
portalProps,
1212
children,
13+
showCloseButton = true,
1314
...restProps
1415
}: WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
1516
portalProps?: DialogPrimitive.PortalProps;
1617
children: Snippet;
18+
showCloseButton?: boolean;
1719
} = $props();
1820
</script>
1921

@@ -29,11 +31,13 @@
2931
{...restProps}
3032
>
3133
{@render children?.()}
32-
<DialogPrimitive.Close
33-
class="ring-offset-background focus:ring-ring rounded-xs focus:outline-hidden absolute right-4 top-4 opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0"
34-
>
35-
<XIcon />
36-
<span class="sr-only">Close</span>
37-
</DialogPrimitive.Close>
34+
{#if showCloseButton}
35+
<DialogPrimitive.Close
36+
class="ring-offset-background focus:ring-ring rounded-xs focus:outline-hidden absolute end-4 top-4 opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0"
37+
>
38+
<XIcon />
39+
<span class="sr-only">Close</span>
40+
</DialogPrimitive.Close>
41+
{/if}
3842
</DialogPrimitive.Content>
3943
</Dialog.Portal>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts">
2+
import { cn } from "$lib/utils.js";
3+
import type { HTMLAttributes } from "svelte/elements";
4+
5+
let { class: className, children, ...restProps }: HTMLAttributes<HTMLDivElement> = $props();
6+
</script>
7+
8+
<div
9+
data-slot="field-content"
10+
class={cn("group/field-content flex flex-1 flex-col gap-1.5 leading-snug", className)}
11+
{...restProps}
12+
>
13+
{@render children?.()}
14+
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script lang="ts">
2+
import { cn } from "$lib/utils.js";
3+
import type { HTMLAttributes } from "svelte/elements";
4+
5+
let {
6+
class: className,
7+
children,
8+
...restProps
9+
}: HTMLAttributes<HTMLParagraphElement> = $props();
10+
</script>
11+
12+
<p
13+
data-slot="field-description"
14+
class={cn(
15+
"text-muted-foreground text-sm font-normal leading-normal group-has-[[data-orientation=horizontal]]/field:text-balance",
16+
"nth-last-2:-mt-1 last:mt-0 [[data-variant=legend]+&]:-mt-1.5",
17+
"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
18+
className
19+
)}
20+
{...restProps}
21+
>
22+
{@render children?.()}
23+
</p>

0 commit comments

Comments
 (0)