Skip to content

Commit cc69429

Browse files
author
Chris Hasson
committed
refactor(storybook): Centralize story decorators
1 parent 47fef49 commit cc69429

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Decorator } from "@storybook/react"
2+
3+
// Function that creates a decorator with a limited width container
4+
// Provides consistent centering and configurable max-width constraint
5+
export const withLimitedWidth = (maxWidth: number = 600): Decorator => {
6+
return (Story) => (
7+
<div style={{ maxWidth: `${maxWidth}px`, margin: "0 auto" }}>
8+
<Story />
9+
</div>
10+
)
11+
}

apps/storybook/stories/AutoApproveMenu.stories.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import type { Meta, StoryObj } from "@storybook/react"
22
import AutoApproveMenu from "../../../webview-ui/src/components/chat/AutoApproveMenu"
3+
import { withLimitedWidth } from "../src/decorators/withLimitedWidth"
34

45
const meta: Meta<typeof AutoApproveMenu> = {
56
title: "Chat/AutoApproveMenu",
67
component: AutoApproveMenu,
7-
parameters: {
8-
layout: "padded",
9-
},
10-
decorators: [
11-
(Story) => (
12-
<div style={{ maxWidth: "400px", margin: "0 auto" }}>
13-
<Story />
14-
</div>
15-
),
16-
],
8+
decorators: [withLimitedWidth(400)],
179
}
1810

1911
export default meta

apps/storybook/stories/AutoApproveSettings.stories.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import type { Meta, StoryObj } from "@storybook/react"
22
import { AutoApproveSettings } from "../../../webview-ui/src/components/settings/AutoApproveSettings"
3+
import { withLimitedWidth } from "../src/decorators/withLimitedWidth"
34

45
const meta: Meta<typeof AutoApproveSettings> = {
56
title: "Settings/AutoApproveSettings",
67
component: AutoApproveSettings,
7-
decorators: [
8-
(Story) => (
9-
<div style={{ maxWidth: "600px", margin: "0 auto" }}>
10-
<Story />
11-
</div>
12-
),
13-
],
8+
decorators: [withLimitedWidth(600)],
149
}
1510

1611
export default meta

0 commit comments

Comments
 (0)