Skip to content

Commit 7413c7e

Browse files
author
mkrause
committed
Move story descriptions to doc blocks.
1 parent 0306a8b commit 7413c7e

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

src/components/containers/Banner/Banner.stories.tsx

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
|* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
33
|* the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { dedent } from 'ts-dedent';
65
import * as React from 'react';
76
import { idToCssIdent } from '../../../util/reactUtil.ts';
87
import { startViewTransition } from '../../../util/reactDomUtil.ts';
98

109
import type { Meta, StoryObj } from '@storybook/react';
11-
import { storyDescription } from '../../../util/storybook/storybookUtil.ts';
1210
import { LayoutDecorator } from '../../../util/storybook/LayoutDecorator.tsx';
1311
import { loremIpsum, LoremIpsum } from '../../../util/storybook/LoremIpsum.tsx';
1412

@@ -82,11 +80,11 @@ export const BannerStandard: Story = {
8280
},
8381
};
8482

83+
/**
84+
* If the `onClose` prop is given, the component will be rendered with a close button. It is up to the consumer
85+
* to handle the close event and (for example) hide the `Banner`.
86+
*/
8587
export const BannerWithCloseButton: Story = {
86-
...storyDescription(dedent`
87-
If the \`onClose\` prop is given, the component will be rendered with a close button. It is up to the consumer
88-
to handle the close event and (for example) hide the \`Banner\`.
89-
`),
9088
args: {
9189
title: `Banner title`,
9290
children: `A banner with a close button to hide the banner.`,
@@ -100,57 +98,48 @@ export const BannerWithTitleOnly: Story = {
10098
},
10199
};
102100

101+
/** You can specify additional custom actions to be displayed in the banner using `Banner.ActionButton`. */
103102
export const BannerWithAction: Story = {
104-
...storyDescription(dedent`
105-
You can specify additional custom actions to be displayed in the banner.
106-
`),
107103
args: {
108104
children: 'A banner with a button action.',
109105
onClose: () => {},
110106
actions: <ExampleActionButton/>,
111107
},
112108
};
113109

110+
/** Besides text buttons, you can also render icon buttons as actions using `Banner.ActionIcon`. */
114111
export const BannerWithMultipleActions: Story = {
115-
...storyDescription(dedent`
116-
Besides text buttons, you can also render icon buttons as actions.
117-
`),
118112
args: {
119113
children: 'A banner with two actions.',
120114
onClose: () => {},
121115
actions: <ExampleActions/>,
122116
},
123117
};
124118

125-
119+
/** The title should always fit on a single line, if it overflows it should be truncated. */
126120
export const BannerWithTitleOverflow: Story = {
127-
...storyDescription(dedent`
128-
The title should always fit on a single line, if it overflows it should be truncated.
129-
`),
130121
args: {
131122
title: loremIpsum(),
132123
onClose: () => {},
133124
actions: <ExampleActionButton/>,
134125
},
135126
};
136127

128+
/**
129+
* In a compact banner, if the message is too long to be displayed in one line, it should automatically wrap and move
130+
* down to below the title. Note that the message won't extend below the buttons, if you need this behavior you must
131+
* explicitly set `compact` to `false`.
132+
*/
137133
export const BannerWithTextWrap: Story = {
138-
...storyDescription(dedent`
139-
In a compact banner, if the message is too long to be displayed in one line, it should automatically wrap and move
140-
down to below the title. Note that the message won't extend below the buttons, if you need this behavior you must
141-
explicitly set \`compact\` to \`false\`.
142-
`),
143134
args: {
144135
children: <LoremIpsum/>,
145136
onClose: () => {},
146137
actions: <ExampleActions/>,
147-
},
148-
};
138+
},
139+
};
149140

150-
export const BannerWithTitleOverflowAndTextWrap: Story = {
151-
...storyDescription(dedent`
152-
This shows both the title truncation and message wrap at the same time.
153-
`),
141+
/** This shows both the title truncation and message wrap at the same time. */
142+
export const BannerWithTitleOverflowAndTextWrap: Story = {
154143
args: {
155144
title: loremIpsum(),
156145
children: <LoremIpsum/>,
@@ -159,10 +148,8 @@ export const BannerWithTextWrap: Story = {
159148
},
160149
};
161150

151+
/** Banners should always look visually light themed, even when the context is in dark mode. */
162152
export const BannerWithThemedContent: Story = {
163-
...storyDescription(dedent`
164-
Banner should always look visually light themed, even when the context is in dark mode.
165-
`),
166153
args: {
167154
title: 'Banner with themed content',
168155
compact: false,
@@ -227,8 +214,8 @@ export const BannerError: Story = {
227214
},
228215
};
229216

217+
/** By default, subsequent banners are spaced out. To disable this, set `trimmed` to `true`. */
230218
export const BannersStacked: Story = {
231-
...storyDescription(`By default, subsequent banners are spaced out. To disable this, use \`trimmed\`.`),
232219
render: args => (
233220
<>
234221
<BannerControlled {...args} variant="info" onClose={() => {}}/>
@@ -239,8 +226,8 @@ export const BannersStacked: Story = {
239226
),
240227
};
241228

229+
/** If `trimmed` is enabled, no exterior spacing is applied. */
242230
export const BannersStackedTrimmed: Story = {
243-
...storyDescription(`If \`trimmed\` is enabled, no exterior spacing is applied.`),
244231
render: args => (
245232
<>
246233
<BannerControlled trimmed {...args} variant="info" onClose={() => {}}/>

0 commit comments

Comments
 (0)