-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add radix-ui/Separator * feat: separator --------- Co-authored-by: boomchanotai <[email protected]>
- Loading branch information
1 parent
db05057
commit 8fcb0f4
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import { Separator } from '.' | ||
|
||
const meta: Meta<typeof Separator> = { | ||
title: 'Components/Separator', | ||
component: Separator, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = { | ||
args: {}, | ||
render: (args) => ( | ||
<div> | ||
<div className='space-y-1'> | ||
<h4 className='text-sm font-medium leading-none'>Radix Primitives</h4> | ||
<p className='text-sm text-muted-foreground'> | ||
An open-source UI component library. | ||
</p> | ||
</div> | ||
<Separator className='my-4' {...args} /> | ||
<div className='flex h-5 items-center space-x-4 text-sm'> | ||
<div>Blog</div> | ||
<Separator orientation='vertical' /> | ||
<div>Docs</div> | ||
<Separator orientation='vertical' /> | ||
<div>Source</div> | ||
</div> | ||
</div> | ||
), | ||
} | ||
|
||
export const Vertical: Story = { | ||
args: { | ||
orientation: 'vertical', | ||
}, | ||
render: (args) => ( | ||
<div> | ||
<div className='flex h-5 items-center space-x-4 text-sm'> | ||
<div>Blog</div> | ||
<Separator {...args} /> | ||
<div>Docs</div> | ||
<Separator {...args} /> | ||
<div>Source</div> | ||
</div> | ||
</div> | ||
), | ||
} | ||
|
||
export const Horizontal: Story = { | ||
args: { | ||
orientation: 'horizontal', | ||
}, | ||
render: (args) => ( | ||
<div className='space-y-4 text-center'> | ||
<div> | ||
<p>First Element</p> | ||
</div> | ||
<Separator {...args} /> | ||
<div> | ||
<p>Second Element</p> | ||
</div> | ||
</div> | ||
), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client' | ||
|
||
import * as SeparatorPrimitive from '@radix-ui/react-separator' | ||
import * as React from 'react' | ||
|
||
import { cn } from '@/utils' | ||
|
||
const Separator = React.forwardRef< | ||
React.ElementRef<typeof SeparatorPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> | ||
>( | ||
( | ||
{ className, orientation = 'horizontal', decorative = true, ...props }, | ||
ref | ||
) => ( | ||
<SeparatorPrimitive.Root | ||
ref={ref} | ||
decorative={decorative} | ||
orientation={orientation} | ||
className={cn( | ||
'shrink-0 bg-border', | ||
orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]', | ||
className | ||
)} | ||
{...props} | ||
/> | ||
) | ||
) | ||
Separator.displayName = SeparatorPrimitive.Root.displayName | ||
|
||
export { Separator } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.