2
2
|* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
3
3
|* the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
- import { dedent } from 'ts-dedent' ;
6
5
import * as React from 'react' ;
7
6
import { idToCssIdent } from '../../../util/reactUtil.ts' ;
8
7
import { startViewTransition } from '../../../util/reactDomUtil.ts' ;
9
8
10
9
import type { Meta , StoryObj } from '@storybook/react' ;
11
- import { storyDescription } from '../../../util/storybook/storybookUtil.ts' ;
12
10
import { LayoutDecorator } from '../../../util/storybook/LayoutDecorator.tsx' ;
13
11
import { loremIpsum , LoremIpsum } from '../../../util/storybook/LoremIpsum.tsx' ;
14
12
@@ -82,11 +80,11 @@ export const BannerStandard: Story = {
82
80
} ,
83
81
} ;
84
82
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
+ */
85
87
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
- ` ) ,
90
88
args : {
91
89
title : `Banner title` ,
92
90
children : `A banner with a close button to hide the banner.` ,
@@ -100,57 +98,48 @@ export const BannerWithTitleOnly: Story = {
100
98
} ,
101
99
} ;
102
100
101
+ /** You can specify additional custom actions to be displayed in the banner using `Banner.ActionButton`. */
103
102
export const BannerWithAction : Story = {
104
- ...storyDescription ( dedent `
105
- You can specify additional custom actions to be displayed in the banner.
106
- ` ) ,
107
103
args : {
108
104
children : 'A banner with a button action.' ,
109
105
onClose : ( ) => { } ,
110
106
actions : < ExampleActionButton /> ,
111
107
} ,
112
108
} ;
113
109
110
+ /** Besides text buttons, you can also render icon buttons as actions using `Banner.ActionIcon`. */
114
111
export const BannerWithMultipleActions : Story = {
115
- ...storyDescription ( dedent `
116
- Besides text buttons, you can also render icon buttons as actions.
117
- ` ) ,
118
112
args : {
119
113
children : 'A banner with two actions.' ,
120
114
onClose : ( ) => { } ,
121
115
actions : < ExampleActions /> ,
122
116
} ,
123
117
} ;
124
118
125
-
119
+ /** The title should always fit on a single line, if it overflows it should be truncated. */
126
120
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
- ` ) ,
130
121
args : {
131
122
title : loremIpsum ( ) ,
132
123
onClose : ( ) => { } ,
133
124
actions : < ExampleActionButton /> ,
134
125
} ,
135
126
} ;
136
127
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
+ */
137
133
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
- ` ) ,
143
134
args : {
144
135
children : < LoremIpsum /> ,
145
136
onClose : ( ) => { } ,
146
137
actions : < ExampleActions /> ,
147
- } ,
148
- } ;
138
+ } ,
139
+ } ;
149
140
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 = {
154
143
args : {
155
144
title : loremIpsum ( ) ,
156
145
children : < LoremIpsum /> ,
@@ -159,10 +148,8 @@ export const BannerWithTextWrap: Story = {
159
148
} ,
160
149
} ;
161
150
151
+ /** Banners should always look visually light themed, even when the context is in dark mode. */
162
152
export const BannerWithThemedContent : Story = {
163
- ...storyDescription ( dedent `
164
- Banner should always look visually light themed, even when the context is in dark mode.
165
- ` ) ,
166
153
args : {
167
154
title : 'Banner with themed content' ,
168
155
compact : false ,
@@ -227,8 +214,8 @@ export const BannerError: Story = {
227
214
} ,
228
215
} ;
229
216
217
+ /** By default, subsequent banners are spaced out. To disable this, set `trimmed` to `true`. */
230
218
export const BannersStacked : Story = {
231
- ...storyDescription ( `By default, subsequent banners are spaced out. To disable this, use \`trimmed\`.` ) ,
232
219
render : args => (
233
220
< >
234
221
< BannerControlled { ...args } variant = "info" onClose = { ( ) => { } } />
@@ -239,8 +226,8 @@ export const BannersStacked: Story = {
239
226
) ,
240
227
} ;
241
228
229
+ /** If `trimmed` is enabled, no exterior spacing is applied. */
242
230
export const BannersStackedTrimmed : Story = {
243
- ...storyDescription ( `If \`trimmed\` is enabled, no exterior spacing is applied.` ) ,
244
231
render : args => (
245
232
< >
246
233
< BannerControlled trimmed { ...args } variant = "info" onClose = { ( ) => { } } />
0 commit comments