@transferwise/components 0.0.0-experimental-1de8033 → 0.0.0-experimental-2b6c540
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 +3 -1
- package/build/prompt/ActionPrompt/ActionPrompt.js +4 -4
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +4 -4
- 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/styles/main.css +3 -1
- package/build/styles/prompt/InfoPrompt/InfoPrompt.css +3 -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 +3 -1
- package/src/prompt/ActionPrompt/ActionPrompt.accessibility.docs.mdx +1 -17
- package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +271 -107
- package/src/prompt/ActionPrompt/ActionPrompt.test.story.tsx +86 -3
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +11 -4
- package/src/prompt/InfoPrompt/InfoPrompt.accessibility.docs.mdx +79 -0
- package/src/prompt/InfoPrompt/InfoPrompt.css +3 -1
- package/src/prompt/InfoPrompt/InfoPrompt.less +4 -4
- package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +80 -86
- 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.story.tsx +24 -29
- package/src/prompt/InlinePrompt/InlinePrompt.test.story.tsx +21 -0
|
@@ -1,6 +1,6 @@
|
|
|
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;
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
}
|
|
25
25
|
.wds-info-prompt__media svg {
|
|
26
26
|
width: 24px;
|
|
27
|
+
width: var(--size-24);
|
|
27
28
|
height: 24px;
|
|
29
|
+
height: var(--size-24);
|
|
28
30
|
}
|
|
29
31
|
.wds-info-prompt .wds-prompt__media-wrapper {
|
|
30
32
|
padding: 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
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;
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
display: flex;
|
|
27
27
|
|
|
28
28
|
svg {
|
|
29
|
-
width:
|
|
30
|
-
height:
|
|
29
|
+
width: var(--size-24);
|
|
30
|
+
height: var(--size-24);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.wds-prompt__media-wrapper {
|
|
35
35
|
padding: 0;
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|
|
@@ -1,8 +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 { InfoPrompt, InfoPromptProps } from './InfoPrompt';
|
|
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';
|
|
6
9
|
|
|
7
10
|
const withComponentGrid =
|
|
8
11
|
({ maxWidth = 'auto', gap = '1rem' } = {}) =>
|
|
@@ -61,7 +64,7 @@ export default {
|
|
|
61
64
|
* not otherwise possible via Storybook
|
|
62
65
|
*/
|
|
63
66
|
type PreviewStoryArgs = InfoPromptProps & {
|
|
64
|
-
previewMedia:
|
|
67
|
+
previewMedia: InfoPromptMedia | undefined;
|
|
65
68
|
previewOnDismiss: boolean;
|
|
66
69
|
previewAction: boolean;
|
|
67
70
|
};
|
|
@@ -73,10 +76,22 @@ const previewArgGroup = {
|
|
|
73
76
|
},
|
|
74
77
|
};
|
|
75
78
|
|
|
79
|
+
const MEDIA_OPTIONS: Record<string, { asset: ReactElement } | undefined> = {
|
|
80
|
+
undefined,
|
|
81
|
+
star: { asset: <Star title="Starred" /> },
|
|
82
|
+
confetti: { asset: <Confetti size={24} title="Celebration" /> },
|
|
83
|
+
giftbox: { asset: <GiftBox title="Gift" /> },
|
|
84
|
+
travel: { asset: <Travel title="Travel" /> },
|
|
85
|
+
briefcase: { asset: <Briefcase title="Business" /> },
|
|
86
|
+
plane: { asset: <Plane title="Travel" /> },
|
|
87
|
+
};
|
|
88
|
+
|
|
76
89
|
const previewArgTypes = {
|
|
77
90
|
previewMedia: {
|
|
78
91
|
name: 'Preview with `media`',
|
|
79
|
-
control: '
|
|
92
|
+
control: 'select',
|
|
93
|
+
options: ['undefined', 'star', 'confetti', 'giftbox', 'travel', 'briefcase', 'plane'],
|
|
94
|
+
mapping: MEDIA_OPTIONS,
|
|
80
95
|
table: previewArgGroup,
|
|
81
96
|
},
|
|
82
97
|
previewOnDismiss: {
|
|
@@ -99,7 +114,7 @@ const getPropsForPreview = (
|
|
|
99
114
|
return [
|
|
100
115
|
props,
|
|
101
116
|
{
|
|
102
|
-
media: previewMedia
|
|
117
|
+
media: previewMedia,
|
|
103
118
|
onDismiss: previewOnDismiss ? action('onDismiss') : undefined,
|
|
104
119
|
action: previewAction
|
|
105
120
|
? { label: 'Learn more', onClick: action('action.onClick') }
|
|
@@ -109,12 +124,19 @@ const getPropsForPreview = (
|
|
|
109
124
|
};
|
|
110
125
|
|
|
111
126
|
export const Playground: StoryObj<PreviewStoryArgs> = {
|
|
112
|
-
|
|
113
|
-
|
|
127
|
+
argTypes: {
|
|
128
|
+
sentiment: {
|
|
129
|
+
control: 'radio',
|
|
130
|
+
options: ['success', 'negative', 'neutral', 'warning', 'proposition'],
|
|
131
|
+
},
|
|
132
|
+
...previewArgTypes,
|
|
133
|
+
},
|
|
114
134
|
args: {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
135
|
+
title: 'Payment successful',
|
|
136
|
+
description: 'Your payment is being processed.',
|
|
137
|
+
previewMedia: { asset: <Star title="Starred" /> },
|
|
138
|
+
previewOnDismiss: true,
|
|
139
|
+
previewAction: true,
|
|
118
140
|
},
|
|
119
141
|
render: (args: PreviewStoryArgs) => {
|
|
120
142
|
const [props, previewProps] = getPropsForPreview(args);
|
|
@@ -140,7 +162,6 @@ export const Sentiments: StoryObj<InfoPromptProps> = {
|
|
|
140
162
|
<InfoPrompt {...args} sentiment="proposition" description="Check out our new features!" />
|
|
141
163
|
</>
|
|
142
164
|
),
|
|
143
|
-
decorators: [withComponentGrid()],
|
|
144
165
|
};
|
|
145
166
|
|
|
146
167
|
/**
|
|
@@ -169,32 +190,6 @@ export const WithTitle: StoryObj<InfoPromptProps> = {
|
|
|
169
190
|
/>
|
|
170
191
|
</>
|
|
171
192
|
),
|
|
172
|
-
decorators: [withComponentGrid()],
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* When `onDismiss` is provided, a close button appears allowing users to dismiss the prompt.
|
|
177
|
-
* Note: The component itself is not automatically removed - you must handle state management.
|
|
178
|
-
*/
|
|
179
|
-
export const Dismissible: StoryObj<InfoPromptProps> = {
|
|
180
|
-
render: (args: InfoPromptProps) => (
|
|
181
|
-
<>
|
|
182
|
-
<InfoPrompt
|
|
183
|
-
{...args}
|
|
184
|
-
sentiment="success"
|
|
185
|
-
title="Success"
|
|
186
|
-
description="Your payment was successful."
|
|
187
|
-
onDismiss={action('onDismiss')}
|
|
188
|
-
/>
|
|
189
|
-
<InfoPrompt
|
|
190
|
-
{...args}
|
|
191
|
-
sentiment="neutral"
|
|
192
|
-
description="This message can be dismissed."
|
|
193
|
-
onDismiss={action('onDismiss')}
|
|
194
|
-
/>
|
|
195
|
-
</>
|
|
196
|
-
),
|
|
197
|
-
decorators: [withComponentGrid()],
|
|
198
193
|
};
|
|
199
194
|
|
|
200
195
|
/**
|
|
@@ -226,87 +221,86 @@ export const WithAction: StoryObj<InfoPromptProps> = {
|
|
|
226
221
|
/>
|
|
227
222
|
</>
|
|
228
223
|
),
|
|
229
|
-
decorators: [withComponentGrid()],
|
|
230
224
|
};
|
|
231
225
|
|
|
232
226
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
227
|
+
* When `onDismiss` is provided, a close button appears allowing users to dismiss the prompt.
|
|
228
|
+
* Note: The component itself is not automatically removed - you must handle state management.
|
|
229
|
+
*/
|
|
230
|
+
export const Dismissible: StoryObj<InfoPromptProps> = {
|
|
231
|
+
render: function Render() {
|
|
232
|
+
const [showPrompt, setShowPrompt] = useState(true);
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<>
|
|
236
|
+
{showPrompt ? (
|
|
237
|
+
<InfoPrompt
|
|
238
|
+
sentiment="success"
|
|
239
|
+
title="Payment successful"
|
|
240
|
+
description="Your payment was successful."
|
|
241
|
+
onDismiss={() => setShowPrompt(false)}
|
|
242
|
+
/>
|
|
243
|
+
) : (
|
|
244
|
+
<Button v2 onClick={() => setShowPrompt(true)}>
|
|
245
|
+
Show prompt again
|
|
246
|
+
</Button>
|
|
247
|
+
)}
|
|
248
|
+
</>
|
|
249
|
+
);
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* InfoPrompt supports various media types to enhance visual communication.
|
|
235
255
|
*
|
|
256
|
+
* **Default**: Each sentiment has a default status icon that appears when no media is provided.
|
|
257
|
+
*
|
|
258
|
+
* **Icon Overrides**: Replace default icons with custom icons to match the prompt's visual language to its content.
|
|
236
259
|
* Success and proposition sentiments support both standard checkmark and confetti variations.
|
|
237
260
|
*/
|
|
238
|
-
export const
|
|
239
|
-
render: (args
|
|
261
|
+
export const MediaTypes: StoryObj<InfoPromptProps> = {
|
|
262
|
+
render: (args) => (
|
|
240
263
|
<>
|
|
264
|
+
<Title type="title-body">Default</Title>
|
|
265
|
+
<InfoPrompt
|
|
266
|
+
sentiment="success"
|
|
267
|
+
description="When no media is provided, the sentiment's default status icon is displayed."
|
|
268
|
+
/>
|
|
269
|
+
|
|
270
|
+
<Title type="title-body">Icon Overrides</Title>
|
|
241
271
|
<InfoPrompt
|
|
242
|
-
{...args}
|
|
243
272
|
sentiment="success"
|
|
244
273
|
description="Saved to favorites!"
|
|
245
274
|
media={{ asset: <Star title="Starred" /> }}
|
|
246
275
|
/>
|
|
247
276
|
<InfoPrompt
|
|
248
|
-
{...args}
|
|
249
277
|
sentiment="success"
|
|
250
278
|
title="Congratulations!"
|
|
251
279
|
description="You've completed all the steps."
|
|
252
280
|
media={{ asset: <Confetti size={24} title="Celebration" /> }}
|
|
253
281
|
/>
|
|
254
282
|
<InfoPrompt
|
|
255
|
-
{...args}
|
|
256
283
|
sentiment="proposition"
|
|
257
|
-
title="
|
|
284
|
+
title="Special offer"
|
|
258
285
|
description="New ways to send money with Wise!"
|
|
259
286
|
media={{ asset: <GiftBox title="Gift" /> }}
|
|
260
287
|
/>
|
|
261
288
|
<InfoPrompt
|
|
262
|
-
{...args}
|
|
263
289
|
sentiment="success"
|
|
264
290
|
description="Your travel account is ready!"
|
|
265
291
|
media={{ asset: <Travel title="Travel" /> }}
|
|
266
292
|
/>
|
|
267
|
-
</>
|
|
268
|
-
),
|
|
269
|
-
decorators: [withComponentGrid()],
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* InfoPrompt fully supports accessibility attributes through spread props.
|
|
274
|
-
* Use `role="status"` for non-critical updates or `role="alert"` for important messages.
|
|
275
|
-
*/
|
|
276
|
-
export const Accessibility: StoryObj<InfoPromptProps> = {
|
|
277
|
-
render: (args: InfoPromptProps) => (
|
|
278
|
-
<>
|
|
279
293
|
<InfoPrompt
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
description="
|
|
283
|
-
|
|
294
|
+
sentiment="warning"
|
|
295
|
+
title="Business travel"
|
|
296
|
+
description="Book your business trip with Wise."
|
|
297
|
+
media={{ asset: <Briefcase title="Business" /> }}
|
|
284
298
|
/>
|
|
285
299
|
<InfoPrompt
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
title="
|
|
289
|
-
description="Your session has expired. Please log in again."
|
|
290
|
-
role="alert"
|
|
300
|
+
sentiment="neutral"
|
|
301
|
+
description="Your flight is scheduled."
|
|
302
|
+
media={{ asset: <Plane title="Flight" /> }}
|
|
291
303
|
/>
|
|
292
304
|
</>
|
|
293
305
|
),
|
|
294
|
-
decorators: [withComponentGrid()],
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Complete example showing all features combined:
|
|
299
|
-
* sentiment, title, description, action, onDismiss, and custom media.
|
|
300
|
-
*/
|
|
301
|
-
export const CompleteExample: StoryObj<InfoPromptProps> = {
|
|
302
|
-
render: () => (
|
|
303
|
-
<InfoPrompt
|
|
304
|
-
sentiment="proposition"
|
|
305
|
-
title="Invite Friends & Earn"
|
|
306
|
-
description="Share Wise with friends and get £50 for each friend who makes their first transfer."
|
|
307
|
-
media={{ asset: <GiftBox title="Gift" /> }}
|
|
308
|
-
action={{ label: 'Invite friends', onClick: action('invite') }}
|
|
309
|
-
onDismiss={action('onDismiss')}
|
|
310
|
-
/>
|
|
311
|
-
),
|
|
312
306
|
};
|
|
@@ -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.
|
|
@@ -144,7 +144,6 @@ export const Sentiments: StoryObj<PreviewStoryArgs> = {
|
|
|
144
144
|
</>
|
|
145
145
|
);
|
|
146
146
|
},
|
|
147
|
-
decorators: [withComponentGrid()],
|
|
148
147
|
};
|
|
149
148
|
|
|
150
149
|
/**
|
|
@@ -164,6 +163,30 @@ export const Loading: StoryObj<PreviewStoryArgs> = {
|
|
|
164
163
|
},
|
|
165
164
|
};
|
|
166
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Inline prompt is usually associated with a different component, such as `Input` or `ListItem`.
|
|
168
|
+
* When those components are disabled, the prompt is often used to communicate to the user why they
|
|
169
|
+
* cannot interact with them. For that reason, the prompt cannot inherit the usual disabled visual
|
|
170
|
+
* style, and it must retain its interactivity. To bring these 2 components visually closer to each
|
|
171
|
+
* other, `muted` prop introduces slightly reduced opacity and luminosity as well as a special
|
|
172
|
+
* backslash circle icon.
|
|
173
|
+
*/
|
|
174
|
+
export const Muted: StoryObj<PreviewStoryArgs> = {
|
|
175
|
+
argTypes: previewArgTypes,
|
|
176
|
+
args: {
|
|
177
|
+
muted: true,
|
|
178
|
+
previewMedia: false,
|
|
179
|
+
},
|
|
180
|
+
render: (args: PreviewStoryArgs) => {
|
|
181
|
+
const [props, previewProps] = getPropsForPreview(args);
|
|
182
|
+
return (
|
|
183
|
+
<InlinePrompt {...props} {...previewProps}>
|
|
184
|
+
Please <Link href="#">confirm your residential address</Link> to activate this feature.
|
|
185
|
+
</InlinePrompt>
|
|
186
|
+
);
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
|
|
167
190
|
/**
|
|
168
191
|
* `InlinePrompt` can include a single instance of the `Link` component, which can be rendered as
|
|
169
192
|
* either HTML anchor or button. That element will spread across the whole surface of the Prompt
|
|
@@ -194,31 +217,6 @@ export const Interactivity: StoryObj<PreviewStoryArgs> = {
|
|
|
194
217
|
</InlinePrompt>
|
|
195
218
|
</>
|
|
196
219
|
),
|
|
197
|
-
decorators: [withComponentGrid()],
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Inline prompt is usually associated with a different component, such as `Input` or `ListItem`.
|
|
202
|
-
* When those components are disabled, the prompt is often used to communicate to the user why they
|
|
203
|
-
* cannot interact with them. For that reason, the prompt cannot inherit the usual disabled visual
|
|
204
|
-
* style, and it must retain its interactivity. To bring these 2 components visually closer to each
|
|
205
|
-
* other, `muted` prop introduces slightly reduced opacity and luminosity as well as a special
|
|
206
|
-
* backslash circle icon.
|
|
207
|
-
*/
|
|
208
|
-
export const Muted: StoryObj<PreviewStoryArgs> = {
|
|
209
|
-
argTypes: previewArgTypes,
|
|
210
|
-
args: {
|
|
211
|
-
muted: true,
|
|
212
|
-
previewMedia: false,
|
|
213
|
-
},
|
|
214
|
-
render: (args: PreviewStoryArgs) => {
|
|
215
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
216
|
-
return (
|
|
217
|
-
<InlinePrompt {...props} {...previewProps}>
|
|
218
|
-
Please <Link href="#">confirm your residential address</Link> to activate this feature.
|
|
219
|
-
</InlinePrompt>
|
|
220
|
-
);
|
|
221
|
-
},
|
|
222
220
|
};
|
|
223
221
|
|
|
224
222
|
/**
|
|
@@ -250,7 +248,6 @@ export const IconOverrides: StoryObj<PreviewStoryArgs> = {
|
|
|
250
248
|
</>
|
|
251
249
|
);
|
|
252
250
|
},
|
|
253
|
-
decorators: [withComponentGrid()],
|
|
254
251
|
};
|
|
255
252
|
|
|
256
253
|
/**
|
|
@@ -281,7 +278,6 @@ export const SizingStrategies: StoryObj<PreviewStoryArgs> = {
|
|
|
281
278
|
</>
|
|
282
279
|
);
|
|
283
280
|
},
|
|
284
|
-
decorators: [withComponentGrid()],
|
|
285
281
|
};
|
|
286
282
|
|
|
287
283
|
/**
|
|
@@ -309,5 +305,4 @@ export const SentimentAwareness: StoryObj<PreviewStoryArgs> = {
|
|
|
309
305
|
</>
|
|
310
306
|
);
|
|
311
307
|
},
|
|
312
|
-
decorators: [withComponentGrid()],
|
|
313
308
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { Travel } from '@transferwise/icons';
|
|
3
|
+
import { InlinePrompt } from './InlinePrompt';
|
|
4
|
+
import { withVariantConfig } from '../../../.storybook/helpers';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Prompts/InlinePrompt/Tests',
|
|
8
|
+
component: InlinePrompt,
|
|
9
|
+
tags: ['!autodocs'],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof InlinePrompt>;
|
|
13
|
+
|
|
14
|
+
export const TinyScreen: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<InlinePrompt sentiment="positive" media={<Travel />}>
|
|
17
|
+
Your travel money account is now active and ready to use for international transactions.
|
|
18
|
+
</InlinePrompt>
|
|
19
|
+
),
|
|
20
|
+
...withVariantConfig(['400%']),
|
|
21
|
+
};
|