Skip to content

Commit 75f2307

Browse files
cameronjoynerCameron Joyner
andauthored
(chore) migrate Storybook to <Flex> usage (#8078)
Co-authored-by: Cameron Joyner <cjoyner@palantir.com>
1 parent f368102 commit 75f2307

35 files changed

Lines changed: 561 additions & 499 deletions

packages/core/src/components/breadcrumbs/Breadcrumbs.stories.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { Meta, StoryObj } from "@storybook/react-vite";
66
import { storybookLayoutDecorator, StoryLabel } from "@storybook-common";
77
import React from "react";
88

9+
import { Flex } from "@blueprintjs/labs";
10+
911
import { Boundary } from "../../common/boundary";
1012

1113
import { type BreadcrumbProps } from "./breadcrumb";
@@ -67,7 +69,7 @@ export const CollapseFromExample: Story = {
6769
collapseFrom: { table: { disable: true } },
6870
},
6971
render: ({ width, ...args }) => (
70-
<div style={{ display: "flex", flexDirection: "column", gap: 16, alignItems: "flex-start" }}>
72+
<Flex flexDirection="column" gap={4} alignItems="start">
7173
<div style={{ width }}>
7274
<StoryLabel title="Collapse from start (default)" />
7375
<Breadcrumbs {...args} collapseFrom={Boundary.START} />
@@ -76,7 +78,7 @@ export const CollapseFromExample: Story = {
7678
<StoryLabel title="Collapse from end" />
7779
<Breadcrumbs {...args} collapseFrom={Boundary.END} />
7880
</div>
79-
</div>
81+
</Flex>
8082
),
8183
};
8284

@@ -86,7 +88,7 @@ export const CollapseFromExample: Story = {
8688
export const OverflowExample: Story = {
8789
name: "Overflow",
8890
render: args => (
89-
<div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
91+
<Flex flexDirection="column" gap={4}>
9092
<div>
9193
<StoryLabel title="Constrained width (300px)" />
9294
<div style={{ width: 300 }}>
@@ -99,7 +101,7 @@ export const OverflowExample: Story = {
99101
<Breadcrumbs {...args} />
100102
</div>
101103
</div>
102-
</div>
104+
</Flex>
103105
),
104106
};
105107

packages/core/src/components/button/Button.stories.tsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import type { Meta, StoryObj } from "@storybook/react-vite";
66
import { storybookLayoutDecorator, StoryLabel } from "@storybook-common";
77

8+
import { Flex } from "@blueprintjs/labs";
9+
810
import { Alignment, ButtonVariant, Intent, Size } from "../../common";
911

1012
import { Button } from "./buttons";
@@ -116,7 +118,7 @@ export const IntentExample: Story = {
116118
intent: { table: { disable: true } },
117119
},
118120
render: args => (
119-
<div style={{ display: "flex", gap: 8 }}>
121+
<Flex gap={2}>
120122
{Object.values(Intent)
121123
.filter(i => i !== "none")
122124
.map(intent => (
@@ -127,7 +129,7 @@ export const IntentExample: Story = {
127129
text={intent.charAt(0).toUpperCase() + intent.slice(1)}
128130
/>
129131
))}
130-
</div>
132+
</Flex>
131133
),
132134
};
133135

@@ -141,7 +143,7 @@ export const VariantExample: Story = {
141143
variant: { table: { disable: true } },
142144
},
143145
render: args => (
144-
<div style={{ display: "flex", gap: 8 }}>
146+
<Flex gap={2}>
145147
{Object.values(ButtonVariant).map(variant => (
146148
<Button
147149
key={variant}
@@ -150,7 +152,7 @@ export const VariantExample: Story = {
150152
text={variant.charAt(0).toUpperCase() + variant.slice(1)}
151153
/>
152154
))}
153-
</div>
155+
</Flex>
154156
),
155157
};
156158

@@ -163,11 +165,11 @@ export const SizeExample: Story = {
163165
size: { table: { disable: true } },
164166
},
165167
render: args => (
166-
<div style={{ display: "flex", gap: 8, alignItems: "center" }}>
168+
<Flex gap={2} alignItems="center">
167169
{Object.values(Size).map(size => (
168170
<Button key={size} {...args} size={size} text={size.charAt(0).toUpperCase() + size.slice(1)} />
169171
))}
170-
</div>
172+
</Flex>
171173
),
172174
};
173175

@@ -182,12 +184,12 @@ export const StateExample: Story = {
182184
loading: { table: { disable: true } },
183185
},
184186
render: args => (
185-
<div style={{ display: "flex", gap: 8 }}>
187+
<Flex gap={2}>
186188
<Button {...args} text="Default" />
187189
<Button {...args} active={true} text="Active" />
188190
<Button {...args} disabled={true} text="Disabled" />
189191
<Button {...args} loading={true} text="Loading" />
190-
</div>
192+
</Flex>
191193
),
192194
};
193195

@@ -201,12 +203,12 @@ export const IconExample: Story = {
201203
endIcon: { table: { disable: true } },
202204
},
203205
render: args => (
204-
<div style={{ display: "flex", gap: 8 }}>
206+
<Flex gap={2}>
205207
<Button {...args} icon="refresh" text="Reset" />
206208
<Button {...args} icon="user" endIcon="caret-down" text="Profile" />
207209
<Button {...args} endIcon="arrow-right" text="Next" />
208210
<Button {...args} icon="edit" text={undefined} aria-label="edit" />
209-
</div>
211+
</Flex>
210212
),
211213
};
212214

@@ -219,7 +221,7 @@ export const AlignmentExample: Story = {
219221
alignText: { table: { disable: true } },
220222
},
221223
render: args => (
222-
<div style={{ display: "flex", flexDirection: "column", gap: 8, minWidth: 300 }}>
224+
<Flex flexDirection="column" gap={2} style={{ minWidth: 300 }}>
223225
{Object.values(Alignment).map(alignment => (
224226
<Button
225227
key={alignment}
@@ -230,7 +232,7 @@ export const AlignmentExample: Story = {
230232
text={alignment.charAt(0).toUpperCase() + alignment.slice(1)}
231233
/>
232234
))}
233-
</div>
235+
</Flex>
234236
),
235237
};
236238

@@ -250,10 +252,10 @@ export const FillExample: Story = {
250252
),
251253
],
252254
render: args => (
253-
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
255+
<Flex flexDirection="column" gap={2}>
254256
<Button {...args} fill={true} text="Full Width" />
255257
<Button {...args} fill={false} text="Auto Width" />
256-
</div>
258+
</Flex>
257259
),
258260
};
259261

@@ -269,16 +271,16 @@ export const AllIntentsAllVariants: Story = {
269271
loading: { table: { disable: true } },
270272
},
271273
render: args => (
272-
<div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
274+
<Flex flexDirection="column" gap={4}>
273275
{Object.values(ButtonVariant).map(variant => (
274-
<div key={variant} style={{ display: "flex", flexDirection: "column", gap: 8 }}>
276+
<Flex key={variant} flexDirection="column" gap={2}>
275277
<StoryLabel title={variant} />
276-
<div style={{ display: "flex", gap: 8 }}>
278+
<Flex gap={2}>
277279
{Object.values(Intent).map(intent => (
278280
<Button key={intent} {...args} variant={variant} intent={intent} text={intent} />
279281
))}
280-
</div>
281-
<div style={{ display: "flex", gap: 8 }}>
282+
</Flex>
283+
<Flex gap={2}>
282284
{Object.values(Intent).map(intent => (
283285
<Button
284286
key={intent}
@@ -289,8 +291,8 @@ export const AllIntentsAllVariants: Story = {
289291
text={intent}
290292
/>
291293
))}
292-
</div>
293-
<div style={{ display: "flex", gap: 8 }}>
294+
</Flex>
295+
<Flex gap={2}>
294296
{Object.values(Intent).map(intent => (
295297
<Button
296298
key={intent}
@@ -301,8 +303,8 @@ export const AllIntentsAllVariants: Story = {
301303
text={intent}
302304
/>
303305
))}
304-
</div>
305-
<div style={{ display: "flex", gap: 8 }}>
306+
</Flex>
307+
<Flex gap={2}>
306308
{Object.values(Intent).map(intent => (
307309
<Button
308310
key={intent}
@@ -313,10 +315,10 @@ export const AllIntentsAllVariants: Story = {
313315
text={intent}
314316
/>
315317
))}
316-
</div>
317-
</div>
318+
</Flex>
319+
</Flex>
318320
))}
319-
</div>
321+
</Flex>
320322
),
321323
};
322324

0 commit comments

Comments
 (0)