-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create separator ui component (#106)
- Loading branch information
1 parent
fc12062
commit 4b212ba
Showing
14 changed files
with
251 additions
and
1 deletion.
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,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['custom/react'], | ||
} |
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,41 @@ | ||
{ | ||
"name": "@consolelabs/separator", | ||
"version": "0.0.1", | ||
"sideEffects": false, | ||
"main": "src/index.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "tsup src --dts", | ||
"build:fast": "tsup src", | ||
"dev": "yarn build:fast -- --watch", | ||
"lint": "eslint src/", | ||
"clean": "rimraf dist .turbo", | ||
"typecheck": "tsc --noEmit", | ||
"prepack": "clean-package", | ||
"postpack": "clean-package restore" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"clean-package": "^2.2.0", | ||
"eslint-config-custom": "workspace:*", | ||
"prettier": "^3.0.3", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"tsconfig": "workspace:*" | ||
}, | ||
"dependencies": { | ||
"@consolelabs/theme": "workspace:*", | ||
"@radix-ui/react-separator": "^1.0.3", | ||
"clsx": "^2.0.0" | ||
}, | ||
"clean-package": "../../../clean-package.config.json" | ||
} |
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 @@ | ||
export * from './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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as SeparatorPrimitive from '@radix-ui/react-separator' | ||
import { ComponentPropsWithoutRef, ElementRef, forwardRef } from 'react' | ||
import clsx from 'clsx' | ||
import { separator as separatorClassName } from '@consolelabs/theme' | ||
|
||
const Separator = forwardRef< | ||
ElementRef<typeof SeparatorPrimitive.Root>, | ||
ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> | ||
>((props, ref) => { | ||
const { | ||
orientation = 'horizontal', | ||
className, | ||
decorative = true, | ||
...restProps | ||
} = props | ||
|
||
return ( | ||
<SeparatorPrimitive.Root | ||
ref={ref} | ||
decorative={decorative} | ||
className={clsx( | ||
separatorClassName.base, | ||
{ | ||
[separatorClassName.horizontal]: orientation === 'horizontal', | ||
[separatorClassName.vertical]: orientation === 'vertical', | ||
}, | ||
className, | ||
)} | ||
{...restProps} | ||
/> | ||
) | ||
}) | ||
|
||
Separator.displayName = SeparatorPrimitive.Root.displayName | ||
|
||
export { Separator } |
37 changes: 37 additions & 0 deletions
37
packages/components/separator/stories/separator.stories.tsx
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,37 @@ | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import { Separator } from '../src' | ||
|
||
const meta: Meta<typeof Separator> = { | ||
title: 'ui/Separator', | ||
component: Separator, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
argTypes: {}, | ||
} | ||
|
||
export default meta | ||
|
||
export const Default: StoryObj = { | ||
render() { | ||
return ( | ||
<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" /> | ||
<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> | ||
) | ||
}, | ||
} |
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,5 @@ | ||
{ | ||
"extends": "tsconfig/react-library.json", | ||
"include": ["src", "stories", "index.ts"], | ||
"exclude": ["dist", "node_modules"] | ||
} |
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,7 @@ | ||
import { defineConfig } from 'tsup' | ||
|
||
export default defineConfig(() => ({ | ||
clean: true, | ||
target: 'es2019', | ||
format: ['cjs', 'esm'], | ||
})) |
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
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,11 @@ | ||
const horizontal = 'h-[0.5px] w-full' | ||
const vertical = 'w-[0.5px] h-full' | ||
const base = 'shrink-0 bg-neutral-400 rounded-full' | ||
|
||
const separator = { | ||
horizontal, | ||
vertical, | ||
base, | ||
} | ||
|
||
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
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 @@ | ||
export * from './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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import { Separator } from './separator' | ||
|
||
const meta: Meta<typeof Separator> = { | ||
title: 'ui/Separator', | ||
component: Separator, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
argTypes: {}, | ||
} | ||
|
||
export default meta | ||
|
||
export const Default: StoryObj = { | ||
render() { | ||
return ( | ||
<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" /> | ||
<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> | ||
) | ||
}, | ||
} |
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,35 @@ | ||
import * as SeparatorPrimitive from '@radix-ui/react-separator' | ||
import clsx from 'clsx' | ||
import { ComponentPropsWithoutRef, ElementRef, forwardRef } from 'react' | ||
|
||
const Separator = forwardRef< | ||
ElementRef<typeof SeparatorPrimitive.Root>, | ||
ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> | ||
>((props, ref) => { | ||
const { | ||
orientation = 'horizontal', | ||
className, | ||
decorative = true, | ||
...restProps | ||
} = props | ||
|
||
return ( | ||
<SeparatorPrimitive.Root | ||
ref={ref} | ||
decorative={decorative} | ||
className={clsx( | ||
'shrink-0 bg-neutral-400 rounded-full', | ||
{ | ||
'h-[0.5px] w-full': orientation === 'horizontal', | ||
'w-[0.5px] h-full': orientation === 'vertical', | ||
}, | ||
className, | ||
)} | ||
{...restProps} | ||
/> | ||
) | ||
}) | ||
|
||
Separator.displayName = SeparatorPrimitive.Root.displayName | ||
|
||
export { Separator } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4b212ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
websites-mochi – ./apps/mochi-web
websites-mochi-consolelabs.vercel.app
websites-mochi-git-main-consolelabs.vercel.app
websites-mochi.vercel.app
beta.mochi.gg