@transferwise/components 0.0.0-experimental-70cb6d1 → 0.0.0-experimental-8bfed24
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/field/Field.js +5 -4
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +5 -4
- package/build/field/Field.mjs.map +1 -1
- package/build/i18n/en.json +2 -0
- package/build/i18n/en.json.js +2 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +2 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +5 -4
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +5 -4
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/main.css +107 -51
- package/build/moneyInput/MoneyInput.js +12 -28
- package/build/moneyInput/MoneyInput.js.map +1 -1
- package/build/moneyInput/MoneyInput.mjs +14 -30
- package/build/moneyInput/MoneyInput.mjs.map +1 -1
- package/build/moneyInput/currencyFormatting.js +2 -8
- package/build/moneyInput/currencyFormatting.js.map +1 -1
- package/build/moneyInput/currencyFormatting.mjs +4 -5
- package/build/moneyInput/currencyFormatting.mjs.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.js +8 -40
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +8 -40
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/CriticalBanner/CriticalBanner.js +145 -0
- package/build/prompt/CriticalBanner/CriticalBanner.js.map +1 -0
- package/build/prompt/CriticalBanner/CriticalBanner.mjs +143 -0
- package/build/prompt/CriticalBanner/CriticalBanner.mjs.map +1 -0
- package/build/prompt/CriticalBanner/helpers.js +29 -0
- package/build/prompt/CriticalBanner/helpers.js.map +1 -0
- package/build/prompt/CriticalBanner/helpers.mjs +26 -0
- package/build/prompt/CriticalBanner/helpers.mjs.map +1 -0
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js +2 -0
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs +2 -0
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
- package/build/prompt/common/Expander/Expander.js +47 -0
- package/build/prompt/common/Expander/Expander.js.map +1 -0
- package/build/prompt/common/Expander/Expander.messages.js +17 -0
- package/build/prompt/common/Expander/Expander.messages.js.map +1 -0
- package/build/prompt/common/Expander/Expander.messages.mjs +13 -0
- package/build/prompt/common/Expander/Expander.messages.mjs.map +1 -0
- package/build/prompt/common/Expander/Expander.mjs +44 -0
- package/build/prompt/common/Expander/Expander.mjs.map +1 -0
- package/build/prompt/helpers/promptMedia.js +52 -0
- package/build/prompt/helpers/promptMedia.js.map +1 -0
- package/build/prompt/helpers/promptMedia.mjs +50 -0
- package/build/prompt/helpers/promptMedia.mjs.map +1 -0
- package/build/styles/css/neptune.css +22 -22
- package/build/styles/less/neptune-tokens.less +4 -4
- package/build/styles/main.css +107 -51
- package/build/styles/prompt/CriticalBanner/CriticalBanner.css +39 -0
- package/build/styles/prompt/common/Expander/Expander.css +8 -0
- package/build/styles/props/neptune-tokens.css +2 -2
- package/build/styles/styles/less/neptune.css +22 -22
- package/build/typeahead/Typeahead.js +5 -4
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +5 -4
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts +0 -6
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/moneyInput/currencyFormatting.d.ts +3 -4
- package/build/types/moneyInput/currencyFormatting.d.ts.map +1 -1
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +2 -11
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
- package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts +40 -0
- package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts.map +1 -0
- package/build/types/prompt/CriticalBanner/helpers.d.ts +18 -0
- package/build/types/prompt/CriticalBanner/helpers.d.ts.map +1 -0
- package/build/types/prompt/CriticalBanner/index.d.ts +3 -0
- package/build/types/prompt/CriticalBanner/index.d.ts.map +1 -0
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts +8 -3
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
- package/build/types/prompt/common/Expander/Expander.d.ts +20 -0
- package/build/types/prompt/common/Expander/Expander.d.ts.map +1 -0
- package/build/types/prompt/common/Expander/Expander.messages.d.ts +14 -0
- package/build/types/prompt/common/Expander/Expander.messages.d.ts.map +1 -0
- package/build/types/prompt/helpers/promptMedia.d.ts +22 -0
- package/build/types/prompt/helpers/promptMedia.d.ts.map +1 -0
- package/build/types/prompt/index.d.ts +2 -0
- package/build/types/prompt/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +4 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/i18n/en.json +2 -0
- package/src/index.ts +2 -2
- package/src/main.css +107 -51
- package/src/main.less +3 -1
- package/src/moneyInput/MoneyInput.story.tsx +1 -10
- package/src/moneyInput/MoneyInput.test.story.tsx +1 -141
- package/src/moneyInput/MoneyInput.test.tsx +0 -45
- package/src/moneyInput/MoneyInput.tsx +3 -27
- package/src/moneyInput/currencyFormatting.ts +5 -11
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +9 -62
- package/src/prompt/CriticalBanner/CriticalBanner.accessibility.docs.mdx +131 -0
- package/src/prompt/CriticalBanner/CriticalBanner.css +39 -0
- package/src/prompt/CriticalBanner/CriticalBanner.less +45 -0
- package/src/prompt/CriticalBanner/CriticalBanner.story.tsx +645 -0
- package/src/prompt/CriticalBanner/CriticalBanner.test.story.tsx +304 -0
- package/src/prompt/CriticalBanner/CriticalBanner.tsx +185 -0
- package/src/prompt/CriticalBanner/helpers.ts +39 -0
- package/src/prompt/CriticalBanner/index.ts +2 -0
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +9 -2
- package/src/prompt/common/Expander/Expander.css +8 -0
- package/src/prompt/common/Expander/Expander.less +9 -0
- package/src/prompt/common/Expander/Expander.messages.ts +14 -0
- package/src/prompt/common/Expander/Expander.test.tsx +167 -0
- package/src/prompt/common/Expander/Expander.tsx +83 -0
- package/src/prompt/helpers/promptMedia.tsx +79 -0
- package/src/prompt/index.ts +4 -0
- package/src/sentimentSurface/SentimentSurface.story.tsx +43 -17
- package/src/styles/less/neptune.css +22 -22
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import Title from '../title';
|
|
25
25
|
|
|
26
26
|
import messages from './MoneyInput.messages';
|
|
27
|
-
import { formatAmount,
|
|
27
|
+
import { formatAmount, parseAmount } from './currencyFormatting';
|
|
28
28
|
import withId from '../withId';
|
|
29
29
|
|
|
30
30
|
export interface CurrencyOptionItem {
|
|
@@ -48,34 +48,24 @@ const formatAmountIfSet = ({
|
|
|
48
48
|
amount,
|
|
49
49
|
currency,
|
|
50
50
|
locale,
|
|
51
|
-
decimals,
|
|
52
51
|
}: {
|
|
53
52
|
amount: number | null | undefined;
|
|
54
53
|
currency: string;
|
|
55
54
|
locale: string;
|
|
56
|
-
decimals?: number;
|
|
57
55
|
}) => {
|
|
58
|
-
|
|
59
|
-
return '';
|
|
60
|
-
}
|
|
61
|
-
if (decimals != null && getCurrencyDecimals(currency) !== 0) {
|
|
62
|
-
return formatNumber(amount, locale, decimals);
|
|
63
|
-
}
|
|
64
|
-
return formatAmount(amount, currency, locale);
|
|
56
|
+
return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';
|
|
65
57
|
};
|
|
66
58
|
|
|
67
59
|
const parseNumber = ({
|
|
68
60
|
amount,
|
|
69
61
|
currency,
|
|
70
62
|
locale,
|
|
71
|
-
decimals,
|
|
72
63
|
}: {
|
|
73
64
|
amount: string;
|
|
74
65
|
currency: string;
|
|
75
66
|
locale: string;
|
|
76
|
-
decimals?: number;
|
|
77
67
|
}) => {
|
|
78
|
-
return parseAmount(amount, currency, locale
|
|
68
|
+
return parseAmount(amount, currency, locale);
|
|
79
69
|
};
|
|
80
70
|
|
|
81
71
|
const allowedInputKeys = new Set([
|
|
@@ -112,12 +102,6 @@ export interface MoneyInputProps extends WrappedComponentProps {
|
|
|
112
102
|
onCustomAction?: () => void;
|
|
113
103
|
classNames?: Record<string, string>;
|
|
114
104
|
selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;
|
|
115
|
-
/**
|
|
116
|
-
* Specify the number of decimal places to format the amount. When not specified, the number of
|
|
117
|
-
* decimals is determined by the selected currency (e.g. 2 for EUR, 0 for JPY, 3 for BHD).
|
|
118
|
-
* This override is ignored for zero-decimal currencies (e.g. JPY, KRW, HUF), which always use 0.
|
|
119
|
-
*/
|
|
120
|
-
decimals?: number;
|
|
121
105
|
}
|
|
122
106
|
|
|
123
107
|
export type MoneyInputPropsWithInputAttributes = MoneyInputProps &
|
|
@@ -149,7 +133,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
149
133
|
amount: props.amount,
|
|
150
134
|
currency: props.selectedCurrency.currency,
|
|
151
135
|
locale: props.intl.locale,
|
|
152
|
-
decimals: props.decimals,
|
|
153
136
|
}),
|
|
154
137
|
locale: props.intl.locale,
|
|
155
138
|
};
|
|
@@ -164,7 +147,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
164
147
|
amount: nextProps.amount,
|
|
165
148
|
currency: nextProps.selectedCurrency.currency,
|
|
166
149
|
locale: nextProps.intl.locale,
|
|
167
|
-
decimals: nextProps.decimals,
|
|
168
150
|
}),
|
|
169
151
|
});
|
|
170
152
|
}
|
|
@@ -192,7 +174,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
192
174
|
amount: paste,
|
|
193
175
|
currency: this.props.selectedCurrency.currency,
|
|
194
176
|
locale,
|
|
195
|
-
decimals: this.props.decimals,
|
|
196
177
|
});
|
|
197
178
|
|
|
198
179
|
if (isNumberOrNull(parsed)) {
|
|
@@ -201,7 +182,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
201
182
|
amount: parsed,
|
|
202
183
|
currency: this.props.selectedCurrency.currency,
|
|
203
184
|
locale,
|
|
204
|
-
decimals: this.props.decimals,
|
|
205
185
|
}),
|
|
206
186
|
});
|
|
207
187
|
this.props.onAmountChange?.(parsed);
|
|
@@ -221,7 +201,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
221
201
|
amount: value,
|
|
222
202
|
currency: this.props.selectedCurrency.currency,
|
|
223
203
|
locale: this.state.locale,
|
|
224
|
-
decimals: this.props.decimals,
|
|
225
204
|
});
|
|
226
205
|
if (isNumberOrNull(parsed)) {
|
|
227
206
|
this.props.onAmountChange?.(parsed);
|
|
@@ -269,7 +248,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
269
248
|
amount: previousState.formattedAmount,
|
|
270
249
|
currency: this.props.selectedCurrency.currency,
|
|
271
250
|
locale: previousState.locale,
|
|
272
|
-
decimals: this.props.decimals,
|
|
273
251
|
});
|
|
274
252
|
if (!isNumberOrNull(parsed)) {
|
|
275
253
|
return {
|
|
@@ -281,7 +259,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
281
259
|
amount: parsed,
|
|
282
260
|
currency: this.props.selectedCurrency.currency,
|
|
283
261
|
locale: previousState.locale,
|
|
284
|
-
decimals: this.props.decimals,
|
|
285
262
|
}),
|
|
286
263
|
};
|
|
287
264
|
});
|
|
@@ -363,7 +340,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
363
340
|
amount: this.props.placeholder,
|
|
364
341
|
currency: this.props.selectedCurrency.currency,
|
|
365
342
|
locale: this.state.locale,
|
|
366
|
-
decimals: this.props.decimals,
|
|
367
343
|
})}
|
|
368
344
|
autoComplete="off"
|
|
369
345
|
aria-describedby={selectedCurrencyElementId}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { formatAmount
|
|
1
|
+
import { formatAmount } from '@transferwise/formatting';
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_LOCALE } from '../common/locale';
|
|
4
4
|
|
|
5
|
-
export { formatAmount
|
|
5
|
+
export { formatAmount };
|
|
6
6
|
|
|
7
7
|
// TODO: do not duplicate this between formatting and components
|
|
8
8
|
const currencyDecimals: Record<string, number> = {
|
|
@@ -52,7 +52,7 @@ function getValidLocale(locale: string) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
function getCurrencyDecimals(currency: string) {
|
|
56
56
|
const upperCaseCurrency = currency.toUpperCase();
|
|
57
57
|
return currencyDecimals[upperCaseCurrency] ?? DEFAULT_CURRENCY_DECIMALS;
|
|
58
58
|
}
|
|
@@ -61,16 +61,10 @@ function getDecimalSeparator(locale: string) {
|
|
|
61
61
|
return isNumberLocaleSupported() ? (1.1).toLocaleString(locale)[1] : '.';
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function parseAmount(
|
|
65
|
-
number: string,
|
|
66
|
-
currency: string,
|
|
67
|
-
locale = DEFAULT_LOCALE,
|
|
68
|
-
decimals?: number,
|
|
69
|
-
) {
|
|
64
|
+
export function parseAmount(number: string, currency: string, locale = DEFAULT_LOCALE) {
|
|
70
65
|
const validLocale = getValidLocale(locale);
|
|
71
66
|
|
|
72
|
-
const
|
|
73
|
-
const precision = currencyDefault === 0 ? 0 : (decimals ?? currencyDefault);
|
|
67
|
+
const precision = getCurrencyDecimals(currency);
|
|
74
68
|
const groupSeparator = isNumberLocaleSupported() ? (10000).toLocaleString(validLocale)[2] : ',';
|
|
75
69
|
const decimalSeparator = getDecimalSeparator(validLocale);
|
|
76
70
|
const numberWithStandardDecimalSeparator = (number || '')
|
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
import { AriaAttributes, ReactNode, useId } from 'react';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
|
|
4
|
-
import StatusIcon from '../../statusIcon';
|
|
5
4
|
import Body from '../../body';
|
|
6
5
|
import Button from '../../button';
|
|
7
6
|
import { Breakpoint, Typography } from '../../common';
|
|
8
|
-
import AvatarView, { AvatarViewProps } from '../../avatarView';
|
|
9
|
-
import Image from '../../image';
|
|
10
7
|
import { ButtonProps } from '../../button/Button.types';
|
|
11
8
|
import { PrimitivePrompt, PrimitivePromptProps } from '../PrimitivePrompt';
|
|
12
|
-
import { BadgeAssetsProps } from '../../badge';
|
|
13
|
-
import { GiftBox } from '@transferwise/icons';
|
|
14
9
|
import { useScreenSize } from '../../common/hooks/useScreenSize';
|
|
10
|
+
import { renderPromptMedia, PromptMedia } from '../helpers/promptMedia';
|
|
15
11
|
|
|
16
12
|
export type ActionPromptProps = {
|
|
17
13
|
title: ReactNode;
|
|
18
14
|
description?: ReactNode;
|
|
19
15
|
/** @default {} */
|
|
20
|
-
media?:
|
|
21
|
-
imgSrc?: string;
|
|
22
|
-
avatar?: Pick<AvatarViewProps, 'imgSrc' | 'profileName' | 'profileType'> & {
|
|
23
|
-
asset?: AvatarViewProps['children'];
|
|
24
|
-
badge?: Pick<BadgeAssetsProps, 'flagCode'>;
|
|
25
|
-
};
|
|
26
|
-
'aria-label'?: string;
|
|
27
|
-
'aria-hidden'?: boolean;
|
|
28
|
-
};
|
|
16
|
+
media?: PromptMedia;
|
|
29
17
|
action: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {
|
|
30
18
|
label: ButtonProps['children'];
|
|
31
19
|
};
|
|
@@ -74,54 +62,13 @@ export const ActionPrompt = ({
|
|
|
74
62
|
.filter(Boolean)
|
|
75
63
|
.join(' ');
|
|
76
64
|
|
|
77
|
-
const renderMedia = () =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
alt={media['aria-label'] ?? ''}
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
if (media?.avatar) {
|
|
89
|
-
const badge = media.avatar.badge
|
|
90
|
-
? media.avatar.badge
|
|
91
|
-
: sentiment === 'proposition'
|
|
92
|
-
? {}
|
|
93
|
-
: { status: sentiment };
|
|
94
|
-
return (
|
|
95
|
-
<AvatarView
|
|
96
|
-
{...media.avatar}
|
|
97
|
-
badge={badge}
|
|
98
|
-
aria-label={media['aria-label']}
|
|
99
|
-
aria-hidden={media['aria-hidden']}
|
|
100
|
-
id={mediaId}
|
|
101
|
-
size={48}
|
|
102
|
-
>
|
|
103
|
-
{media.avatar.asset}
|
|
104
|
-
</AvatarView>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
return sentiment === 'proposition' ? (
|
|
108
|
-
<AvatarView
|
|
109
|
-
id={mediaId}
|
|
110
|
-
size={48}
|
|
111
|
-
aria-label={media['aria-label']}
|
|
112
|
-
aria-hidden={media['aria-hidden']}
|
|
113
|
-
>
|
|
114
|
-
<GiftBox />
|
|
115
|
-
</AvatarView>
|
|
116
|
-
) : (
|
|
117
|
-
<StatusIcon
|
|
118
|
-
id={mediaId}
|
|
119
|
-
size={48}
|
|
120
|
-
sentiment={sentiment}
|
|
121
|
-
iconLabel={media['aria-hidden'] ? null : media['aria-label']}
|
|
122
|
-
/>
|
|
123
|
-
);
|
|
124
|
-
};
|
|
65
|
+
const renderMedia = () =>
|
|
66
|
+
renderPromptMedia({
|
|
67
|
+
media,
|
|
68
|
+
sentiment,
|
|
69
|
+
mediaId,
|
|
70
|
+
imgClassName: 'wds-action-prompt--media-image',
|
|
71
|
+
});
|
|
125
72
|
|
|
126
73
|
return (
|
|
127
74
|
<PrimitivePrompt
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Meta, Source, Canvas } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as CriticalBannerStories from './CriticalBanner.story';
|
|
3
|
+
|
|
4
|
+
<Meta title="Prompts/CriticalBanner/Accessibility" tags={['new']} />
|
|
5
|
+
|
|
6
|
+
# Accessibility
|
|
7
|
+
|
|
8
|
+
Under the hood, `CriticalBanner` is marked as `role="region"` for a section of content that users might want to navigate to directly.
|
|
9
|
+
|
|
10
|
+
By default, it's labelled by the `title` and described by the `description`.
|
|
11
|
+
|
|
12
|
+
## Announcement Behavior
|
|
13
|
+
|
|
14
|
+
`CriticalBanner` is designed for critical messages that require immediate attention. It always uses **`aria-live="assertive"`** to immediately interrupt and announce changes to screen readers.
|
|
15
|
+
|
|
16
|
+
Unlike `InfoPrompt` which offers configurable politeness levels, `CriticalBanner` is always assertive because it communicates critical, time-sensitive information that users must be aware of immediately.
|
|
17
|
+
|
|
18
|
+
### What Gets Announced
|
|
19
|
+
|
|
20
|
+
The component intelligently announces only **visible content**, respecting the collapsed/expanded state:
|
|
21
|
+
|
|
22
|
+
- **Collapsed with title**: Announces title only (description is hidden)
|
|
23
|
+
- **Collapsed without title**: Announces description only (visible up to 2 lines)
|
|
24
|
+
- **Expanded**: Announces title, description, and action button labels (all visible)
|
|
25
|
+
|
|
26
|
+
<Source
|
|
27
|
+
dark
|
|
28
|
+
code={`
|
|
29
|
+
// Collapsed with title - announces: "Your account requires verification"
|
|
30
|
+
<CriticalBanner
|
|
31
|
+
title="Your account requires verification"
|
|
32
|
+
description="Please verify your identity to continue"
|
|
33
|
+
action={{ label: "Verify now", onClick: handleVerify }}
|
|
34
|
+
expanded={false}
|
|
35
|
+
onToggle={handleToggle}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
// Expanded - announces: "Your account requires verification | Please verify your identity to continue | Verify now | Learn more"
|
|
39
|
+
|
|
40
|
+
<CriticalBanner
|
|
41
|
+
title="Your account requires verification"
|
|
42
|
+
description="Please verify your identity to continue"
|
|
43
|
+
action={{ label: 'Verify now', onClick: handleVerify }}
|
|
44
|
+
actionSecondary={{ label: 'Learn more', onClick: handleLearnMore }}
|
|
45
|
+
expanded={true}
|
|
46
|
+
onToggle={handleToggle}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
// Collapsed without title - announces: "Your verification is pending..."
|
|
50
|
+
|
|
51
|
+
<CriticalBanner
|
|
52
|
+
description="Your verification is pending. We'll notify you once complete."
|
|
53
|
+
expanded={false}
|
|
54
|
+
onToggle={handleToggle}
|
|
55
|
+
/>
|
|
56
|
+
`}
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
### When Announcements Trigger
|
|
60
|
+
|
|
61
|
+
Screen readers announce the banner content whenever:
|
|
62
|
+
|
|
63
|
+
- The banner first appears in the DOM
|
|
64
|
+
- The user toggles between collapsed and expanded states
|
|
65
|
+
- The content (title, description, or action labels) changes
|
|
66
|
+
|
|
67
|
+
## Custom Labels
|
|
68
|
+
|
|
69
|
+
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.
|
|
70
|
+
|
|
71
|
+
<Source
|
|
72
|
+
dark
|
|
73
|
+
code={`
|
|
74
|
+
<CriticalBanner
|
|
75
|
+
title="Account suspended"
|
|
76
|
+
description="Unusual activity detected"
|
|
77
|
+
action={{ label: "Verify identity", onClick: handleVerify }}
|
|
78
|
+
aria-label="Critical: Your account has been suspended due to unusual activity. Please verify your identity immediately to restore access."
|
|
79
|
+
expanded={false}
|
|
80
|
+
onToggle={handleToggle}
|
|
81
|
+
/>
|
|
82
|
+
`}
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
## Media
|
|
86
|
+
|
|
87
|
+
Custom media icons should include their own accessibility attributes. Use the `title` prop on icons to provide accessible names for screen readers:
|
|
88
|
+
|
|
89
|
+
<Source
|
|
90
|
+
dark
|
|
91
|
+
code={`
|
|
92
|
+
import { Bank, AlertCircle } from '@transferwise/icons';
|
|
93
|
+
|
|
94
|
+
<CriticalBanner
|
|
95
|
+
title="Bank connection required"
|
|
96
|
+
description="Connect your bank account to continue"
|
|
97
|
+
media={{ avatar: { asset: <Bank title="Bank account" /> } }}
|
|
98
|
+
action={{ label: 'Connect now', onClick: handleConnect }}
|
|
99
|
+
expanded={false}
|
|
100
|
+
onToggle={handleToggle}
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<CriticalBanner
|
|
104
|
+
title="Verification required"
|
|
105
|
+
description="We need to verify your identity"
|
|
106
|
+
media={{ avatar: { asset: <AlertCircle title="Alert" /> } }}
|
|
107
|
+
action={{ label: "Start verification", onClick: handleVerify }}
|
|
108
|
+
expanded={false}
|
|
109
|
+
onToggle={handleToggle}
|
|
110
|
+
/>
|
|
111
|
+
`}
|
|
112
|
+
/>
|
|
113
|
+
|
|
114
|
+
Alternatively, you can use `media['aria-label']` to provide a label for custom images:
|
|
115
|
+
|
|
116
|
+
<Source
|
|
117
|
+
dark
|
|
118
|
+
code={`
|
|
119
|
+
<CriticalBanner
|
|
120
|
+
title="Card blocked"
|
|
121
|
+
description="Your card has been blocked for security reasons"
|
|
122
|
+
media={{
|
|
123
|
+
imgSrc: '/wise-card.svg',
|
|
124
|
+
'aria-label': 'Wise debit card'
|
|
125
|
+
}}
|
|
126
|
+
action={{ label: "Unblock card", onClick: handleUnblock }}
|
|
127
|
+
expanded={false}
|
|
128
|
+
onToggle={handleToggle}
|
|
129
|
+
/>
|
|
130
|
+
`}
|
|
131
|
+
/>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.wds-critical-banner {
|
|
2
|
+
--Prompt-padding: var(--size-16);
|
|
3
|
+
--Prompt-actions-gap: var(--size-8);
|
|
4
|
+
--Prompt-gap: var(--size-10) var(--size-16);
|
|
5
|
+
--Prompt-border-radius: 0;
|
|
6
|
+
}
|
|
7
|
+
.wds-critical-banner--media-image {
|
|
8
|
+
width: 48px;
|
|
9
|
+
width: var(--size-48);
|
|
10
|
+
height: 48px;
|
|
11
|
+
height: var(--size-48);
|
|
12
|
+
-o-object-fit: contain;
|
|
13
|
+
object-fit: contain;
|
|
14
|
+
}
|
|
15
|
+
@media (max-width: 767px) {
|
|
16
|
+
.wds-critical-banner--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
|
|
17
|
+
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
18
|
+
min-width: -moz-fit-content;
|
|
19
|
+
min-width: fit-content;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
.wds-critical-banner__description--collapsed {
|
|
23
|
+
display: -webkit-box;
|
|
24
|
+
-webkit-line-clamp: 2;
|
|
25
|
+
-webkit-box-orient: vertical;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
}
|
|
28
|
+
.wds-critical-banner .wds-prompt__content-wrapper {
|
|
29
|
+
grid-template-columns: auto 1fr auto;
|
|
30
|
+
align-items: flex-start;
|
|
31
|
+
}
|
|
32
|
+
.wds-critical-banner__text-wrapper {
|
|
33
|
+
min-width: 0;
|
|
34
|
+
}
|
|
35
|
+
@media (max-width: 767px) {
|
|
36
|
+
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
37
|
+
grid-column: span 3;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.wds-critical-banner {
|
|
2
|
+
--Prompt-padding: var(--size-16);
|
|
3
|
+
--Prompt-actions-gap: var(--size-8);
|
|
4
|
+
--Prompt-gap: var(--size-10) var(--size-16);
|
|
5
|
+
--Prompt-border-radius: 0;
|
|
6
|
+
|
|
7
|
+
&--media-image {
|
|
8
|
+
width: var(--size-48);
|
|
9
|
+
height: var(--size-48);
|
|
10
|
+
object-fit: contain;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&--with-two-actions {
|
|
14
|
+
@media (--screen-sm-max) {
|
|
15
|
+
.wds-prompt__actions-wrapper {
|
|
16
|
+
.wds-Button {
|
|
17
|
+
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
18
|
+
min-width: fit-content;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&__description--collapsed {
|
|
25
|
+
display: -webkit-box;
|
|
26
|
+
-webkit-line-clamp: 2;
|
|
27
|
+
-webkit-box-orient: vertical;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.wds-prompt__content-wrapper {
|
|
32
|
+
grid-template-columns: auto 1fr auto;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__text-wrapper {
|
|
37
|
+
min-width: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.wds-prompt__actions-wrapper {
|
|
41
|
+
@media (--screen-sm-max) {
|
|
42
|
+
grid-column: span 3;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|