@transferwise/components 0.0.0-experimental-cdb8834 → 0.0.0-experimental-276a15d
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/build/main.css +5 -11
- package/build/prompt/ActionPrompt/ActionPrompt.js +0 -2
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +0 -2
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.js.map +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.mjs.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.js +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/styles/main.css +5 -11
- package/build/styles/prompt/ActionPrompt/ActionPrompt.css +0 -4
- package/build/styles/prompt/InfoPrompt/InfoPrompt.css +3 -3
- package/build/styles/prompt/InlinePrompt/InlinePrompt.css +2 -3
- package/build/styles/prompt/PrimitivePrompt/PrimitivePrompt.css +0 -1
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +7 -0
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
- package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts +4 -2
- package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/iconButton/IconButton.story.tsx +173 -48
- package/src/iconButton/IconButton.test.story.tsx +194 -0
- package/src/listItem/_stories/ListItem.story.tsx +0 -1
- package/src/main.css +5 -11
- package/src/prompt/ActionPrompt/ActionPrompt.accessibility.docs.mdx +1 -17
- package/src/prompt/ActionPrompt/ActionPrompt.css +0 -4
- package/src/prompt/ActionPrompt/ActionPrompt.less +1 -5
- package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +290 -119
- package/src/prompt/ActionPrompt/ActionPrompt.test.story.tsx +86 -3
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +9 -6
- package/src/prompt/InfoPrompt/InfoPrompt.accessibility.docs.mdx +79 -0
- package/src/prompt/InfoPrompt/InfoPrompt.css +3 -3
- package/src/prompt/InfoPrompt/InfoPrompt.less +3 -4
- package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +93 -109
- package/src/prompt/InfoPrompt/InfoPrompt.test.story.tsx +54 -1
- package/src/prompt/InfoPrompt/InfoPrompt.tsx +4 -2
- package/src/prompt/InlinePrompt/InlinePrompt.accessibility.docs.mdx +63 -0
- package/src/prompt/InlinePrompt/InlinePrompt.css +2 -3
- package/src/prompt/InlinePrompt/InlinePrompt.less +2 -2
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +25 -30
- package/src/prompt/InlinePrompt/InlinePrompt.test.story.tsx +21 -0
- package/src/prompt/InlinePrompt/InlinePrompt.test.tsx +3 -10
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +1 -1
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.css +0 -1
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +1 -2
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Meta, Source } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Prompts/InfoPrompt/Accessibility" />
|
|
4
|
+
|
|
5
|
+
# Accessibility
|
|
6
|
+
|
|
7
|
+
Under the hood, `InfoPrompt` is marked as `role="region"` for a section of content that users might want to navigate to directly.
|
|
8
|
+
|
|
9
|
+
By default, it's labelled by the `title` and described by the `description`.
|
|
10
|
+
|
|
11
|
+
## Announcement Behaviour
|
|
12
|
+
|
|
13
|
+
`InfoPrompt` is designed for contextual messages that appear within a screen. Unlike `ActionPrompt`, it can be configured to announce to screen readers using ARIA roles:
|
|
14
|
+
|
|
15
|
+
- **`role="status"`**: Politely announces updates when the screen reader is idle. Use for non-critical success messages or informational updates (e.g., "Your profile has been saved").
|
|
16
|
+
- **`role="alert"`**: Immediately interrupts to announce urgent messages. Use for time-sensitive information that requires immediate attention (e.g., errors, warnings, deadlines).
|
|
17
|
+
|
|
18
|
+
**Default behavior:** Without a role, the prompt won't be announced automatically. Users will encounter it when navigating the page.
|
|
19
|
+
|
|
20
|
+
<Source
|
|
21
|
+
dark
|
|
22
|
+
code={`
|
|
23
|
+
// Polite announcement for non-critical updates
|
|
24
|
+
<InfoPrompt
|
|
25
|
+
sentiment="success"
|
|
26
|
+
description="Your profile has been saved"
|
|
27
|
+
role="status"
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
// Immediate announcement for urgent messages
|
|
31
|
+
|
|
32
|
+
<InfoPrompt
|
|
33
|
+
sentiment="negative"
|
|
34
|
+
title="Session expired"
|
|
35
|
+
description="Your session has expired. Please log in again."
|
|
36
|
+
role="alert"
|
|
37
|
+
/>
|
|
38
|
+
`}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
## Custom Labels
|
|
42
|
+
|
|
43
|
+
If you want to provide a custom label for screen readers, you can use the `aria-label` prop. Make sure to include all necessary information in it, because when provided, the default labelling will be removed.
|
|
44
|
+
|
|
45
|
+
<Source
|
|
46
|
+
dark
|
|
47
|
+
code={`
|
|
48
|
+
<InfoPrompt
|
|
49
|
+
sentiment="negative"
|
|
50
|
+
title="Payment failed"
|
|
51
|
+
description="Unable to process payment."
|
|
52
|
+
aria-label="Critical error: Your payment could not be processed. Please update your payment method and try again within 24 hours."
|
|
53
|
+
/>
|
|
54
|
+
`}
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
## Media
|
|
58
|
+
|
|
59
|
+
Custom media icons should include their own accessibility attributes. Use the `title` prop on icons to provide accessible names for screen readers:
|
|
60
|
+
|
|
61
|
+
<Source
|
|
62
|
+
dark
|
|
63
|
+
code={`
|
|
64
|
+
<InfoPrompt
|
|
65
|
+
sentiment="success"
|
|
66
|
+
description="Your travel account is ready!"
|
|
67
|
+
media={{ asset: <Travel title="Travel feature" /> }}
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
<InfoPrompt
|
|
71
|
+
sentiment="warning"
|
|
72
|
+
title="Business travel"
|
|
73
|
+
description="Book your business trip with Wise."
|
|
74
|
+
media={{ asset: <Briefcase title="Business" /> }}
|
|
75
|
+
/>
|
|
76
|
+
`}
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
**Note:** Unlike `ActionPrompt` (which uses `media['aria-label']`) and `InlinePrompt` (which uses `mediaLabel`), `InfoPrompt` requires you to add accessibility attributes directly to the icon component you pass.
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
.wds-info-prompt {
|
|
2
2
|
--Prompt-gap: var(--size-8);
|
|
3
|
-
--Prompt-padding:
|
|
3
|
+
--Prompt-padding: var(--size-12);
|
|
4
4
|
}
|
|
5
5
|
.wds-info-prompt__content {
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
justify-content: center;
|
|
9
|
-
max-width: calc(48px * 10);
|
|
10
|
-
max-width: calc(var(--size-48) * 10);
|
|
11
9
|
}
|
|
12
10
|
.wds-info-prompt__content:has(.wds-info-prompt__title) {
|
|
13
11
|
justify-content: flex-start;
|
|
@@ -26,7 +24,9 @@
|
|
|
26
24
|
}
|
|
27
25
|
.wds-info-prompt__media svg {
|
|
28
26
|
width: 24px;
|
|
27
|
+
width: var(--size-24);
|
|
29
28
|
height: 24px;
|
|
29
|
+
height: var(--size-24);
|
|
30
30
|
}
|
|
31
31
|
.wds-info-prompt .wds-prompt__media-wrapper {
|
|
32
32
|
padding: 0;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
.wds-info-prompt {
|
|
2
2
|
--Prompt-gap: var(--size-8);
|
|
3
|
-
--Prompt-padding:
|
|
3
|
+
--Prompt-padding: var(--size-12);
|
|
4
4
|
|
|
5
5
|
&__content {
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
justify-content: center;
|
|
9
|
-
max-width: calc(var(--size-48) * 10);
|
|
10
9
|
|
|
11
10
|
&:has(.wds-info-prompt__title) {
|
|
12
11
|
justify-content: flex-start; /* Top align when title exists */
|
|
@@ -27,8 +26,8 @@
|
|
|
27
26
|
display: flex;
|
|
28
27
|
|
|
29
28
|
svg {
|
|
30
|
-
width:
|
|
31
|
-
height:
|
|
29
|
+
width: var(--size-24);
|
|
30
|
+
height: var(--size-24);
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
4
|
import { action } from 'storybook/actions';
|
|
4
|
-
import { Confetti, GiftBox, Star, Travel } from '@transferwise/icons';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { Confetti, GiftBox, Star, Travel, Briefcase, Plane } from '@transferwise/icons';
|
|
6
|
+
import { InfoPrompt, InfoPromptProps, InfoPromptMedia } from './InfoPrompt';
|
|
7
|
+
import Button from '../../button';
|
|
8
|
+
import Title from '../../title';
|
|
7
9
|
|
|
8
10
|
const withComponentGrid =
|
|
9
11
|
({ maxWidth = 'auto', gap = '1rem' } = {}) =>
|
|
@@ -49,6 +51,19 @@ export default {
|
|
|
49
51
|
type: { summary: 'ReactNode' },
|
|
50
52
|
},
|
|
51
53
|
},
|
|
54
|
+
media: {
|
|
55
|
+
table: {
|
|
56
|
+
type: { summary: 'InfoPromptMedia', detail: '{ asset: ReactNode }' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
action: {
|
|
60
|
+
table: {
|
|
61
|
+
type: {
|
|
62
|
+
summary: 'InfoPromptAction',
|
|
63
|
+
detail: '{ label: string; href?: string; target?: string; onClick?: () => void }',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
52
67
|
},
|
|
53
68
|
parameters: {
|
|
54
69
|
docs: {
|
|
@@ -62,7 +77,7 @@ export default {
|
|
|
62
77
|
* not otherwise possible via Storybook
|
|
63
78
|
*/
|
|
64
79
|
type PreviewStoryArgs = InfoPromptProps & {
|
|
65
|
-
previewMedia:
|
|
80
|
+
previewMedia: InfoPromptMedia | undefined;
|
|
66
81
|
previewOnDismiss: boolean;
|
|
67
82
|
previewAction: boolean;
|
|
68
83
|
};
|
|
@@ -74,10 +89,22 @@ const previewArgGroup = {
|
|
|
74
89
|
},
|
|
75
90
|
};
|
|
76
91
|
|
|
92
|
+
const MEDIA_OPTIONS: Record<string, { asset: ReactElement } | undefined> = {
|
|
93
|
+
undefined,
|
|
94
|
+
star: { asset: <Star title="Starred" /> },
|
|
95
|
+
confetti: { asset: <Confetti size={24} title="Celebration" /> },
|
|
96
|
+
giftbox: { asset: <GiftBox title="Gift" /> },
|
|
97
|
+
travel: { asset: <Travel title="Travel" /> },
|
|
98
|
+
briefcase: { asset: <Briefcase title="Business" /> },
|
|
99
|
+
plane: { asset: <Plane title="Travel" /> },
|
|
100
|
+
};
|
|
101
|
+
|
|
77
102
|
const previewArgTypes = {
|
|
78
103
|
previewMedia: {
|
|
79
104
|
name: 'Preview with `media`',
|
|
80
|
-
control: '
|
|
105
|
+
control: 'select',
|
|
106
|
+
options: ['undefined', 'star', 'confetti', 'giftbox', 'travel', 'briefcase', 'plane'],
|
|
107
|
+
mapping: MEDIA_OPTIONS,
|
|
81
108
|
table: previewArgGroup,
|
|
82
109
|
},
|
|
83
110
|
previewOnDismiss: {
|
|
@@ -100,7 +127,7 @@ const getPropsForPreview = (
|
|
|
100
127
|
return [
|
|
101
128
|
props,
|
|
102
129
|
{
|
|
103
|
-
media: previewMedia
|
|
130
|
+
media: previewMedia,
|
|
104
131
|
onDismiss: previewOnDismiss ? action('onDismiss') : undefined,
|
|
105
132
|
action: previewAction
|
|
106
133
|
? { label: 'Learn more', onClick: action('action.onClick') }
|
|
@@ -110,12 +137,19 @@ const getPropsForPreview = (
|
|
|
110
137
|
};
|
|
111
138
|
|
|
112
139
|
export const Playground: StoryObj<PreviewStoryArgs> = {
|
|
113
|
-
|
|
114
|
-
|
|
140
|
+
argTypes: {
|
|
141
|
+
sentiment: {
|
|
142
|
+
control: 'radio',
|
|
143
|
+
options: ['success', 'negative', 'neutral', 'warning', 'proposition'],
|
|
144
|
+
},
|
|
145
|
+
...previewArgTypes,
|
|
146
|
+
},
|
|
115
147
|
args: {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
148
|
+
title: 'Payment successful',
|
|
149
|
+
description: 'Your payment is being processed.',
|
|
150
|
+
previewMedia: { asset: <Star title="Starred" /> },
|
|
151
|
+
previewOnDismiss: true,
|
|
152
|
+
previewAction: true,
|
|
119
153
|
},
|
|
120
154
|
render: (args: PreviewStoryArgs) => {
|
|
121
155
|
const [props, previewProps] = getPropsForPreview(args);
|
|
@@ -141,7 +175,6 @@ export const Sentiments: StoryObj<InfoPromptProps> = {
|
|
|
141
175
|
<InfoPrompt {...args} sentiment="proposition" description="Check out our new features!" />
|
|
142
176
|
</>
|
|
143
177
|
),
|
|
144
|
-
decorators: [withComponentGrid()],
|
|
145
178
|
};
|
|
146
179
|
|
|
147
180
|
/**
|
|
@@ -170,32 +203,6 @@ export const WithTitle: StoryObj<InfoPromptProps> = {
|
|
|
170
203
|
/>
|
|
171
204
|
</>
|
|
172
205
|
),
|
|
173
|
-
decorators: [withComponentGrid()],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* When `onDismiss` is provided, a close button appears allowing users to dismiss the prompt.
|
|
178
|
-
* Note: The component itself is not automatically removed - you must handle state management.
|
|
179
|
-
*/
|
|
180
|
-
export const Dismissible: StoryObj<InfoPromptProps> = {
|
|
181
|
-
render: (args: InfoPromptProps) => (
|
|
182
|
-
<>
|
|
183
|
-
<InfoPrompt
|
|
184
|
-
{...args}
|
|
185
|
-
sentiment="success"
|
|
186
|
-
title="Success"
|
|
187
|
-
description="Your payment was successful."
|
|
188
|
-
onDismiss={action('onDismiss')}
|
|
189
|
-
/>
|
|
190
|
-
<InfoPrompt
|
|
191
|
-
{...args}
|
|
192
|
-
sentiment="neutral"
|
|
193
|
-
description="This message can be dismissed."
|
|
194
|
-
onDismiss={action('onDismiss')}
|
|
195
|
-
/>
|
|
196
|
-
</>
|
|
197
|
-
),
|
|
198
|
-
decorators: [withComponentGrid()],
|
|
199
206
|
};
|
|
200
207
|
|
|
201
208
|
/**
|
|
@@ -227,109 +234,86 @@ export const WithAction: StoryObj<InfoPromptProps> = {
|
|
|
227
234
|
/>
|
|
228
235
|
</>
|
|
229
236
|
),
|
|
230
|
-
decorators: [withComponentGrid()],
|
|
231
237
|
};
|
|
232
238
|
|
|
233
239
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
240
|
+
* When `onDismiss` is provided, a close button appears allowing users to dismiss the prompt.
|
|
241
|
+
* Note: The component itself is not automatically removed - you must handle state management.
|
|
242
|
+
*/
|
|
243
|
+
export const Dismissible: StoryObj<InfoPromptProps> = {
|
|
244
|
+
render: function Render() {
|
|
245
|
+
const [showPrompt, setShowPrompt] = useState(true);
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<>
|
|
249
|
+
{showPrompt ? (
|
|
250
|
+
<InfoPrompt
|
|
251
|
+
sentiment="success"
|
|
252
|
+
title="Payment successful"
|
|
253
|
+
description="Your payment was successful."
|
|
254
|
+
onDismiss={() => setShowPrompt(false)}
|
|
255
|
+
/>
|
|
256
|
+
) : (
|
|
257
|
+
<Button v2 onClick={() => setShowPrompt(true)}>
|
|
258
|
+
Show prompt again
|
|
259
|
+
</Button>
|
|
260
|
+
)}
|
|
261
|
+
</>
|
|
262
|
+
);
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* InfoPrompt supports various media types to enhance visual communication.
|
|
268
|
+
*
|
|
269
|
+
* **Default**: Each sentiment has a default status icon that appears when no media is provided.
|
|
236
270
|
*
|
|
271
|
+
* **Icon Overrides**: Replace default icons with custom icons to match the prompt's visual language to its content.
|
|
237
272
|
* Success and proposition sentiments support both standard checkmark and confetti variations.
|
|
238
273
|
*/
|
|
239
|
-
export const
|
|
240
|
-
render: (args
|
|
274
|
+
export const MediaTypes: StoryObj<InfoPromptProps> = {
|
|
275
|
+
render: (args) => (
|
|
241
276
|
<>
|
|
277
|
+
<Title type="title-body">Default</Title>
|
|
278
|
+
<InfoPrompt
|
|
279
|
+
sentiment="success"
|
|
280
|
+
description="When no media is provided, the sentiment's default status icon is displayed."
|
|
281
|
+
/>
|
|
282
|
+
|
|
283
|
+
<Title type="title-body">Icon Overrides</Title>
|
|
242
284
|
<InfoPrompt
|
|
243
|
-
{...args}
|
|
244
285
|
sentiment="success"
|
|
245
286
|
description="Saved to favorites!"
|
|
246
287
|
media={{ asset: <Star title="Starred" /> }}
|
|
247
288
|
/>
|
|
248
289
|
<InfoPrompt
|
|
249
|
-
{...args}
|
|
250
290
|
sentiment="success"
|
|
251
291
|
title="Congratulations!"
|
|
252
292
|
description="You've completed all the steps."
|
|
253
293
|
media={{ asset: <Confetti size={24} title="Celebration" /> }}
|
|
254
294
|
/>
|
|
255
295
|
<InfoPrompt
|
|
256
|
-
{...args}
|
|
257
296
|
sentiment="proposition"
|
|
258
|
-
title="
|
|
297
|
+
title="Special offer"
|
|
259
298
|
description="New ways to send money with Wise!"
|
|
260
299
|
media={{ asset: <GiftBox title="Gift" /> }}
|
|
261
300
|
/>
|
|
262
301
|
<InfoPrompt
|
|
263
|
-
{...args}
|
|
264
302
|
sentiment="success"
|
|
265
303
|
description="Your travel account is ready!"
|
|
266
304
|
media={{ asset: <Travel title="Travel" /> }}
|
|
267
305
|
/>
|
|
268
|
-
</>
|
|
269
|
-
),
|
|
270
|
-
decorators: [withComponentGrid()],
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* InfoPrompt fully supports accessibility attributes through spread props.
|
|
275
|
-
* Use `role="status"` for non-critical updates or `role="alert"` for important messages.
|
|
276
|
-
*/
|
|
277
|
-
export const Accessibility: StoryObj<InfoPromptProps> = {
|
|
278
|
-
render: (args: InfoPromptProps) => (
|
|
279
|
-
<>
|
|
280
306
|
<InfoPrompt
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
description="
|
|
284
|
-
|
|
307
|
+
sentiment="warning"
|
|
308
|
+
title="Business travel"
|
|
309
|
+
description="Book your business trip with Wise."
|
|
310
|
+
media={{ asset: <Briefcase title="Business" /> }}
|
|
285
311
|
/>
|
|
286
312
|
<InfoPrompt
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
title="
|
|
290
|
-
description="Your session has expired. Please log in again."
|
|
291
|
-
role="alert"
|
|
313
|
+
sentiment="neutral"
|
|
314
|
+
description="Your flight is scheduled."
|
|
315
|
+
media={{ asset: <Plane title="Flight" /> }}
|
|
292
316
|
/>
|
|
293
317
|
</>
|
|
294
318
|
),
|
|
295
|
-
decorators: [withComponentGrid()],
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* While the component itself will stretch to the full available width, the text container will be
|
|
300
|
-
* capped at `480px` to ensure optimal readability.
|
|
301
|
-
*
|
|
302
|
-
* [Visit wise.design](https://wise.design/components/info-prompt#writing-an-info-prompt) for guidance on writing effective prompt messages that are concise and easy to understand.
|
|
303
|
-
*/
|
|
304
|
-
export const ParagraphWidth: StoryObj<PreviewStoryArgs> = {
|
|
305
|
-
parameters: {
|
|
306
|
-
docs: {
|
|
307
|
-
canvas: {
|
|
308
|
-
sourceState: 'hidden',
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
args: {
|
|
313
|
-
title: lorem10,
|
|
314
|
-
description: lorem20,
|
|
315
|
-
sentiment: 'success',
|
|
316
|
-
onDismiss: () => {},
|
|
317
|
-
},
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Complete example showing all features combined:
|
|
322
|
-
* sentiment, title, description, action, onDismiss, and custom media.
|
|
323
|
-
*/
|
|
324
|
-
export const CompleteExample: StoryObj<InfoPromptProps> = {
|
|
325
|
-
render: () => (
|
|
326
|
-
<InfoPrompt
|
|
327
|
-
sentiment="proposition"
|
|
328
|
-
title="Invite Friends & Earn"
|
|
329
|
-
description="Share Wise with friends and get £50 for each friend who makes their first transfer."
|
|
330
|
-
media={{ asset: <GiftBox title="Gift" /> }}
|
|
331
|
-
action={{ label: 'Invite friends', onClick: action('invite') }}
|
|
332
|
-
onDismiss={action('onDismiss')}
|
|
333
|
-
/>
|
|
334
|
-
),
|
|
335
319
|
};
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { useState, MouseEvent } from 'react';
|
|
1
|
+
import { useState, MouseEvent, ReactElement } from 'react';
|
|
2
2
|
import { userEvent, within, expect, waitFor } from 'storybook/test';
|
|
3
3
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
4
|
+
import { action } from 'storybook/actions';
|
|
5
|
+
import { Star } from '@transferwise/icons';
|
|
4
6
|
import { InfoPrompt, type InfoPromptProps } from './InfoPrompt';
|
|
7
|
+
import { allModes } from '../../../.storybook/modes';
|
|
8
|
+
import { withVariantConfig } from '../../../.storybook/helpers';
|
|
9
|
+
|
|
10
|
+
const withComponentGrid =
|
|
11
|
+
({ gap = '1rem' } = {}) =>
|
|
12
|
+
(Story: () => ReactElement) => (
|
|
13
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap }}>
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
5
17
|
|
|
6
18
|
const meta = {
|
|
7
19
|
title: 'Prompts/InfoPrompt/Tests',
|
|
@@ -244,3 +256,44 @@ export const TouchInteraction: Story = {
|
|
|
244
256
|
);
|
|
245
257
|
},
|
|
246
258
|
};
|
|
259
|
+
|
|
260
|
+
export const AllThemesAndSentiments: Story = {
|
|
261
|
+
render: () => (
|
|
262
|
+
<>
|
|
263
|
+
{(['success', 'warning', 'negative', 'neutral', 'proposition'] as const).map((sentiment) => (
|
|
264
|
+
<InfoPrompt
|
|
265
|
+
key={sentiment}
|
|
266
|
+
sentiment={sentiment}
|
|
267
|
+
title={`${sentiment.charAt(0).toUpperCase() + sentiment.slice(1)} prompt`}
|
|
268
|
+
description="This demonstrates the prompt appearance in different themes."
|
|
269
|
+
media={sentiment === 'success' ? { asset: <Star title="Star" /> } : undefined}
|
|
270
|
+
action={{ label: 'Action', onClick: action('action') }}
|
|
271
|
+
onDismiss={action('dismiss')}
|
|
272
|
+
/>
|
|
273
|
+
))}
|
|
274
|
+
</>
|
|
275
|
+
),
|
|
276
|
+
decorators: [withComponentGrid({ gap: '1.5rem' })],
|
|
277
|
+
parameters: {
|
|
278
|
+
padding: '16px',
|
|
279
|
+
variants: ['default', 'dark', 'bright-green', 'forest-green'],
|
|
280
|
+
chromatic: {
|
|
281
|
+
dark: allModes.dark,
|
|
282
|
+
brightGreen: allModes.brightGreen,
|
|
283
|
+
forestGreen: allModes.forestGreen,
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export const TinyScreen: Story = {
|
|
289
|
+
render: () => (
|
|
290
|
+
<InfoPrompt
|
|
291
|
+
sentiment="success"
|
|
292
|
+
title="Payment received"
|
|
293
|
+
description="Your transfer of 500 GBP has been successfully received and is now available in your account."
|
|
294
|
+
action={{ label: 'View details', onClick: action('view-details') }}
|
|
295
|
+
onDismiss={action('dismiss')}
|
|
296
|
+
/>
|
|
297
|
+
),
|
|
298
|
+
...withVariantConfig(['400%']),
|
|
299
|
+
};
|
|
@@ -18,8 +18,7 @@ export type InfoPromptAction = Pick<LinkProps, 'href' | 'target' | 'onClick'> &
|
|
|
18
18
|
export type InfoPromptMedia = {
|
|
19
19
|
/**
|
|
20
20
|
* The icon/image asset to display.
|
|
21
|
-
* The asset should include its own accessibility attributes (e.g. title, aria-label)
|
|
22
|
-
* if it conveys meaning, or aria-hidden="true" if decorative.
|
|
21
|
+
* The asset should include its own accessibility attributes (e.g. title, aria-label) if it conveys meaning.
|
|
23
22
|
*/
|
|
24
23
|
asset: ReactNode;
|
|
25
24
|
};
|
|
@@ -53,6 +52,7 @@ export type InfoPromptProps = Omit<HTMLAttributes<HTMLDivElement>, 'title'> &
|
|
|
53
52
|
* Description text for the prompt (required)
|
|
54
53
|
*/
|
|
55
54
|
description: string;
|
|
55
|
+
className?: string;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -61,6 +61,8 @@ export type InfoPromptProps = Omit<HTMLAttributes<HTMLDivElement>, 'title'> &
|
|
|
61
61
|
* or positive feedback with optional actions and dismissal capabilities.
|
|
62
62
|
*
|
|
63
63
|
* Use this component to replace the deprecated Alert component.
|
|
64
|
+
*
|
|
65
|
+
* Guidance can be found in the [design system](https://wise.design/components/info-prompt).
|
|
64
66
|
*/
|
|
65
67
|
export const InfoPrompt = ({
|
|
66
68
|
sentiment = 'neutral',
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Meta, Source } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Prompts/InlinePrompt/Accessibility" />
|
|
4
|
+
|
|
5
|
+
# Accessibility
|
|
6
|
+
|
|
7
|
+
Under the hood, `InlinePrompt` is marked as `role="region"` for a section of content that users might want to navigate to directly.
|
|
8
|
+
|
|
9
|
+
By default, it's labelled by the `media` icon and the prompt's text content.
|
|
10
|
+
|
|
11
|
+
## Announcement Behaviour
|
|
12
|
+
|
|
13
|
+
`InlinePrompt` appears alongside a specific component on the screen (e.g., input fields, list items). It should not be announced via screen reader—neither assertively (`role="alert"`) nor politely (`role="status"`).
|
|
14
|
+
|
|
15
|
+
**Note:** For immediate user feedback that requires announcement, use [InfoPrompt](?path=/docs/prompts-infoprompt--docs) instead.
|
|
16
|
+
|
|
17
|
+
## Media Label
|
|
18
|
+
|
|
19
|
+
You can use the `mediaLabel` prop to override the icon's accessible name announced by screen readers. This is especially useful for custom icons or when you want to provide more context than the default sentiment label.
|
|
20
|
+
|
|
21
|
+
By default, sentiment icons have these labels:
|
|
22
|
+
|
|
23
|
+
- `positive`: "Success:"
|
|
24
|
+
- `negative`: "Error:"
|
|
25
|
+
- `warning`: "Warning:"
|
|
26
|
+
- `neutral`: "Information:"
|
|
27
|
+
- `proposition`: No label (GiftBox icon is decorative by default)
|
|
28
|
+
|
|
29
|
+
<Source
|
|
30
|
+
dark
|
|
31
|
+
code={`
|
|
32
|
+
<InlinePrompt
|
|
33
|
+
media={<Travel />}
|
|
34
|
+
sentiment="positive"
|
|
35
|
+
mediaLabel="Travel feature enabled: "
|
|
36
|
+
>
|
|
37
|
+
Your travel account is set up and ready to use.
|
|
38
|
+
</InlinePrompt>
|
|
39
|
+
|
|
40
|
+
<InlinePrompt
|
|
41
|
+
media={<Clock />}
|
|
42
|
+
sentiment="warning"
|
|
43
|
+
mediaLabel="Delayed processing: "
|
|
44
|
+
>
|
|
45
|
+
The account verification is taking longer than usual.
|
|
46
|
+
</InlinePrompt>
|
|
47
|
+
`}
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
## Muted State
|
|
51
|
+
|
|
52
|
+
When a prompt is associated with a disabled component, use the `muted` prop to visually indicate the relationship while keeping the prompt accessible and interactive. The prompt remains keyboard accessible and can include interactive elements like links.
|
|
53
|
+
|
|
54
|
+
<Source
|
|
55
|
+
dark
|
|
56
|
+
code={`
|
|
57
|
+
<InlinePrompt muted sentiment="warning" mediaLabel="Feature locked: ">
|
|
58
|
+
Please <Link href="#">confirm your residential address</Link> to activate this feature.
|
|
59
|
+
</InlinePrompt>
|
|
60
|
+
`}
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
The muted state uses a special backslash circle icon to indicate the disabled relationship, but the prompt itself remains fully accessible to screen readers and keyboard users.
|
|
@@ -18,9 +18,8 @@
|
|
|
18
18
|
.wds-inline-prompt:has(button):active {
|
|
19
19
|
background-color: var(--color-sentiment-background-surface-active);
|
|
20
20
|
}
|
|
21
|
-
.wds-inline-prompt--
|
|
22
|
-
width:
|
|
23
|
-
width: initial;
|
|
21
|
+
.wds-inline-prompt--full-width {
|
|
22
|
+
width: 100%;
|
|
24
23
|
}
|
|
25
24
|
.wds-inline-prompt--muted {
|
|
26
25
|
opacity: 0.93;
|