Skip to content

Commit fd2f903

Browse files
authored
feat(Divider): responsive prop (#375)
1 parent bd346a2 commit fd2f903

2 files changed

Lines changed: 57 additions & 16 deletions

File tree

src/Divider/Divider.stories.tsx

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,78 @@ import React from 'react'
22
import { StoryFn as Story, Meta } from '@storybook/react'
33

44
import Divider, { DividerProps } from '.'
5+
import Card from '../Card'
56

67
export default {
78
title: 'Layout/Divider',
89
component: Divider,
10+
args: {
11+
children: 'OR',
12+
},
913
} as Meta
1014

11-
export const Default: Story<DividerProps> = (args) => {
15+
export const Default: Story<DividerProps> = ({ children, ...args }) => {
1216
return (
13-
<div className="flex flex-col w-full">
14-
<div className="grid h-20 card bg-base-300 rounded-box place-items-center">
17+
<div className="flex flex-col w-full border-opacity-50">
18+
<Card className="grid h-20 bg-base-300 rounded-box place-items-center">
1519
content
16-
</div>
17-
<Divider {...args}>{args.children}</Divider>
18-
<div className="grid h-20 card bg-base-300 rounded-box place-items-center">
20+
</Card>
21+
<Divider {...args}>{children}</Divider>
22+
<Card className="grid h-20 bg-base-300 rounded-box place-items-center">
1923
content
20-
</div>
24+
</Card>
2125
</div>
2226
)
2327
}
2428
Default.args = {}
2529

26-
export const Vertical: Story<DividerProps> = (args) => {
30+
export const Horizontal: Story<DividerProps> = ({ children, ...args }) => {
31+
return (
32+
<div className="flex w-full ">
33+
<Card className="grid h-20 flex-grow bg-base-300 rounded-box place-items-center">
34+
content
35+
</Card>
36+
<Divider {...args}>{children}</Divider>
37+
<Card className="grid h-20 flex-grow bg-base-300 rounded-box place-items-center">
38+
content
39+
</Card>
40+
</div>
41+
)
42+
}
43+
Horizontal.args = {
44+
horizontal: true,
45+
}
46+
47+
export const NoText: Story<DividerProps> = ({ children, ...args }) => {
48+
return (
49+
<div className="flex flex-col w-full">
50+
<Card className="grid h-20 bg-base-300 rounded-box place-items-center">
51+
content
52+
</Card>
53+
<Divider {...args}>{children}</Divider>
54+
<Card className="grid h-20 bg-base-300 rounded-box place-items-center">
55+
content
56+
</Card>
57+
</div>
58+
)
59+
}
60+
NoText.args = {
61+
children: '',
62+
}
63+
64+
export const Responsive: Story<DividerProps> = ({ children, ...args }) => {
2765
return (
28-
<div className="flex flex-row w-full">
29-
<div className="grid flex-grow h-32 card bg-base-300 rounded-box place-items-center">
66+
<div className="flex flex-col w-full lg:flex-row">
67+
<Card className="grid flex-grow h-32 bg-base-300 rounded-box place-items-center">
3068
content
31-
</div>
32-
<Divider {...args}>{args.children}</Divider>
33-
<div className="grid flex-grow h-32 card bg-base-300 rounded-box place-items-center">
69+
</Card>
70+
<Divider {...args}>{children}</Divider>
71+
<Card className="grid flex-grow h-32 bg-base-300 rounded-box place-items-center">
3472
content
35-
</div>
73+
</Card>
3674
</div>
3775
)
3876
}
39-
Vertical.args = {
40-
vertical: true,
77+
Responsive.args = {
78+
responsive: true,
4179
}

src/Divider/Divider.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ export type DividerProps = React.HTMLAttributes<HTMLDivElement> &
88
IComponentBaseProps & {
99
vertical?: boolean
1010
horizontal?: boolean
11+
responsive?: boolean
1112
}
1213

1314
const Divider = ({
1415
children,
1516
vertical,
1617
horizontal,
18+
responsive,
1719
dataTheme,
1820
className,
1921
...props
@@ -24,6 +26,7 @@ const Divider = ({
2426
clsx({
2527
'divider-vertical': vertical,
2628
'divider-horizontal': horizontal,
29+
'lg:divider-horizontal': responsive,
2730
})
2831
)
2932

0 commit comments

Comments
 (0)