Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit 21f5d69

Browse files
committed
add divider
1 parent d4349e8 commit 21f5d69

File tree

11 files changed

+122
-34
lines changed

11 files changed

+122
-34
lines changed

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
name: Feature request
33
about: Suggest a feature for this project
4-
title: ""
4+
title: ''
55
labels: enhancement
66
assignees: ''
7-
87
---
98

109
**Is your feature request related to a problem? Please describe.**

components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
},
3636
"dependencies": {
3737
"@radix-ui/react-checkbox": "^1.0.1",
38+
"@radix-ui/react-separator": "^1.0.1",
3839
"@vanilla-extract/css": "^1.6.3",
3940
"@vanilla-extract/css-utils": "^0.1.1",
4041
"@vanilla-extract/dynamic": "^2.0.0",

components/src/components/Checkbox/styles.css.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,38 +68,6 @@ const tone = {
6868

6969
export type Tone = keyof typeof tone
7070

71-
export const checkbox = style({
72-
all: 'unset',
73-
backgroundColor: vars.colors.background,
74-
width: vars.space['10'],
75-
height: vars.space['10'],
76-
borderRadius: vars.radii.large,
77-
display: 'flex',
78-
alignItems: 'center',
79-
justifyContent: 'center',
80-
boxShadow: `0 0 0 1px ${vars.colors.foregroundSecondary}`,
81-
82-
selectors: {
83-
'&[data-state="checked"]': {
84-
backgroundColor: vars.colors.green,
85-
},
86-
'&[data-disabled]': {
87-
backgroundColor: vars.colors.foregroundSecondary,
88-
},
89-
},
90-
91-
':hover': {
92-
backgroundColor: vars.colors.background,
93-
},
94-
':focus': {
95-
boxShadow: `0 0 0 2px ${vars.colors.foregroundSecondary}`,
96-
},
97-
})
98-
99-
export const indicator = style({
100-
color: vars.colors.accent,
101-
})
102-
10371
const variant = {
10472
primary: style([
10573
atoms({
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Divider
3+
description: Visually or semantically separates content.
4+
---
5+
6+
```tsx
7+
import { Divider } from '@kalidao/reality'
8+
```
9+
10+
```tsx live=true expand=true
11+
<Divider />
12+
```
13+
14+
## Props
15+
16+
<PropsTable sourceLink={sourceLink} types={types} />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react'
2+
3+
import { Snippet } from '!/playroom/src/types'
4+
import { Divider } from './Divider'
5+
6+
export const snippets: Snippet[] = [
7+
{
8+
name: 'Basic',
9+
code: <Divider />,
10+
},
11+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from 'react'
2+
3+
import { cleanup, render } from '@/test'
4+
5+
import { Divider } from './Divider'
6+
7+
describe('<Divider />', () => {
8+
afterEach(cleanup)
9+
10+
it('renders', () => {
11+
render(<Divider />)
12+
})
13+
})
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as React from 'react'
2+
import * as Separator from '@radix-ui/react-separator'
3+
4+
import { Stack } from '../Stack'
5+
import { Text } from '../Text'
6+
import * as styles from './styles.css'
7+
8+
type Props = {
9+
label?: string
10+
orientation?: 'horizontal' | 'vertical'
11+
}
12+
13+
export const Divider = ({ label, orientation = 'horizontal' }: Props) => {
14+
if (!label)
15+
return (
16+
<Separator.Root
17+
className={styles.variants({
18+
orientation,
19+
})}
20+
orientation={orientation}
21+
/>
22+
)
23+
24+
return (
25+
<Stack align="center" direction={orientation}>
26+
<Separator.Root
27+
className={styles.variants({
28+
orientation,
29+
})}
30+
orientation={orientation}
31+
/>
32+
<Text>{label}</Text>
33+
<Separator.Root className={styles.variants()} orientation={orientation} />
34+
</Stack>
35+
)
36+
}
37+
38+
Divider.displayName = 'Divider'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Divider } from './Divider'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { RecipeVariants, recipe } from '@vanilla-extract/recipes'
2+
import { style } from '@vanilla-extract/css'
3+
4+
import { vars } from '../../css'
5+
6+
export const variants = recipe({
7+
base: style([
8+
style({
9+
backgroundColor: vars.colors.foregroundSecondary,
10+
}),
11+
]),
12+
variants: {
13+
orientation: {
14+
vertical: {
15+
height: '100%',
16+
width: '1px',
17+
},
18+
horizontal: {
19+
height: '1px',
20+
width: '100%',
21+
},
22+
},
23+
},
24+
})
25+
26+
export type Variants = RecipeVariants<typeof variants>

components/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { Button } from './Button'
77
export { ButtonCard } from './ButtonCard'
88
export { Card } from './Card'
99
export { Checkbox } from './Checkbox'
10+
export { Divider } from './Divider'
1011
export { Field } from './Field'
1112
export { FieldSet } from './FieldSet'
1213
export { FileInput } from './FileInput'

0 commit comments

Comments
 (0)