Skip to content

Commit 3662279

Browse files
feat: separator section and variant.
1 parent 82947cc commit 3662279

4 files changed

Lines changed: 77 additions & 8 deletions

File tree

examples/ui-playground/src/app/playground/shadcn/page-sidebar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const navigationItems = [
2727
{ href: '#link', label: 'Link' },
2828
{ href: '#pagination', label: 'Pagination' },
2929
{ href: '#progress', label: 'Progress' },
30+
{ href: '#separator', label: 'Separator' },
3031
{ href: '#select', label: 'Select' },
3132
{ href: '#slider', label: 'Slider' },
3233
{ href: '#switch', label: 'Switch' },

examples/ui-playground/src/app/playground/shadcn/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { PaginationSection } from './pagination-section'
2020
import { ProgressSection } from './progress-section'
2121
import { RichTextSection } from './rich-text-section'
2222
import { SelectSection } from './select-section'
23+
import { SeparatorSection } from './separator-section'
2324
import { SliderSection } from './slider-section'
2425
import { SwitchSection } from './switch-section'
2526
import { TableSection } from './table-section'
@@ -73,7 +74,7 @@ export default function ComboboxPage() {
7374
<Typography type="h2" weight="bold" id="input-otp">
7475
Input OTP
7576
</Typography>
76-
<InputOtpSection />A
77+
<InputOtpSection />
7778
<Typography type="h2" weight="bold" id="link">
7879
Link
7980
</Typography>
@@ -94,6 +95,10 @@ export default function ComboboxPage() {
9495
Slider
9596
</Typography>
9697
<SliderSection />
98+
<Typography type="h2" weight="bold" id="separator">
99+
Separator
100+
</Typography>
101+
<SeparatorSection />
97102
<Typography type="h2" weight="bold" id="switch">
98103
Switch
99104
</Typography>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react'
2+
3+
import { Separator, Typography } from '@genseki/react/v2'
4+
5+
import { PlaygroundCard } from '~/src/components/card'
6+
7+
function BasicSeparatorExamples() {
8+
return (
9+
<div className="space-y-6">
10+
<div className="flex items-center gap-4">
11+
<span className="text-sm text-muted-foreground">Left content</span>
12+
<Separator className="flex-1" />
13+
<span className="text-sm text-muted-foreground">Right content</span>
14+
</div>
15+
<div className="flex h-24 items-center gap-4">
16+
<span className="text-sm text-muted-foreground">Top</span>
17+
<Separator orientation="vertical" className="h-full" />
18+
<span className="text-sm text-muted-foreground">Bottom</span>
19+
</div>
20+
<div className="flex items-center gap-4">
21+
<span className="text-sm text-muted-foreground">Left content</span>
22+
<Separator variant="dashed" className="flex-1" />
23+
<span className="text-sm text-muted-foreground">Right content</span>
24+
</div>
25+
<div className="flex h-24 items-center gap-4">
26+
<span className="text-sm text-muted-foreground">Top</span>
27+
<Separator variant="dashed" orientation="vertical" className="h-full" />
28+
<span className="text-sm text-muted-foreground">Bottom</span>
29+
</div>
30+
</div>
31+
)
32+
}
33+
34+
export function SeparatorSection() {
35+
return (
36+
<div className="grid gap-8">
37+
<PlaygroundCard title="Separator" categoryTitle="Component">
38+
<Typography type="body" className="text-muted-foreground mb-4">
39+
Visual dividers for grouping content horizontally or vertically.
40+
</Typography>
41+
<div className="p-4 bg-secondary w-full rounded-lg">
42+
<BasicSeparatorExamples />
43+
</div>
44+
</PlaygroundCard>
45+
</div>
46+
)
47+
}

packages/react/v2/components/primitives/separator.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,44 @@
22
import React from 'react'
33

44
import * as SeparatorPrimitive from '@radix-ui/react-separator'
5-
6-
import { cn } from '../../../src/react/utils/cn'
5+
import { cva, type VariantProps } from 'class-variance-authority'
76

87
/**
98
* Shadcn component
109
*/
1110

11+
const separator = cva('shrink-0', {
12+
variants: {
13+
variant: {
14+
solid:
15+
'bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px',
16+
dashed: `bg-size-[12px_12px] bg-repeat
17+
data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=horizontal]:bg-[linear-gradient(to_right,var(--color-border-primary)_50%,transparent_50%)]
18+
data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px data-[orientation=vertical]:bg-[linear-gradient(to_bottom,var(--color-border-primary)_50%,transparent_50%)]
19+
`,
20+
},
21+
},
22+
defaultVariants: {
23+
variant: 'solid',
24+
},
25+
})
26+
27+
type SeparatorProps = React.ComponentProps<typeof SeparatorPrimitive.Root> &
28+
VariantProps<typeof separator>
29+
1230
function Separator({
1331
className,
1432
orientation = 'horizontal',
33+
variant,
1534
decorative = true,
1635
...props
17-
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
36+
}: SeparatorProps) {
1837
return (
1938
<SeparatorPrimitive.Root
2039
data-slot="separator"
2140
decorative={decorative}
2241
orientation={orientation}
23-
className={cn(
24-
'bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px',
25-
className
26-
)}
42+
className={separator({ variant, className })}
2743
{...props}
2844
/>
2945
)

0 commit comments

Comments
 (0)