Skip to content

Commit 93ba905

Browse files
authored
fix(Artboard): changed default value of demo prop (#376)
1 parent fd2f903 commit 93ba905

3 files changed

Lines changed: 87 additions & 49 deletions

File tree

src/Artboard/Artboard.stories.tsx

Lines changed: 72 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,83 @@ export default {
88
component: Artboard,
99
} as Meta
1010

11-
export const Default: Story<ArtboardProps> = (args) => {
12-
return <Artboard {...args}>Example</Artboard>
11+
const Template: Story<ArtboardProps> = ({ children, ...args }) => {
12+
return <Artboard {...args}>{children}</Artboard>
1313
}
14+
export const Default = Template.bind({})
1415
Default.args = {
1516
size: 1,
17+
children: ' 320×568',
1618
}
1719

18-
export const Sizes: Story<ArtboardProps> = (args) => {
19-
return (
20-
<div className="flex w-auto space-x-10 flex-nowrap overflow-x-auto p-8 bg-neutral rounded-2xl">
21-
<Artboard {...args} size={1}>
22-
phone-1
23-
</Artboard>
24-
<Artboard {...args} size={2}>
25-
phone-2
26-
</Artboard>
27-
<Artboard {...args} size={3}>
28-
phone-3
29-
</Artboard>
30-
<Artboard {...args} size={4}>
31-
phone-4
32-
</Artboard>
33-
<Artboard {...args} size={5}>
34-
phone-5
35-
</Artboard>
36-
<Artboard {...args} size={6}>
37-
phone-6
38-
</Artboard>
39-
</div>
40-
)
20+
export const Size2 = Template.bind({})
21+
Size2.args = {
22+
size: 2,
23+
children: ' 375×667',
4124
}
4225

43-
export const Horizontal: Story<ArtboardProps> = (args) => {
44-
return (
45-
<div className="flex w-auto space-x-4 flex-nowrap overflow-x-auto p-8 bg-neutral rounded-2xl">
46-
<Artboard {...args} size={1} horizontal>
47-
phone-1
48-
</Artboard>
49-
<Artboard {...args} size={2} horizontal>
50-
phone-2
51-
</Artboard>
52-
<Artboard {...args} size={3} horizontal>
53-
phone-3
54-
</Artboard>
55-
<Artboard {...args} size={4} horizontal>
56-
phone-4
57-
</Artboard>
58-
<Artboard {...args} size={5} horizontal>
59-
phone-5
60-
</Artboard>
61-
<Artboard {...args} size={6} horizontal>
62-
phone-6
63-
</Artboard>
64-
</div>
65-
)
26+
export const Size3 = Template.bind({})
27+
Size3.args = {
28+
size: 3,
29+
children: ' 414×736',
30+
}
31+
32+
export const Size4 = Template.bind({})
33+
Size4.args = {
34+
size: 4,
35+
children: ' 375×812',
36+
}
37+
38+
export const Size5 = Template.bind({})
39+
Size5.args = {
40+
size: 5,
41+
children: ' 414×896',
42+
}
43+
44+
export const Size6 = Template.bind({})
45+
Size6.args = {
46+
size: 6,
47+
children: ' 320×1024',
48+
}
49+
50+
export const HorizontalSize1 = Template.bind({})
51+
HorizontalSize1.args = {
52+
size: 1,
53+
children: '568×320',
54+
horizontal: true,
55+
}
56+
57+
export const HorizontalSize2 = Template.bind({})
58+
HorizontalSize2.args = {
59+
size: 2,
60+
children: ' 667×375',
61+
horizontal: true,
62+
}
63+
64+
export const HorizontalSize3 = Template.bind({})
65+
HorizontalSize3.args = {
66+
size: 3,
67+
children: ' 736×414',
68+
horizontal: true,
69+
}
70+
71+
export const HorizontalSize4 = Template.bind({})
72+
HorizontalSize4.args = {
73+
size: 4,
74+
children: ' 812×375',
75+
horizontal: true,
76+
}
77+
78+
export const HorizontalSize5 = Template.bind({})
79+
HorizontalSize5.args = {
80+
size: 5,
81+
children: ' 896×414',
82+
horizontal: true,
83+
}
84+
85+
export const HorizontalSize6 = Template.bind({})
86+
HorizontalSize6.args = {
87+
size: 6,
88+
children: ' 1024×320',
89+
horizontal: true,
6690
}

src/Artboard/Artboard.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ describe('Artboard', () => {
1818
expect(screen.getByLabelText('Artboard')).toHaveClass('horizontal')
1919
})
2020

21+
it.each`
22+
demo | expected
23+
${undefined} | ${true}
24+
${true} | ${true}
25+
${false} | ${false}
26+
`('renders a demo', ({ demo, expected }) => {
27+
render(<Artboard demo={demo}>Test</Artboard>)
28+
if (expected) {
29+
expect(screen.getByLabelText('Artboard')).toHaveClass('artboard-demo')
30+
} else {
31+
expect(screen.getByLabelText('Artboard')).not.toHaveClass('artboard-demo')
32+
}
33+
})
34+
2135
it('should be able to access the native div', () => {
2236
const artboardRef = createRef<HTMLDivElement>()
2337
render(<Artboard ref={artboardRef}>Test</Artboard>)

src/Artboard/Artboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type ArtboardProps = React.HTMLAttributes<HTMLDivElement> &
1313

1414
const Artboard = forwardRef<HTMLDivElement, ArtboardProps>(
1515
(
16-
{ children, demo, size, horizontal, dataTheme, className, ...props },
16+
{ children, demo = true, size, horizontal, dataTheme, className, ...props },
1717
ref
1818
): JSX.Element => {
1919
const classes = twMerge(

0 commit comments

Comments
 (0)