@transferwise/components 46.146.0 → 46.148.0

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.
Files changed (109) hide show
  1. package/build/main.css +66 -0
  2. package/build/nudge/Nudge.js.map +1 -1
  3. package/build/nudge/Nudge.mjs.map +1 -1
  4. package/build/prompt/CriticalBanner/CriticalBanner.js +78 -68
  5. package/build/prompt/CriticalBanner/CriticalBanner.js.map +1 -1
  6. package/build/prompt/CriticalBanner/CriticalBanner.mjs +79 -69
  7. package/build/prompt/CriticalBanner/CriticalBanner.mjs.map +1 -1
  8. package/build/styles/main.css +66 -0
  9. package/build/styles/nudge/Nudge.css +11 -0
  10. package/build/styles/prompt/CriticalBanner/CriticalBanner.css +48 -0
  11. package/build/types/nudge/Nudge.d.ts +1 -1
  12. package/build/types/nudge/Nudge.d.ts.map +1 -1
  13. package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts.map +1 -1
  14. package/package.json +23 -19
  15. package/src/accordion/Accordion.story.tsx +25 -0
  16. package/src/avatarLayout/AvatarLayout.story.tsx +10 -0
  17. package/src/avatarView/AvatarView.story.tsx +8 -0
  18. package/src/body/Body.story.tsx +12 -0
  19. package/src/button/_stories/Button.story.tsx +7 -1
  20. package/src/calendar/Calendar.story.tsx +19 -7
  21. package/src/carousel/Carousel.story.tsx +35 -0
  22. package/src/checkbox/Checkbox.story.tsx +20 -0
  23. package/src/checkboxButton/CheckboxButton.story.tsx +16 -0
  24. package/src/chevron/Chevron.story.tsx +6 -0
  25. package/src/chips/Chips.story.tsx +23 -0
  26. package/src/circularButton/CircularButton.story.tsx +13 -0
  27. package/src/common/baseCard/BaseCard.story.tsx +12 -0
  28. package/src/common/bottomSheet/BottomSheet.story.tsx +21 -0
  29. package/src/common/circle/Circle.story.tsx +11 -0
  30. package/src/container/Container.story.tsx +12 -0
  31. package/src/dateInput/DateInput.story.tsx +20 -0
  32. package/src/dateLookup/DateLookup.story.tsx +23 -0
  33. package/src/decision/Decision.story.tsx +36 -0
  34. package/src/definitionList/DefinitionList.story.tsx +16 -0
  35. package/src/dimmer/Dimmer.story.tsx +24 -0
  36. package/src/display/Display.story.tsx +11 -0
  37. package/src/divider/Divider.story.tsx +6 -0
  38. package/src/drawer/Drawer.story.tsx +25 -0
  39. package/src/dropFade/DropFade.story.tsx +27 -0
  40. package/src/emphasis/Emphasis.story.tsx +10 -0
  41. package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +37 -0
  42. package/src/field/Field.story.tsx +16 -0
  43. package/src/flowNavigation/FlowNavigation.story.tsx +25 -0
  44. package/src/header/Header.story.tsx +17 -0
  45. package/src/iconButton/IconButton.story.tsx +14 -0
  46. package/src/image/Image.story.tsx +11 -0
  47. package/src/info/Info.story.tsx +10 -0
  48. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +23 -0
  49. package/src/inputs/InputGroup.story.tsx +37 -0
  50. package/src/inputs/SearchInput.story.tsx +22 -0
  51. package/src/inputs/SelectInput/_stories/SelectInput.story.tsx +42 -0
  52. package/src/inputs/TextArea.story.tsx +22 -0
  53. package/src/instructionsList/InstructionsList.story.tsx +19 -0
  54. package/src/label/Label.story.tsx +17 -0
  55. package/src/link/Link.story.tsx +11 -0
  56. package/src/list/List.story.tsx +19 -0
  57. package/src/listItem/_stories/ListItem.story.tsx +20 -0
  58. package/src/loader/Loader.story.tsx +6 -0
  59. package/src/logo/Logo.story.tsx +6 -0
  60. package/src/main.css +66 -0
  61. package/src/markdown/Markdown.story.tsx +17 -0
  62. package/src/modal/Modal.story.tsx +23 -0
  63. package/src/money/Money.story.tsx +7 -0
  64. package/src/moneyInput/MoneyInput.story.tsx +34 -0
  65. package/src/nudge/Nudge.css +11 -0
  66. package/src/nudge/Nudge.less +4 -0
  67. package/src/nudge/Nudge.story.tsx +26 -0
  68. package/src/nudge/Nudge.tsx +2 -1
  69. package/src/overlayHeader/OverlayHeader.story.tsx +10 -0
  70. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +23 -0
  71. package/src/popover/Popover.story.tsx +12 -0
  72. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +11 -0
  73. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +11 -0
  74. package/src/processIndicator/ProcessIndicator.story.tsx +10 -0
  75. package/src/progress/Progress.story.tsx +6 -0
  76. package/src/progressBar/ProgressBar.story.tsx +12 -0
  77. package/src/promoCard/PromoCard.story.tsx +15 -0
  78. package/src/promoCard/PromoCardGroup.story.tsx +28 -0
  79. package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +31 -0
  80. package/src/prompt/CriticalBanner/CriticalBanner.accessibility.docs.mdx +9 -0
  81. package/src/prompt/CriticalBanner/CriticalBanner.css +48 -0
  82. package/src/prompt/CriticalBanner/CriticalBanner.less +72 -0
  83. package/src/prompt/CriticalBanner/CriticalBanner.story.tsx +180 -169
  84. package/src/prompt/CriticalBanner/CriticalBanner.test.story.tsx +25 -6
  85. package/src/prompt/CriticalBanner/CriticalBanner.test.tsx +37 -0
  86. package/src/prompt/CriticalBanner/CriticalBanner.tsx +92 -83
  87. package/src/prompt/CriticalBanner/CriticalBanner.vars.less +1 -0
  88. package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +30 -0
  89. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +14 -0
  90. package/src/radio/Radio.story.tsx +34 -0
  91. package/src/radioGroup/RadioGroup.story.tsx +26 -0
  92. package/src/section/Section.story.tsx +15 -0
  93. package/src/segmentedControl/SegmentedControl.story.tsx +27 -0
  94. package/src/sentimentSurface/SentimentSurface.story.tsx +11 -0
  95. package/src/slidingPanel/SlidingPanel.story.tsx +19 -0
  96. package/src/snackbar/Snackbar.story.tsx +24 -0
  97. package/src/statusIcon/StatusIcon.story.tsx +6 -0
  98. package/src/stepper/Stepper.story.tsx +30 -0
  99. package/src/sticky/Sticky.story.tsx +22 -1
  100. package/src/switch/Switch.story.tsx +17 -0
  101. package/src/table/Table.story.tsx +32 -0
  102. package/src/tabs/Tabs.story.tsx +31 -0
  103. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +23 -0
  104. package/src/tile/Tile.story.tsx +13 -0
  105. package/src/title/Title.story.tsx +12 -0
  106. package/src/tooltip/Tooltip.story.tsx +8 -0
  107. package/src/typeahead/Typeahead.story.tsx +33 -0
  108. package/src/upload/Upload.story.tsx +24 -0
  109. package/src/uploadInput/UploadInput.story.tsx +31 -0
@@ -1,6 +1,7 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
 
3
3
  import Money from './Money';
4
+ import { createSandboxStory } from '../../.storybook/components/sandbox/SandboxEditor';
4
5
 
5
6
  export default {
6
7
  component: Money,
@@ -9,9 +10,15 @@ export default {
9
10
 
10
11
  type Story = StoryObj<typeof Money>;
11
12
 
13
+ export const Sandbox = createSandboxStory({
14
+ code: `<Money amount={1234.56} currency="GBP" />`,
15
+ scope: { Money },
16
+ });
17
+
12
18
  export const Basic: Story = {
13
19
  args: {
14
20
  amount: 1234.5678,
15
21
  currency: 'GBP',
16
22
  },
17
23
  };
24
+
@@ -3,6 +3,10 @@ import { within, userEvent, expect } from 'storybook/test';
3
3
  import { Padlock } from '@transferwise/icons';
4
4
  import { useState } from 'react';
5
5
 
6
+ import {
7
+ createSandboxStory,
8
+ globalScope,
9
+ } from '../../.storybook/components/sandbox/SandboxEditor';
6
10
  import MoneyInput, { CurrencyOptionItem } from '.';
7
11
  import { Field } from '../field/Field';
8
12
  import translations from '../i18n/en.json';
@@ -108,6 +112,36 @@ const exampleBalanceCurrency = {
108
112
  },
109
113
  } as const;
110
114
 
115
+ export const Sandbox = createSandboxStory({
116
+ code: `const App = () => {
117
+ const currencies = [
118
+ { header: 'Popular currencies' },
119
+ { value: 'EUR', label: 'EUR', note: 'Euro', currency: 'eur', searchable: 'Spain, Germany' },
120
+ { value: 'GBP', label: 'GBP', note: 'British pound', currency: 'gbp', searchable: 'England' },
121
+ { value: 'USD', label: 'USD', note: 'US dollar', currency: 'usd', searchable: 'United States' },
122
+ ];
123
+
124
+ const [selectedCurrency, setSelectedCurrency] = React.useState(currencies[1]);
125
+ const [amount, setAmount] = React.useState(1000);
126
+
127
+ return (
128
+ <Field label="Amount" id="money-input">
129
+ <MoneyInput
130
+ id="money-input"
131
+ size="lg"
132
+ amount={amount}
133
+ currencies={currencies}
134
+ selectedCurrency={selectedCurrency}
135
+ searchPlaceholder="Type a currency or country"
136
+ onAmountChange={(value) => setAmount(value)}
137
+ onCurrencyChange={(value) => setSelectedCurrency(value)}
138
+ />
139
+ </Field>
140
+ );
141
+ };`,
142
+ scope: globalScope,
143
+ });
144
+
111
145
  export const SingleCurrency: Story = {
112
146
  args: {
113
147
  currencies: [],
@@ -169,6 +169,17 @@
169
169
  margin-left: 0;
170
170
  margin-right: -22px;
171
171
  }
172
+ .wds-nudge-media-documents {
173
+ margin-left: -8px;
174
+ margin-top: 22px;
175
+ position: absolute;
176
+ width: 120px;
177
+ }
178
+ [dir="rtl"] .wds-nudge-media-documents {
179
+ transform: scaleX(-1);
180
+ margin-left: 0;
181
+ margin-right: -8px;
182
+ }
172
183
  .wds-nudge-container {
173
184
  align-items: stretch;
174
185
  display: flex;
@@ -80,6 +80,10 @@
80
80
  &-gift-box {
81
81
  .media-position(129px, -22px, 6px);
82
82
  }
83
+
84
+ &-documents {
85
+ .media-position(120px, -8px, 22px);
86
+ }
83
87
  }
84
88
 
85
89
  &-container {
@@ -1,5 +1,6 @@
1
1
  import { action } from 'storybook/actions';
2
2
  import { Assets } from '@wise/art';
3
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
3
4
 
4
5
  import { Nudge } from '..';
5
6
 
@@ -8,6 +9,22 @@ export default {
8
9
  title: 'Prompts/Nudge',
9
10
  };
10
11
 
12
+ export const Sandbox = createSandboxStory({
13
+ code: `<Nudge
14
+ mediaName="globe"
15
+ title="Get special rewards when you spend from a new balance"
16
+ link="Add balance"
17
+ href="#"
18
+ action={{
19
+ 'aria-label': 'Learn more about rewards',
20
+ text: 'Learn more',
21
+ href: '#',
22
+ }}
23
+ onDismiss={() => console.log('dismissed')}
24
+ />`,
25
+ scope: globalScope,
26
+ });
27
+
11
28
  export const Default = () => {
12
29
  return (
13
30
  <div className="d-flex flex-column">
@@ -128,6 +145,15 @@ export const Default = () => {
128
145
  onClick={action('action clicked')}
129
146
  onDismiss={action('dismissed')}
130
147
  />
148
+ <Nudge
149
+ mediaName={Assets.DOCUMENTS}
150
+ className="m-b-2"
151
+ title="Text that is no longer than two lines."
152
+ link="Link"
153
+ href="#"
154
+ onClick={action('action clicked')}
155
+ onDismiss={action('dismissed')}
156
+ />
131
157
  </div>
132
158
  );
133
159
  };
@@ -43,7 +43,8 @@ type MediaNameType =
43
43
  | `${Assets.SHOPPING_BAG}`
44
44
  | `${Assets.FLOWER}`
45
45
  | `${Assets.GIFT_BOX}`
46
- | `${Assets.BACKPACK}`;
46
+ | `${Assets.BACKPACK}`
47
+ | `${Assets.DOCUMENTS}`;
47
48
 
48
49
  type BaseProps = {
49
50
  /** @deprecated Use `mediaName` property instead. */
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { action } from 'storybook/actions';
3
3
  import { Person, Briefcase as BriefcaseIcon } from '@transferwise/icons';
4
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
4
5
  import AvatarView from '../avatarView';
5
6
  import { ProfileType } from '../common';
6
7
  import Logo from '../logo';
@@ -31,6 +32,15 @@ const avatarProfiles = {
31
32
  Profile: <Person size="24" />,
32
33
  };
33
34
 
35
+ export const Sandbox = createSandboxStory({
36
+ code: `<OverlayHeader
37
+ avatar={<AvatarView profileType={ProfileType.BUSINESS} />}
38
+ logo={<Logo />}
39
+ onClose={() => console.log('Close clicked')}
40
+ />`,
41
+ scope: globalScope,
42
+ });
43
+
34
44
  export const Basic: StoryObj<StoryArgs> = {
35
45
  render: (args) => (
36
46
  <OverlayHeader
@@ -1,5 +1,9 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
 
3
+ import {
4
+ createSandboxStory,
5
+ globalScope,
6
+ } from '../../.storybook/components/sandbox/SandboxEditor';
3
7
  import { Field } from '../field/Field';
4
8
  import PhoneNumberInput from './PhoneNumberInput';
5
9
 
@@ -12,6 +16,25 @@ export default meta;
12
16
 
13
17
  type Story = StoryObj<typeof meta>;
14
18
 
19
+ export const Sandbox = createSandboxStory({
20
+ code: `const App = () => {
21
+ const [value, setValue] = React.useState('+447573135343');
22
+
23
+ return (
24
+ <Field label="Phone number">
25
+ <PhoneNumberInput
26
+ initialValue="+447573135343"
27
+ size="md"
28
+ placeholder="Enter phone number"
29
+ searchPlaceholder="Search country"
30
+ onChange={console.log}
31
+ />
32
+ </Field>
33
+ );
34
+ };`,
35
+ scope: globalScope,
36
+ });
37
+
15
38
  export const Basic = {
16
39
  args: {
17
40
  searchPlaceholder: 'searchPlaceholder',
@@ -5,6 +5,7 @@ import { Position } from '../common';
5
5
 
6
6
  import Popover from './Popover';
7
7
  import { Meta, StoryObj } from '@storybook/react-webpack5';
8
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
8
9
 
9
10
  type Story = StoryObj<typeof Popover>;
10
11
 
@@ -44,6 +45,17 @@ export default {
44
45
  },
45
46
  } satisfies Meta<typeof Popover>;
46
47
 
48
+ export const Sandbox = createSandboxStory({
49
+ code: `<Popover
50
+ content="You'll get this rate as long as we receive your 10 EUR within the next 51 hours."
51
+ preferredPlacement="bottom"
52
+ title="Guaranteed rate"
53
+ >
54
+ <Button v2 size="md">Click here to Open Popover!</Button>
55
+ </Popover>`,
56
+ scope: globalScope,
57
+ });
58
+
47
59
  export const Basic: Story = {};
48
60
 
49
61
  /**
@@ -1,5 +1,9 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { fn } from 'storybook/test';
3
+ import {
4
+ createSandboxStory,
5
+ globalScope,
6
+ } from '../../../../.storybook/components/sandbox/SandboxEditor';
3
7
  import PrimitiveAnchor from '..';
4
8
 
5
9
  const meta: Meta<typeof PrimitiveAnchor> = {
@@ -21,6 +25,13 @@ export default meta;
21
25
 
22
26
  type Story = StoryObj<typeof PrimitiveAnchor>;
23
27
 
28
+ export const Sandbox = createSandboxStory({
29
+ code: `<PrimitiveAnchor href="https://example.com" target="_blank">
30
+ Click me
31
+ </PrimitiveAnchor>`,
32
+ scope: { ...globalScope, PrimitiveAnchor },
33
+ });
34
+
24
35
  export const Basic: Story = {};
25
36
 
26
37
  export const WithLongName: Story = {
@@ -1,5 +1,9 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { fn } from 'storybook/test';
3
+ import {
4
+ createSandboxStory,
5
+ globalScope,
6
+ } from '../../../../.storybook/components/sandbox/SandboxEditor';
3
7
  import PrimitiveButton from '..';
4
8
 
5
9
  const meta: Meta<typeof PrimitiveButton> = {
@@ -20,6 +24,13 @@ export default meta;
20
24
 
21
25
  type Story = StoryObj<typeof PrimitiveButton>;
22
26
 
27
+ export const Sandbox = createSandboxStory({
28
+ code: `<PrimitiveButton onClick={() => console.log('clicked')}>
29
+ Button text
30
+ </PrimitiveButton>`,
31
+ scope: { ...globalScope, PrimitiveButton },
32
+ });
33
+
23
34
  export const Basic: Story = {};
24
35
 
25
36
  export const WithLongName: Story = {
@@ -1,4 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { createSandboxStory } from '../../.storybook/components/sandbox/SandboxEditor';
2
3
 
3
4
  import { Size, Status } from '../common';
4
5
 
@@ -11,6 +12,15 @@ export default {
11
12
 
12
13
  type Story = StoryObj<typeof ProcessIndicator>;
13
14
 
15
+ export const Sandbox = createSandboxStory({
16
+ code: `<ProcessIndicator
17
+ status={Status.PROCESSING}
18
+ size={Size.EXTRA_SMALL}
19
+ onAnimationCompleted={(status) => console.log(status)}
20
+ />`,
21
+ scope: { ProcessIndicator },
22
+ });
23
+
14
24
  export const Basic: Story = {
15
25
  args: {
16
26
  size: Size.EXTRA_SMALL,
@@ -1,4 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { createSandboxStory } from '../../.storybook/components/sandbox/SandboxEditor';
2
3
 
3
4
  import Progress from './Progress';
4
5
 
@@ -9,6 +10,11 @@ export default {
9
10
 
10
11
  type Story = StoryObj<typeof Progress>;
11
12
 
13
+ export const Sandbox = createSandboxStory({
14
+ code: `<Progress progress={{ value: 50, max: 100 }} />`,
15
+ scope: { Progress },
16
+ });
17
+
12
18
  export const Basic: Story = {
13
19
  args: {
14
20
  progress: { value: 50, max: 100 },
@@ -1,4 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
2
3
 
3
4
  import ProgressBar from './ProgressBar';
4
5
  import Info from '../info';
@@ -10,6 +11,17 @@ export default {
10
11
 
11
12
  type Story = StoryObj<typeof ProgressBar>;
12
13
 
14
+ export const Sandbox = createSandboxStory({
15
+ code: `<ProgressBar
16
+ title="Send 5,550 GBP"
17
+ description="You have 3 days to reach your goal."
18
+ id="progress-bar-sandbox"
19
+ progress={{ value: 50, max: 100 }}
20
+ textEnd="200 GBP to go"
21
+ />`,
22
+ scope: globalScope,
23
+ });
24
+
13
25
  export const Basic: Story = {
14
26
  args: {
15
27
  description: 'You have 3 days to reach your goal.',
@@ -2,6 +2,10 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { StarFill } from '@transferwise/icons';
3
3
 
4
4
  import PromoCard, { type PromoCardCheckedProps, type PromoCardLinkProps } from './PromoCard';
5
+ import {
6
+ createSandboxStory,
7
+ globalScope,
8
+ } from '../../.storybook/components/sandbox/SandboxEditor';
5
9
 
6
10
  const meta: Meta<typeof PromoCard> = {
7
11
  component: PromoCard,
@@ -15,6 +19,17 @@ const meta: Meta<typeof PromoCard> = {
15
19
  export default meta;
16
20
  type Story = StoryObj<typeof PromoCard>;
17
21
 
22
+ export const Sandbox = createSandboxStory({
23
+ code: `<PromoCard
24
+ title="Digital"
25
+ description="A card that lives online and works anywhere. Easy, secure, and always on hand."
26
+ indicatorLabel="Free"
27
+ imageSource="https://wise.com/web-art/assets/illustrations/digital-card-2-medium@2x.webp"
28
+ href="#"
29
+ />`,
30
+ scope: globalScope,
31
+ });
32
+
18
33
  export const Default: Story = {
19
34
  args: {
20
35
  description: 'A card that lives online and works anywhere. Easy, secure, and always on hand.',
@@ -2,6 +2,10 @@ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
 
3
3
  import PromoCard from './PromoCard';
4
4
  import PromoCardGroup from './PromoCardGroup';
5
+ import {
6
+ createSandboxStory,
7
+ globalScope,
8
+ } from '../../.storybook/components/sandbox/SandboxEditor';
5
9
 
6
10
  const PromoCards = () => {
7
11
  return (
@@ -48,6 +52,30 @@ const meta: Meta<typeof PromoCardGroup> = {
48
52
  export default meta;
49
53
  type Story = StoryObj<typeof PromoCardGroup>;
50
54
 
55
+ export const Sandbox = createSandboxStory({
56
+ code: `<PromoCardGroup name="card-selection">
57
+ <PromoCard
58
+ title="Digital"
59
+ description="A card that lives online and works anywhere."
60
+ type="radio"
61
+ value="digital"
62
+ id="digital"
63
+ indicatorLabel="Free"
64
+ imageSource="https://wise.com/web-art/assets/illustrations/digital-card-2-medium@2x.webp"
65
+ />
66
+ <PromoCard
67
+ title="Standard"
68
+ description="Spend and withdraw money around the world."
69
+ type="radio"
70
+ value="standard"
71
+ id="standard"
72
+ indicatorLabel="7 GBP"
73
+ imageSource="https://wise.com/web-art/assets/illustrations/personal-card-medium@2x.webp"
74
+ />
75
+ </PromoCardGroup>`,
76
+ scope: globalScope,
77
+ });
78
+
51
79
  export const Default: Story = {
52
80
  args: {
53
81
  children: <PromoCards />,
@@ -2,6 +2,10 @@ import { ReactElement, useState } from 'react';
2
2
  import { Meta, StoryObj } from '@storybook/react-webpack5';
3
3
  import { fn } from 'storybook/test';
4
4
  import { Bank, Star, Suitcase, Briefcase } from '@transferwise/icons';
5
+ import {
6
+ createSandboxStory,
7
+ globalScope,
8
+ } from '../../../.storybook/components/sandbox/SandboxEditor';
5
9
  import { lorem10, lorem20 } from '../../test-utils';
6
10
  import Button from '../../button';
7
11
  import Title from '../../title';
@@ -186,6 +190,33 @@ export const Playground: StoryObj<PreviewStoryArgs> = {
186
190
  },
187
191
  };
188
192
 
193
+ export const Sandbox = createSandboxStory({
194
+ code: `const App = () => {
195
+ const [dismissed, setDismissed] = React.useState(false);
196
+
197
+ if (dismissed) {
198
+ return (
199
+ <Button v2 size="md" onClick={() => setDismissed(false)}>
200
+ Show prompt again
201
+ </Button>
202
+ );
203
+ }
204
+
205
+ return (
206
+ <ActionPrompt
207
+ sentiment="neutral"
208
+ title="Action Required"
209
+ description="Please complete the following action to continue."
210
+ media={{ avatar: { asset: <Bank /> } }}
211
+ action={{ label: 'Continue', onClick: () => console.log('action clicked') }}
212
+ actionSecondary={{ label: 'Cancel', onClick: () => console.log('cancel clicked') }}
213
+ onDismiss={() => setDismissed(true)}
214
+ />
215
+ );
216
+ };`,
217
+ scope: globalScope,
218
+ });
219
+
189
220
  /**
190
221
  * ActionPrompt supports multiple sentiments to communicate different types of messages:
191
222
  * - `neutral` (default): General prompts
@@ -64,6 +64,15 @@ Screen readers announce the banner content whenever:
64
64
  - The user toggles between collapsed and expanded states
65
65
  - The content (title, description, or action labels) changes
66
66
 
67
+ ## Reduced Motion
68
+
69
+ `CriticalBanner` respects the user's reduced motion preference. When reduced motion is on, the component does not show:
70
+
71
+ - the entry animation that reveals the banner from above when it first appears
72
+ - the collapse and expand animation used when the user toggles the banner content
73
+
74
+ The same content is still rendered and announced. Reduced motion only removes the visual movement.
75
+
67
76
  ## Media
68
77
 
69
78
  Custom media icons should include their own accessibility attributes. Use the `title` prop on icons to provide accessible names for screen readers:
@@ -4,6 +4,7 @@
4
4
  --Prompt-gap: var(--size-10) var(--size-16);
5
5
  --Prompt-border-radius: 0;
6
6
  container-type: inline-size;
7
+ position: relative;
7
8
  --critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
8
9
  --critical-banner-duration: 150ms;
9
10
  /* Override PrimitivePrompt's --screen-sm-max actions behaviour:
@@ -124,6 +125,48 @@
124
125
  min-width: fit-content;
125
126
  }
126
127
  }
128
+ .wds-critical-banner-overhang-query {
129
+ container-name: critical-banner-overhang;
130
+ container-type: inline-size;
131
+ inline-size: 100%;
132
+ }
133
+ .wds-critical-banner__entry-mask {
134
+ display: grid;
135
+ grid-template-rows: 0fr;
136
+ overflow: hidden;
137
+ animation: wds-critical-banner-reveal-height 400ms cubic-bezier(0.3, 0, 0.1, 1) 500ms both;
138
+ }
139
+ @container critical-banner-overhang (max-width: 600px) {
140
+ .wds-critical-banner__entry-mask {
141
+ --critical-banner-mobile-overhang-size: 32px;
142
+ }
143
+ .wds-critical-banner__entry-mask .wds-critical-banner-overhang {
144
+ margin-bottom: var(--critical-banner-mobile-overhang-size);
145
+ }
146
+ .wds-critical-banner__entry-mask .wds-critical-banner-overhang::after {
147
+ content: "";
148
+ position: absolute;
149
+ right: 0;
150
+ bottom: calc(-1 * var(--critical-banner-mobile-overhang-size));
151
+ left: 0;
152
+ height: var(--critical-banner-mobile-overhang-size);
153
+ pointer-events: none;
154
+ background: radial-gradient(circle at 100% 100%, transparent var(--critical-banner-mobile-overhang-size), var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)) 0 0 / var(--critical-banner-mobile-overhang-size) var(--critical-banner-mobile-overhang-size) no-repeat, radial-gradient(circle at 0% 100%, transparent var(--critical-banner-mobile-overhang-size), var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)) 100% 0 / var(--critical-banner-mobile-overhang-size) var(--critical-banner-mobile-overhang-size) no-repeat;
155
+ }
156
+ }
157
+ .wds-critical-banner__entry-track {
158
+ min-height: 0;
159
+ }
160
+ @keyframes wds-critical-banner-reveal-height {
161
+ from {
162
+ grid-template-rows: 0fr;
163
+ overflow: hidden;
164
+ }
165
+ to {
166
+ grid-template-rows: 1fr;
167
+ overflow: visible;
168
+ }
169
+ }
127
170
  @media (prefers-reduced-motion: reduce) {
128
171
  .wds-critical-banner__description,
129
172
  .wds-critical-banner__title,
@@ -131,4 +174,9 @@
131
174
  .wds-critical-banner__toggle {
132
175
  transition: none !important;
133
176
  }
177
+ .wds-critical-banner__entry-mask {
178
+ animation: none;
179
+ grid-template-rows: 1fr;
180
+ overflow: visible;
181
+ }
134
182
  }
@@ -7,6 +7,7 @@
7
7
  --Prompt-gap: var(--size-10) var(--size-16);
8
8
  --Prompt-border-radius: 0;
9
9
  container-type: inline-size;
10
+ position: relative;
10
11
 
11
12
  // Animation variables
12
13
  --critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
@@ -144,6 +145,71 @@
144
145
  }
145
146
  }
146
147
 
148
+ // Entry animation: after a 500ms delay, reveal the already-positioned banner
149
+ // over 400ms. The mask clips only during the reveal, then becomes visible so the
150
+ // overhang and actions are not clipped after the animation.
151
+ .wds-critical-banner-overhang-query {
152
+ container-name: critical-banner-overhang;
153
+ container-type: inline-size;
154
+ inline-size: 100%;
155
+ }
156
+
157
+ .wds-critical-banner__entry-mask {
158
+ display: grid;
159
+ grid-template-rows: 0fr;
160
+ overflow: hidden;
161
+ animation: wds-critical-banner-reveal-height 400ms cubic-bezier(0.3, 0, 0.1, 1) 500ms both;
162
+
163
+ @container critical-banner-overhang (max-width: @wds-critical-banner-mobile-overhang-max) {
164
+ --critical-banner-mobile-overhang-size: 32px;
165
+
166
+ .wds-critical-banner-overhang {
167
+ margin-bottom: var(--critical-banner-mobile-overhang-size);
168
+
169
+ &::after {
170
+ content: "";
171
+ position: absolute;
172
+ right: 0;
173
+ bottom: calc(-1 * var(--critical-banner-mobile-overhang-size));
174
+ left: 0;
175
+ height: var(--critical-banner-mobile-overhang-size);
176
+ pointer-events: none;
177
+ background:
178
+ radial-gradient(
179
+ circle at 100% 100%,
180
+ transparent var(--critical-banner-mobile-overhang-size),
181
+ var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)
182
+ )
183
+ 0 0 / var(--critical-banner-mobile-overhang-size)
184
+ var(--critical-banner-mobile-overhang-size) no-repeat,
185
+ radial-gradient(
186
+ circle at 0% 100%,
187
+ transparent var(--critical-banner-mobile-overhang-size),
188
+ var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)
189
+ )
190
+ 100% 0 / var(--critical-banner-mobile-overhang-size)
191
+ var(--critical-banner-mobile-overhang-size) no-repeat;
192
+ }
193
+ }
194
+ }
195
+ }
196
+
197
+ .wds-critical-banner__entry-track {
198
+ min-height: 0;
199
+ }
200
+
201
+ @keyframes wds-critical-banner-reveal-height {
202
+ from {
203
+ grid-template-rows: 0fr;
204
+ overflow: hidden;
205
+ }
206
+
207
+ to {
208
+ grid-template-rows: 1fr;
209
+ overflow: visible;
210
+ }
211
+ }
212
+
147
213
  // Reduced motion support
148
214
  @media (prefers-reduced-motion: reduce) {
149
215
  .wds-critical-banner__description,
@@ -152,4 +218,10 @@
152
218
  .wds-critical-banner__toggle {
153
219
  transition: none !important;
154
220
  }
221
+
222
+ .wds-critical-banner__entry-mask {
223
+ animation: none;
224
+ grid-template-rows: 1fr;
225
+ overflow: visible;
226
+ }
155
227
  }