Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e9f994e

Browse files
committedJul 29, 2024·
Add Bento playground story
1 parent 9d1c5b2 commit e9f994e

File tree

2 files changed

+191
-13
lines changed

2 files changed

+191
-13
lines changed
 

‎apps/docs/content/components/Bento.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bento
33
status: Alpha
44
a11yReviewed: true
55
source: https://github.com/primer/brand/blob/main/packages/react/src/Bento/Bento.tsx
6-
storybook: '/brand/storybook/?path=/story/components-bento--default'
6+
storybook: '/brand/storybook/?path=/story/components-bento--playground'
77
description: Use the bento to present content in a responsive grid layout.
88
---
99

‎packages/react/src/Bento/Bento.stories.tsx

+190-12
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@ import React from 'react'
22
import {Meta} from '@storybook/react'
33
import {Bento} from '.'
44
import {Link} from '../Link'
5+
import placeholderImage from '../fixtures/images/placeholder-600x400.png'
56

67
import {CopilotIcon} from '@primer/octicons-react'
8+
import {HeadingSizes, HeadingTags} from '../Heading'
79

810
export default {
911
title: 'Components/Bento',
1012
component: Bento,
11-
args: {},
12-
argTypes: {
13-
className: {
14-
description: 'Custom class name for the second component',
15-
control: {
16-
type: 'text',
17-
},
18-
},
19-
},
2013
} as Meta<typeof Bento>
2114

2215
export const Default = () => (
@@ -27,10 +20,195 @@ export const Default = () => (
2720
Push what&apos;s possible with GitHub Copilot, the world&apos;s most trusted and widely adopted AI developer
2821
tool.
2922
</Bento.Heading>
30-
<Link href="#" variant="default">
31-
Learn more about Copilot
32-
</Link>
23+
<Link href="#">Learn more about Copilot</Link>
3324
</Bento.Content>
3425
</Bento.Item>
3526
</Bento>
3627
)
28+
29+
export const Playground = ({
30+
contentVisible,
31+
contentLeadingVisualVisible,
32+
contentLinkVisible,
33+
contentPadding,
34+
contentHorizontalAlign,
35+
contentVerticalAlign,
36+
headingText,
37+
headingAs,
38+
headingSize,
39+
visualVisible,
40+
visualFillMedia,
41+
visualPosition,
42+
visualPadding,
43+
...args
44+
}) => (
45+
<Bento>
46+
<Bento.Item {...args}>
47+
{contentVisible && (
48+
<Bento.Content
49+
leadingVisual={contentLeadingVisualVisible && <CopilotIcon />}
50+
padding={contentPadding}
51+
horizontalAlign={contentHorizontalAlign}
52+
verticalAlign={contentVerticalAlign}
53+
>
54+
<Bento.Heading as={headingAs} size={headingSize}>
55+
{headingText}
56+
</Bento.Heading>
57+
{contentLinkVisible && <Link href="#">Call to action</Link>}
58+
</Bento.Content>
59+
)}
60+
61+
{visualVisible && (
62+
<Bento.Visual fillMedia={visualFillMedia} position={visualPosition} padding={visualPadding}>
63+
<img alt="placeholder, blank area with an gray background color" src={placeholderImage} />
64+
</Bento.Visual>
65+
)}
66+
</Bento.Item>
67+
</Bento>
68+
)
69+
Playground.storyName = 'Playground'
70+
Playground.args = {
71+
flow: 'column',
72+
colorMode: 'light',
73+
visualAsBackground: false,
74+
order: 'default',
75+
contentVisible: true,
76+
contentLeadingVisualVisible: true,
77+
contentLinkVisible: true,
78+
contentPadding: 'normal',
79+
contentHorizontalAlign: 'start',
80+
contentVerticalAlign: 'center',
81+
headingText: 'Heading',
82+
headingAs: 'h2',
83+
headingSize: '3',
84+
visualVisible: true,
85+
visualFillMedia: true,
86+
visualPosition: '50% 50%',
87+
visualPadding: undefined,
88+
}
89+
Playground.argTypes = {
90+
flow: {
91+
options: ['row', 'column'],
92+
control: 'radio',
93+
table: {
94+
category: 'Bento.Item',
95+
},
96+
},
97+
colorMode: {
98+
options: ['light', 'dark'],
99+
control: 'radio',
100+
table: {
101+
category: 'Bento.Item',
102+
},
103+
},
104+
visualAsBackground: {
105+
control: 'boolean',
106+
table: {
107+
category: 'Bento.Item',
108+
},
109+
},
110+
order: {
111+
options: ['default', 'reverse'],
112+
control: 'radio',
113+
table: {
114+
category: 'Bento.Item',
115+
},
116+
},
117+
contentVisible: {
118+
name: 'visible',
119+
control: 'boolean',
120+
table: {
121+
category: 'Bento.Content',
122+
},
123+
},
124+
contentLeadingVisualVisible: {
125+
name: 'leadingVisual visible',
126+
control: 'boolean',
127+
table: {
128+
category: 'Bento.Content',
129+
},
130+
},
131+
contentLinkVisible: {
132+
name: 'Link visible',
133+
control: 'boolean',
134+
table: {
135+
category: 'Bento.Content',
136+
},
137+
},
138+
contentPadding: {
139+
name: 'padding',
140+
options: ['condensed', 'normal', 'spacious'],
141+
control: 'radio',
142+
table: {
143+
category: 'Bento.Content',
144+
},
145+
},
146+
contentHorizontalAlign: {
147+
name: 'horizontalAlign',
148+
options: ['start', 'center', 'end'],
149+
control: 'inline-radio',
150+
table: {
151+
category: 'Bento.Content',
152+
},
153+
},
154+
contentVerticalAlign: {
155+
name: 'verticalAlign',
156+
options: ['start', 'center', 'end'],
157+
control: 'inline-radio',
158+
table: {
159+
category: 'Bento.Content',
160+
},
161+
},
162+
headingText: {
163+
name: 'text',
164+
control: 'text',
165+
table: {
166+
category: 'Bento.Heading',
167+
},
168+
},
169+
headingAs: {
170+
name: 'as',
171+
control: 'inline-radio',
172+
options: HeadingTags,
173+
table: {
174+
category: 'Bento.Heading',
175+
},
176+
},
177+
headingSize: {
178+
name: 'size',
179+
control: 'inline-radio',
180+
options: HeadingSizes,
181+
table: {
182+
category: 'Bento.Heading',
183+
},
184+
},
185+
visualVisible: {
186+
name: 'visible',
187+
control: 'boolean',
188+
table: {
189+
category: 'Bento.Visual',
190+
},
191+
},
192+
visualFillMedia: {
193+
name: 'fillMedia',
194+
control: 'boolean',
195+
table: {
196+
category: 'Bento.Visual',
197+
},
198+
},
199+
visualPosition: {
200+
name: 'position',
201+
control: 'text',
202+
table: {
203+
category: 'Bento.Visual',
204+
},
205+
},
206+
visualPadding: {
207+
name: 'padding',
208+
options: [undefined, 'condensed', 'normal', 'spacious'],
209+
control: 'radio',
210+
table: {
211+
category: 'Bento.Visual',
212+
},
213+
},
214+
}

0 commit comments

Comments
 (0)
Please sign in to comment.