@redis-ui/components 43.0.2 → 43.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HighlightedIcon/HighlightedIcon.cjs +26 -0
- package/dist/HighlightedIcon/HighlightedIcon.d.ts +3 -0
- package/dist/HighlightedIcon/HighlightedIcon.js +26 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.cjs +49 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.d.ts +5 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.js +47 -0
- package/dist/HighlightedIcon/HighlightedIcon.types.d.ts +8 -0
- package/dist/HighlightedIcon/index.d.ts +3 -0
- package/dist/Stepper/Stepper.cjs +14 -5
- package/dist/Stepper/Stepper.d.ts +2 -0
- package/dist/Stepper/Stepper.js +14 -5
- package/dist/Stepper/Stepper.utils.cjs +12 -0
- package/dist/Stepper/Stepper.utils.d.ts +2 -0
- package/dist/Stepper/Stepper.utils.js +12 -0
- package/dist/Stepper/components/Compose/Compose.d.ts +1 -0
- package/dist/Stepper/components/Step/Step.cjs +2 -0
- package/dist/Stepper/components/Step/Step.d.ts +1 -0
- package/dist/Stepper/components/Step/Step.js +2 -0
- package/dist/Stepper/components/Step/components/Compose/Compose.cjs +2 -9
- package/dist/Stepper/components/Step/components/Compose/Compose.js +2 -9
- package/dist/Stepper/components/Step/components/Separator/Separator.cjs +15 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.d.ts +3 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.js +15 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.cjs +24 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.d.ts +1 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.js +22 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.types.d.ts +5 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +74 -70
- package/package.json +2 -2
- package/skills/redis-ui-components/SKILL.md +0 -2
- package/skills/redis-ui-components/references/ActionIconButton.md +96 -0
- package/skills/redis-ui-components/references/AppBar.md +161 -0
- package/skills/redis-ui-components/references/AppSelectionMenu.md +184 -0
- package/skills/redis-ui-components/references/AutoCompleteSelect.md +193 -0
- package/skills/redis-ui-components/references/Badge.md +77 -0
- package/skills/redis-ui-components/references/Banner.md +563 -0
- package/skills/redis-ui-components/references/BoxSelectionGroup.md +487 -0
- package/skills/redis-ui-components/references/Breadcrumbs.md +214 -0
- package/skills/redis-ui-components/references/ButtonGroup.md +126 -0
- package/skills/redis-ui-components/references/Card.md +56 -0
- package/skills/redis-ui-components/references/Checkbox.md +171 -0
- package/skills/redis-ui-components/references/Chip.md +154 -0
- package/skills/redis-ui-components/references/ChipList.md +307 -0
- package/skills/redis-ui-components/references/CopyToClipboardButton.md +47 -0
- package/skills/redis-ui-components/references/CountryFlag.md +57 -0
- package/skills/redis-ui-components/references/Drawer.md +298 -0
- package/skills/redis-ui-components/references/Filters.md +162 -0
- package/skills/redis-ui-components/references/FormField.md +678 -0
- package/skills/redis-ui-components/references/IconButton.md +63 -0
- package/skills/redis-ui-components/references/Input.md +295 -0
- package/skills/redis-ui-components/references/KeyValueList.md +501 -0
- package/skills/redis-ui-components/references/Label.md +238 -0
- package/skills/redis-ui-components/references/Link.md +402 -0
- package/skills/redis-ui-components/references/Loader.md +100 -0
- package/skills/redis-ui-components/references/Menu.md +988 -0
- package/skills/redis-ui-components/references/MidBar.md +358 -0
- package/skills/redis-ui-components/references/Modal.md +525 -0
- package/skills/redis-ui-components/references/MoreInfoIcon.md +119 -0
- package/skills/redis-ui-components/references/MultiSelect.md +558 -0
- package/skills/redis-ui-components/references/NumericInput.md +322 -0
- package/skills/redis-ui-components/references/Overflow.md +127 -0
- package/skills/redis-ui-components/references/Pagination.md +151 -0
- package/skills/redis-ui-components/references/PasswordInput.md +262 -0
- package/skills/redis-ui-components/references/Popover.md +868 -0
- package/skills/redis-ui-components/references/ProfileIcon.md +65 -0
- package/skills/redis-ui-components/references/ProgressBar.md +103 -0
- package/skills/redis-ui-components/references/QuantityCounter.md +555 -0
- package/skills/redis-ui-components/references/RadioGroup.md +265 -0
- package/skills/redis-ui-components/references/ScreenReaderAnnounce.md +147 -0
- package/skills/redis-ui-components/references/SearchBar.md +242 -0
- package/skills/redis-ui-components/references/SearchInput.md +213 -0
- package/skills/redis-ui-components/references/Section.md +349 -0
- package/skills/redis-ui-components/references/SideBar.md +468 -0
- package/skills/redis-ui-components/references/Slider.md +398 -0
- package/skills/redis-ui-components/references/Stepper.md +288 -0
- package/skills/redis-ui-components/references/Switch.md +193 -0
- package/skills/redis-ui-components/references/Tabs.md +383 -0
- package/skills/redis-ui-components/references/TextArea.md +139 -0
- package/skills/redis-ui-components/references/TextButton.md +217 -0
- package/skills/redis-ui-components/references/Toast.md +399 -0
- package/skills/redis-ui-components/references/ToggleButton.md +163 -0
- package/skills/redis-ui-components/references/Tooltip.md +636 -0
- package/skills/redis-ui-components/references/Typography.md +323 -0
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
# Banner
|
|
2
|
+
|
|
3
|
+
Semantic banner and strip component with automatic icon, message, action, and close-button composition. It also exposes a lower-level `Banner.Compose` surface for custom layouts.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> Icons used in examples are imported separately from `@redislabsdev/redis-ui-icons`.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
### Banner
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
|------|------|---------|-------------|
|
|
19
|
+
| show | `boolean` | `true` | Controls whether the banner renders at all |
|
|
20
|
+
| onClose | `VoidFunction` | - | Close callback passed to the compose surface and close actions |
|
|
21
|
+
| variant | `'informative' \| 'notice' \| 'danger' \| 'attention' \| 'success'` | `informative` | Semantic banner variant |
|
|
22
|
+
| size | `'M' \| 'S'` | `M` | Banner density |
|
|
23
|
+
| layoutVariant | `'banner' \| 'strip'` | `banner` | Full banner or strip layout |
|
|
24
|
+
| message | `ReactNode` | - | Message content displayed by the banner |
|
|
25
|
+
| actions | `{ primary?: BannerActionType; secondary?: BannerActionType }` | - | Primary and secondary action descriptors |
|
|
26
|
+
| customIcon | `IconType` | - | Custom icon rendered instead of the semantic icon |
|
|
27
|
+
| showIcon | `boolean` | `true` | Shows or hides the leading icon |
|
|
28
|
+
| showCloseButton | `boolean` | `!!onClose` | Shows or hides the close button |
|
|
29
|
+
|
|
30
|
+
The root banner forwards standard `div` attributes through the compose container.
|
|
31
|
+
|
|
32
|
+
### Banner.Compose
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
|------|------|---------|-------------|
|
|
36
|
+
| children | `ReactNode` | required | Composed banner contents |
|
|
37
|
+
| variant | `'informative' \| 'notice' \| 'danger' \| 'attention' \| 'success'` | `informative` | Semantic banner variant for the container |
|
|
38
|
+
| size | `'M' \| 'S'` | `M` | Banner density for composed children |
|
|
39
|
+
| layoutVariant | `'banner' \| 'strip'` | `banner` | Container layout variant |
|
|
40
|
+
| onClose | `VoidFunction` | - | Close callback shared through banner context |
|
|
41
|
+
|
|
42
|
+
`Banner.Compose` accepts standard `div` attributes.
|
|
43
|
+
|
|
44
|
+
### Banner.Actions
|
|
45
|
+
|
|
46
|
+
| Prop | Type | Default | Description |
|
|
47
|
+
|------|------|---------|-------------|
|
|
48
|
+
| primary | `BannerActionType` | - | Primary action descriptor |
|
|
49
|
+
| secondary | `BannerActionType` | - | Secondary action descriptor |
|
|
50
|
+
|
|
51
|
+
`Banner.Actions` accepts standard `div` attributes and renders nothing when both actions are missing.
|
|
52
|
+
|
|
53
|
+
### Banner.Actions.Compose
|
|
54
|
+
|
|
55
|
+
| Prop | Type | Default | Description |
|
|
56
|
+
|------|------|---------|-------------|
|
|
57
|
+
| children | `ReactNode` | required | Custom action-row contents |
|
|
58
|
+
|
|
59
|
+
`Banner.Actions.Compose` accepts standard `div` attributes.
|
|
60
|
+
|
|
61
|
+
### Banner.Actions.Action
|
|
62
|
+
|
|
63
|
+
| Prop | Type | Default | Description |
|
|
64
|
+
|------|------|---------|-------------|
|
|
65
|
+
| label | `string` | required | Action label text |
|
|
66
|
+
| onClick | `VoidFunction` | required | Action callback |
|
|
67
|
+
| closes | `boolean` | `false` | Closes the banner after the action runs |
|
|
68
|
+
| icon | `IconType` | - | Optional icon shown before the label |
|
|
69
|
+
| variant | `'primary' \| 'secondary'` | `primary` | Outline style for the action button |
|
|
70
|
+
| size | `'M' \| 'S'` | `M` | Action button density |
|
|
71
|
+
| disabled | `boolean` | `false` | Disables the action button |
|
|
72
|
+
|
|
73
|
+
`Banner.Actions.Action` accepts standard `button` attributes.
|
|
74
|
+
|
|
75
|
+
### Banner.Icon
|
|
76
|
+
|
|
77
|
+
| Prop | Type | Default | Description |
|
|
78
|
+
|------|------|---------|-------------|
|
|
79
|
+
| variant | `'informative' \| 'notice' \| 'danger' \| 'attention' \| 'success'` | `informative` | Semantic icon variant |
|
|
80
|
+
| customIcon | `IconType` | - | Custom icon override |
|
|
81
|
+
|
|
82
|
+
`Banner.Icon` also inherits `MonochromeIconProps` from `@redislabsdev/redis-ui-icons`.
|
|
83
|
+
|
|
84
|
+
### Banner.Message
|
|
85
|
+
|
|
86
|
+
| Prop | Type | Default | Description |
|
|
87
|
+
|------|------|---------|-------------|
|
|
88
|
+
| children | `ReactNode` | required | Message content |
|
|
89
|
+
|
|
90
|
+
`Banner.Message` inherits `Typography.Body` props.
|
|
91
|
+
|
|
92
|
+
### Banner.CloseButton
|
|
93
|
+
|
|
94
|
+
| Prop | Type | Default | Description |
|
|
95
|
+
|------|------|---------|-------------|
|
|
96
|
+
| size | `'M' \| 'S'` | `M` | Close icon size inherited through banner context |
|
|
97
|
+
| variant | `'informative' \| 'notice' \| 'danger' \| 'attention' \| 'success'` | `informative` | Semantic color variant inherited through banner context |
|
|
98
|
+
|
|
99
|
+
`Banner.CloseButton` accepts standard `button` attributes.
|
|
100
|
+
|
|
101
|
+
### Banner.Split
|
|
102
|
+
|
|
103
|
+
| Prop | Type | Default | Description |
|
|
104
|
+
|------|------|---------|-------------|
|
|
105
|
+
| minWidth | `string \| number \| undefined` | - | Minimum width for the split spacer |
|
|
106
|
+
|
|
107
|
+
`Banner.Split` accepts standard `div` attributes.
|
|
108
|
+
|
|
109
|
+
## Sub-components
|
|
110
|
+
|
|
111
|
+
- `Banner.Compose` - Low-level banner container used for custom composition.
|
|
112
|
+
- `Banner.Icon` - Semantic banner icon wrapper with optional custom icon.
|
|
113
|
+
- `Banner.Message` - Message content wrapper for banner text.
|
|
114
|
+
- `Banner.Actions` - Default action row wrapper for primary and secondary actions.
|
|
115
|
+
- `Banner.Actions.Compose` - Low-level action-row container for fully custom action layouts.
|
|
116
|
+
- `Banner.Actions.Action` - Semantic action button used inside `Banner.Actions.Compose`.
|
|
117
|
+
- `Banner.CloseButton` - Close button alias that uses banner context.
|
|
118
|
+
- `Banner.Split` - Spacer/split element between the banner message and actions.
|
|
119
|
+
|
|
120
|
+
## Examples
|
|
121
|
+
|
|
122
|
+
### Playground
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import { Banner, BannerProps } from '@redislabsdev/redis-ui-components';
|
|
126
|
+
import { unflatten } from '../../helpers/unflatten';
|
|
127
|
+
|
|
128
|
+
const handleClose = () => {};
|
|
129
|
+
const handleClick = () => {};
|
|
130
|
+
|
|
131
|
+
function Render(args: unknown) {
|
|
132
|
+
const props = unflatten(args) as BannerProps;
|
|
133
|
+
|
|
134
|
+
if (props.actions?.primary) {
|
|
135
|
+
props.actions.primary.onClick = handleClick;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (props.actions?.secondary) {
|
|
139
|
+
props.actions.secondary.onClick = handleClick;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return <Banner {...props} onClose={handleClose} />;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### BasicBanner
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
150
|
+
|
|
151
|
+
<>
|
|
152
|
+
<Banner message="Basic banner" />
|
|
153
|
+
<Banner layoutVariant="strip" message="Basic banner strip" />
|
|
154
|
+
</>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### SemanticBanners
|
|
158
|
+
|
|
159
|
+
> We support a few different semantic variants of banners.
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
import { Banner, BannerVariant, bannerVariants } from '@redislabsdev/redis-ui-components';
|
|
163
|
+
import { PhoneIcon } from '@redislabsdev/redis-ui-icons';
|
|
164
|
+
|
|
165
|
+
const handleClose = () => {};
|
|
166
|
+
const handleClick = () => {};
|
|
167
|
+
|
|
168
|
+
const restOfBannerProps = {
|
|
169
|
+
onClose: handleClose,
|
|
170
|
+
actions: {
|
|
171
|
+
primary: {
|
|
172
|
+
label: 'Primary',
|
|
173
|
+
onClick: handleClick,
|
|
174
|
+
icon: PhoneIcon
|
|
175
|
+
},
|
|
176
|
+
secondary: {
|
|
177
|
+
label: 'Secondary',
|
|
178
|
+
onClick: handleClick
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const renderSemanticBanner = (variant: BannerVariant, idx: number) => (
|
|
184
|
+
<Banner
|
|
185
|
+
key={idx}
|
|
186
|
+
variant={variant}
|
|
187
|
+
message={
|
|
188
|
+
<>
|
|
189
|
+
variant = <strong>"{variant}"</strong>
|
|
190
|
+
</>
|
|
191
|
+
}
|
|
192
|
+
{...restOfBannerProps}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
<>
|
|
197
|
+
{bannerVariants.map(renderSemanticBanner)}
|
|
198
|
+
</>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### SemanticStrips
|
|
202
|
+
|
|
203
|
+
> We support a few different semantic variants of banner strips.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
import { Banner, BannerVariant, bannerVariants } from '@redislabsdev/redis-ui-components';
|
|
207
|
+
import { PhoneIcon } from '@redislabsdev/redis-ui-icons';
|
|
208
|
+
|
|
209
|
+
const handleClose = () => {};
|
|
210
|
+
const handleClick = () => {};
|
|
211
|
+
|
|
212
|
+
const restOfBannerProps = {
|
|
213
|
+
onClose: handleClose,
|
|
214
|
+
actions: {
|
|
215
|
+
primary: {
|
|
216
|
+
label: 'Primary',
|
|
217
|
+
onClick: handleClick,
|
|
218
|
+
icon: PhoneIcon
|
|
219
|
+
},
|
|
220
|
+
secondary: {
|
|
221
|
+
label: 'Secondary',
|
|
222
|
+
onClick: handleClick
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const renderSemanticBanner = (variant: BannerVariant, idx: number) => (
|
|
228
|
+
<Banner
|
|
229
|
+
key={idx}
|
|
230
|
+
variant={variant}
|
|
231
|
+
layoutVariant="strip"
|
|
232
|
+
message={
|
|
233
|
+
<>
|
|
234
|
+
variant = <strong>"{variant}"</strong>
|
|
235
|
+
</>
|
|
236
|
+
}
|
|
237
|
+
{...restOfBannerProps}
|
|
238
|
+
/>
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
<>
|
|
242
|
+
{bannerVariants.map(renderSemanticBanner)}
|
|
243
|
+
</>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### BannerSize
|
|
247
|
+
|
|
248
|
+
> Banner can be one of the following sizes
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
252
|
+
|
|
253
|
+
const handleClose = () => {};
|
|
254
|
+
const handleClick = () => {};
|
|
255
|
+
|
|
256
|
+
const restOfBannerProps = {
|
|
257
|
+
onClose: handleClose,
|
|
258
|
+
actions: {
|
|
259
|
+
primary: {
|
|
260
|
+
label: 'Primary',
|
|
261
|
+
onClick: handleClick
|
|
262
|
+
},
|
|
263
|
+
secondary: {
|
|
264
|
+
label: 'Secondary',
|
|
265
|
+
onClick: handleClick
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
<>
|
|
271
|
+
<Banner message="Medium Banner (size='M')" size="M" {...restOfBannerProps} />
|
|
272
|
+
<Banner message="Small Banner (size='S')" size="S" {...restOfBannerProps} />
|
|
273
|
+
<Banner message="Default size Banner strip" layoutVariant="strip" {...restOfBannerProps} />
|
|
274
|
+
</>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### MessageFormatting
|
|
278
|
+
|
|
279
|
+
> Message can contain any JSX elements
|
|
280
|
+
|
|
281
|
+
```tsx
|
|
282
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
283
|
+
|
|
284
|
+
const handleClose = () => {};
|
|
285
|
+
|
|
286
|
+
<>
|
|
287
|
+
<Banner message="Simple text message" />
|
|
288
|
+
<Banner
|
|
289
|
+
variant="notice"
|
|
290
|
+
message={
|
|
291
|
+
<>
|
|
292
|
+
<strong>JSX formatted</strong> <em style={{ color: 'limegreen' }}>message</em>
|
|
293
|
+
</>
|
|
294
|
+
}
|
|
295
|
+
/>
|
|
296
|
+
<Banner
|
|
297
|
+
variant="attention"
|
|
298
|
+
message={
|
|
299
|
+
<>
|
|
300
|
+
This message is
|
|
301
|
+
<br />
|
|
302
|
+
forced multiline
|
|
303
|
+
</>
|
|
304
|
+
}
|
|
305
|
+
onClose={handleClose}
|
|
306
|
+
/>
|
|
307
|
+
<Banner
|
|
308
|
+
layoutVariant="strip"
|
|
309
|
+
variant="notice"
|
|
310
|
+
message={
|
|
311
|
+
<>
|
|
312
|
+
<strong>JSX formatted</strong> <em style={{ color: 'limegreen' }}>message</em>
|
|
313
|
+
</>
|
|
314
|
+
}
|
|
315
|
+
/>
|
|
316
|
+
<Banner
|
|
317
|
+
layoutVariant="strip"
|
|
318
|
+
variant="attention"
|
|
319
|
+
message={
|
|
320
|
+
<>
|
|
321
|
+
This message is
|
|
322
|
+
<br />
|
|
323
|
+
forced multiline
|
|
324
|
+
</>
|
|
325
|
+
}
|
|
326
|
+
onClose={handleClose}
|
|
327
|
+
/>
|
|
328
|
+
</>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Actions
|
|
332
|
+
|
|
333
|
+
> Each Banner can contain two independent action buttons: primary and secondary. Each of them can be added separately.
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
337
|
+
|
|
338
|
+
const handleClick = () => {};
|
|
339
|
+
|
|
340
|
+
<>
|
|
341
|
+
<Banner
|
|
342
|
+
message="Banner with both actions"
|
|
343
|
+
actions={{
|
|
344
|
+
primary: { label: 'Primary Action', onClick: handleClick },
|
|
345
|
+
secondary: { label: 'Secondary Action', onClick: handleClick }
|
|
346
|
+
}}
|
|
347
|
+
/>
|
|
348
|
+
<Banner
|
|
349
|
+
message="Banner with Primary action"
|
|
350
|
+
actions={{
|
|
351
|
+
primary: { label: 'Primary Action', onClick: handleClick }
|
|
352
|
+
}}
|
|
353
|
+
/>
|
|
354
|
+
<Banner
|
|
355
|
+
message="Banner with Secondary action"
|
|
356
|
+
actions={{
|
|
357
|
+
secondary: { label: 'Secondary Action', onClick: handleClick }
|
|
358
|
+
}}
|
|
359
|
+
/>
|
|
360
|
+
<Banner
|
|
361
|
+
layoutVariant="strip"
|
|
362
|
+
message="Banner strip with actions"
|
|
363
|
+
actions={{
|
|
364
|
+
primary: { label: 'Primary Action', onClick: handleClick },
|
|
365
|
+
secondary: { label: 'Secondary Action', onClick: handleClick }
|
|
366
|
+
}}
|
|
367
|
+
/>
|
|
368
|
+
</>
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### AutoClosingActions
|
|
372
|
+
|
|
373
|
+
> Each Banner Action allows to close banner automatically after performing the action. Use `closes` flag of the action to enable it.
|
|
374
|
+
>
|
|
375
|
+
> `onClose` handler should be specified to perform the close operation.
|
|
376
|
+
>
|
|
377
|
+
> If necessary, the close button can be hidden by setting `showCloseButton={false}`.
|
|
378
|
+
|
|
379
|
+
```tsx
|
|
380
|
+
import { useState } from 'react';
|
|
381
|
+
import { Banner, Button } from '@redislabsdev/redis-ui-components';
|
|
382
|
+
|
|
383
|
+
const handleClick = () => {};
|
|
384
|
+
|
|
385
|
+
function Render() {
|
|
386
|
+
const [show, setShow] = useState(true);
|
|
387
|
+
|
|
388
|
+
return (
|
|
389
|
+
<>
|
|
390
|
+
{show || (
|
|
391
|
+
<Button onClick={() => setShow(!show)} style={{ minHeight: 42 }}>
|
|
392
|
+
Show Banner
|
|
393
|
+
</Button>
|
|
394
|
+
)}
|
|
395
|
+
<Banner
|
|
396
|
+
show={show}
|
|
397
|
+
message="Auto-closing Actions"
|
|
398
|
+
actions={{
|
|
399
|
+
primary: { label: 'Close 1', onClick: handleClick, closes: true },
|
|
400
|
+
secondary: { label: 'Close 2', onClick: handleClick, closes: true }
|
|
401
|
+
}}
|
|
402
|
+
onClose={() => setShow(false)}
|
|
403
|
+
/>
|
|
404
|
+
</>
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### CustomIcon
|
|
410
|
+
|
|
411
|
+
> Banner can have custom icon. Use `customIcon` property to specify it.
|
|
412
|
+
|
|
413
|
+
```tsx
|
|
414
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
415
|
+
import { ShardIcon } from '@redislabsdev/redis-ui-icons';
|
|
416
|
+
|
|
417
|
+
<>
|
|
418
|
+
<Banner message="Banner with custom icon" customIcon={ShardIcon} />
|
|
419
|
+
<Banner layoutVariant="strip" message="Banner strip with custom icon" customIcon={ShardIcon} />
|
|
420
|
+
</>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### InvisibleIcon
|
|
424
|
+
|
|
425
|
+
> Icon of the banner can be hidden. Use `showIcon = false` to hide it.
|
|
426
|
+
|
|
427
|
+
```tsx
|
|
428
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
429
|
+
|
|
430
|
+
<>
|
|
431
|
+
<Banner message="Banner without icon" showIcon={false} />
|
|
432
|
+
<Banner layoutVariant="strip" message="Banner strip without icon" showIcon={false} />
|
|
433
|
+
</>
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### CloseButton
|
|
437
|
+
|
|
438
|
+
> To show the close button, `onClose` handler should be specified.
|
|
439
|
+
>
|
|
440
|
+
> The close button can be forced to be hidden, even if a close handler is specified. Use `showCloseButton={false}` to hide it.
|
|
441
|
+
|
|
442
|
+
```tsx
|
|
443
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
444
|
+
|
|
445
|
+
const handleClose = () => {};
|
|
446
|
+
const handleClick = () => {};
|
|
447
|
+
|
|
448
|
+
<>
|
|
449
|
+
<Banner message="Banner with close button" onClose={handleClose} />
|
|
450
|
+
<Banner
|
|
451
|
+
message="Banner with forcibly hidden close button"
|
|
452
|
+
onClose={handleClose}
|
|
453
|
+
showCloseButton={false}
|
|
454
|
+
actions={{ secondary: { label: 'Save and Close', onClick: handleClick, closes: true } }}
|
|
455
|
+
/>
|
|
456
|
+
<Banner layoutVariant="strip" message="Banner strip with close button" onClose={handleClose} />
|
|
457
|
+
<Banner
|
|
458
|
+
layoutVariant="strip"
|
|
459
|
+
message="Banner strip with forcibly hidden close button"
|
|
460
|
+
onClose={handleClose}
|
|
461
|
+
showCloseButton={false}
|
|
462
|
+
actions={{ secondary: { label: 'Save and Close', onClick: handleClick, closes: true } }}
|
|
463
|
+
/>
|
|
464
|
+
</>
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### ForceBannerWidth
|
|
468
|
+
|
|
469
|
+
> If the banner or strip is narrower than the content, it can wrap long message text.
|
|
470
|
+
>
|
|
471
|
+
> If the banner is stretched, it may leave space to the right of the short text. The strip always centers the entire content.
|
|
472
|
+
|
|
473
|
+
```tsx
|
|
474
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
475
|
+
|
|
476
|
+
const handleClose = () => {};
|
|
477
|
+
const handleClick = () => {};
|
|
478
|
+
|
|
479
|
+
<>
|
|
480
|
+
<Banner message="Short msg" style={{ width: '100%' }} />
|
|
481
|
+
<Banner
|
|
482
|
+
message="Short msg"
|
|
483
|
+
actions={{ secondary: { label: 'Action', onClick: handleClick } }}
|
|
484
|
+
style={{ width: 'auto' }}
|
|
485
|
+
/>
|
|
486
|
+
<Banner
|
|
487
|
+
onClose={handleClose}
|
|
488
|
+
message="Very very very very very very very very long message is wrapping"
|
|
489
|
+
actions={{ secondary: { label: 'Action', onClick: handleClick } }}
|
|
490
|
+
style={{ width: 'auto' }}
|
|
491
|
+
/>
|
|
492
|
+
<Banner layoutVariant="strip" message="Short msg" />
|
|
493
|
+
<Banner
|
|
494
|
+
layoutVariant="strip"
|
|
495
|
+
message="Short msg"
|
|
496
|
+
actions={{ secondary: { label: 'Action', onClick: handleClick } }}
|
|
497
|
+
/>
|
|
498
|
+
<Banner
|
|
499
|
+
layoutVariant="strip"
|
|
500
|
+
onClose={handleClose}
|
|
501
|
+
message="Very very very very very very very very long message is wrapping"
|
|
502
|
+
actions={{ secondary: { label: 'Action', onClick: handleClick } }}
|
|
503
|
+
/>
|
|
504
|
+
</>
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### CompositionWithStyling
|
|
508
|
+
|
|
509
|
+
> Banner can be custom composed by using `Banner.Compose` as the root element. Composition elements can be styled.
|
|
510
|
+
|
|
511
|
+
```tsx
|
|
512
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
513
|
+
import { ShardIcon } from '@redislabsdev/redis-ui-icons';
|
|
514
|
+
|
|
515
|
+
<Banner.Compose
|
|
516
|
+
style={{ backgroundColor: '#80ecf0a8', borderColor: '#a6d7d9', color: '#0a585b' }}
|
|
517
|
+
>
|
|
518
|
+
<Banner.Icon customIcon={ShardIcon} customColor="#00999f" />
|
|
519
|
+
<Banner.Message>
|
|
520
|
+
This banner composed using custom icon and message with overridden style
|
|
521
|
+
</Banner.Message>
|
|
522
|
+
</Banner.Compose>
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### CompositionOfActions
|
|
526
|
+
|
|
527
|
+
> Actions have their own composition. Use `Banner.Actions.Compose` and `Banner.Actions.Action`.
|
|
528
|
+
|
|
529
|
+
```tsx
|
|
530
|
+
import { Banner } from '@redislabsdev/redis-ui-components';
|
|
531
|
+
import { ShardIcon, StarsIcon } from '@redislabsdev/redis-ui-icons';
|
|
532
|
+
|
|
533
|
+
const handleClose = () => {};
|
|
534
|
+
const handleClick = () => {};
|
|
535
|
+
|
|
536
|
+
<Banner.Compose variant="success" size="S" onClose={handleClose}>
|
|
537
|
+
<Banner.Icon customIcon={StarsIcon} />
|
|
538
|
+
<Banner.Message>Message text</Banner.Message>
|
|
539
|
+
<Banner.Split />
|
|
540
|
+
<Banner.Actions.Compose>
|
|
541
|
+
<Banner.Actions.Action
|
|
542
|
+
label="Primary"
|
|
543
|
+
icon={ShardIcon}
|
|
544
|
+
closes
|
|
545
|
+
variant="primary"
|
|
546
|
+
onClick={handleClick}
|
|
547
|
+
/>
|
|
548
|
+
<Banner.Actions.Action label="Other" variant="secondary" onClick={handleClick} />
|
|
549
|
+
</Banner.Actions.Compose>
|
|
550
|
+
<Banner.CloseButton />
|
|
551
|
+
</Banner.Compose>
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
## Notes
|
|
555
|
+
|
|
556
|
+
- Banner semantic variants are `informative`, `notice`, `danger`, `attention`, and `success`.
|
|
557
|
+
- `showIcon={false}` hides the leading icon.
|
|
558
|
+
- `showCloseButton={false}` hides the close button even when `onClose` is provided.
|
|
559
|
+
- Action descriptors can auto-close the banner when `closes` is set, but `onClose` must be available for the close behavior to run.
|
|
560
|
+
- Banner and strip layouts wrap long content; strips center the entire content.
|
|
561
|
+
- `Banner.Compose` is the right entry point for custom layouts and can be styled directly.
|
|
562
|
+
- `Banner.Actions.Compose` and `Banner.Actions.Action` expose the extended action composition surface.
|
|
563
|
+
- Banner message content can contain any JSX.
|