@transferwise/components 0.0.0-experimental-06b4575 → 0.0.0-experimental-7fec974
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/dateLookup/monthCalendar/table/MonthCalendarTable.js +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.js.map +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.mjs +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.mjs.map +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.js +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.js.map +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.mjs +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.mjs.map +1 -1
- package/build/field/Field.js +1 -0
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +1 -0
- package/build/field/Field.mjs.map +1 -1
- package/build/header/Header.js +1 -1
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/header/Header.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/inputs/Input.js.map +1 -1
- package/build/inputs/Input.mjs.map +1 -1
- package/build/inputs/SearchInput.js.map +1 -1
- package/build/inputs/SearchInput.mjs.map +1 -1
- package/build/inputs/TextArea.js.map +1 -1
- package/build/inputs/TextArea.mjs.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +1 -0
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +1 -0
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/main.css +31 -0
- package/build/prompt/InfoPrompt/InfoPrompt.js +113 -0
- package/build/prompt/InfoPrompt/InfoPrompt.js.map +1 -0
- package/build/prompt/InfoPrompt/InfoPrompt.mjs +111 -0
- package/build/prompt/InfoPrompt/InfoPrompt.mjs.map +1 -0
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
- package/build/radioOption/RadioOption.js.map +1 -1
- package/build/radioOption/RadioOption.mjs.map +1 -1
- package/build/slidingPanel/SlidingPanel.js.map +1 -1
- package/build/slidingPanel/SlidingPanel.mjs.map +1 -1
- package/build/styles/main.css +31 -0
- package/build/styles/prompt/InfoPrompt/InfoPrompt.css +31 -0
- package/build/table/TableCell.js.map +1 -1
- package/build/table/TableCell.mjs.map +1 -1
- package/build/tabs/Tabs.js +1 -1
- package/build/tabs/Tabs.js.map +1 -1
- package/build/tabs/Tabs.mjs +1 -1
- package/build/tabs/Tabs.mjs.map +1 -1
- package/build/typeahead/Typeahead.js +1 -0
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +1 -0
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/Input.d.ts.map +1 -1
- package/build/types/inputs/SearchInput.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/PrimitiveButton.types.d.ts.map +1 -1
- package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts +56 -0
- package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts.map +1 -0
- package/build/types/prompt/InfoPrompt/index.d.ts +3 -0
- package/build/types/prompt/InfoPrompt/index.d.ts.map +1 -0
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts +5 -5
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
- package/build/types/prompt/index.d.ts +2 -0
- package/build/types/prompt/index.d.ts.map +1 -1
- package/build/types/radioOption/RadioOption.d.ts.map +1 -1
- package/build/types/slidingPanel/SlidingPanel.d.ts.map +1 -1
- package/build/types/table/TableCell.d.ts.map +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
- package/build/uploadInput/UploadInput.js +1 -1
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/build/uploadInput/UploadInput.mjs.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
- package/package.json +3 -3
- package/src/actionButton/ActionButton.story.tsx +9 -2
- package/src/avatar/Avatar.story.tsx +8 -2
- package/src/avatarLayout/AvatarLayout.story.tsx +3 -3
- package/src/avatarView/AvatarView.story.tsx +29 -24
- package/src/button/_stories/Button.test.story.tsx +10 -5
- package/src/checkbox/Checkbox.story.tsx +16 -3
- package/src/circularButton/CircularButton.story.tsx +7 -2
- package/src/common/bottomSheet/BottomSheet.story.tsx +32 -6
- package/src/common/circle/Circle.story.tsx +14 -3
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +16 -3
- package/src/dateInput/DateInput.test.story.tsx +13 -3
- package/src/dateLookup/DateLookup.story.tsx +7 -9
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.tsx +1 -5
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.tsx +1 -1
- package/src/header/Header.test.story.tsx +10 -5
- package/src/header/Header.tsx +1 -1
- package/src/index.ts +2 -1
- package/src/info/Info.story.tsx +20 -4
- package/src/inputs/Input.tsx +8 -9
- package/src/inputs/SearchInput.tsx +8 -9
- package/src/inputs/TextArea.tsx +6 -7
- package/src/listItem/_stories/variants/ListItem.brightGreen.test.story.tsx +7 -2
- package/src/listItem/_stories/variants/ListItem.dark.test.story.tsx +7 -2
- package/src/listItem/_stories/variants/ListItem.forestGreen.test.story.tsx +7 -2
- package/src/listItem/_stories/variants/ListItem.rtl.test.story.tsx +7 -2
- package/src/main.css +31 -0
- package/src/main.less +2 -1
- package/src/modal/Modal.story.tsx +31 -6
- package/src/primitives/PrimitiveAnchor/PrimitiveAnchor.types.ts +1 -3
- package/src/primitives/PrimitiveButton/PrimitiveButton.types.ts +1 -3
- package/src/prompt/ActionPrompt/ActionPrompt.less +1 -1
- package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +7 -2
- package/src/prompt/ActionPrompt/ActionPrompt.test.tsx +2 -7
- package/src/prompt/InfoPrompt/InfoPrompt.css +31 -0
- package/src/prompt/InfoPrompt/InfoPrompt.less +37 -0
- package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +312 -0
- package/src/prompt/InfoPrompt/InfoPrompt.test.story.tsx +246 -0
- package/src/prompt/InfoPrompt/InfoPrompt.test.tsx +224 -0
- package/src/prompt/InfoPrompt/InfoPrompt.tsx +148 -0
- package/src/prompt/InfoPrompt/index.ts +2 -0
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +1 -1
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +5 -5
- package/src/prompt/index.ts +5 -0
- package/src/radioOption/RadioOption.tsx +2 -1
- package/src/select/Select.story.tsx +1 -1
- package/src/slidingPanel/SlidingPanel.tsx +4 -2
- package/src/snackbar/Snackbar.test.story.tsx +32 -6
- package/src/ssr.test.tsx +1 -0
- package/src/statusIcon/StatusIcon.story.tsx +9 -5
- package/src/table/TableCell.tsx +1 -3
- package/src/tabs/Tabs.tsx +1 -1
- package/src/tooltip/Tooltip.story.tsx +7 -2
- package/src/uploadInput/UploadInput.tsx +1 -1
- package/src/withDisplayFormat/WithDisplayFormat.tsx +13 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta } from '@storybook/react-webpack5';
|
|
2
2
|
import { ListItem, type ListItemProps } from '../../ListItem';
|
|
3
3
|
import { VariantStory } from './helpers';
|
|
4
|
-
import {
|
|
4
|
+
import { allModes } from '../../../../.storybook/modes';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
component: ListItem,
|
|
@@ -16,7 +16,12 @@ export default {
|
|
|
16
16
|
|
|
17
17
|
const Default = {
|
|
18
18
|
...VariantStory,
|
|
19
|
-
|
|
19
|
+
parameters: {
|
|
20
|
+
variants: ['rtl'],
|
|
21
|
+
chromatic: {
|
|
22
|
+
rtl: allModes.rtl,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
20
25
|
args: { variant: 'rtl' },
|
|
21
26
|
};
|
|
22
27
|
|
package/src/main.css
CHANGED
|
@@ -5441,6 +5441,37 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5441
5441
|
.wds-inline-prompt .wds-inline-prompt-process-indicator .process-circle {
|
|
5442
5442
|
stroke: currentColor;
|
|
5443
5443
|
}
|
|
5444
|
+
.wds-info-prompt {
|
|
5445
|
+
--Prompt-gap: var(--size-8);
|
|
5446
|
+
--Prompt-padding: 12px;
|
|
5447
|
+
}
|
|
5448
|
+
.wds-info-prompt__content {
|
|
5449
|
+
display: flex;
|
|
5450
|
+
flex-direction: column;
|
|
5451
|
+
justify-content: center;
|
|
5452
|
+
}
|
|
5453
|
+
.wds-info-prompt__content:has(.wds-info-prompt__title) {
|
|
5454
|
+
justify-content: flex-start;
|
|
5455
|
+
/* Top align when title exists */
|
|
5456
|
+
}
|
|
5457
|
+
.wds-info-prompt__title,
|
|
5458
|
+
.wds-info-prompt__description {
|
|
5459
|
+
display: block;
|
|
5460
|
+
color: var(--color-sentiment-primary);
|
|
5461
|
+
}
|
|
5462
|
+
.wds-info-prompt__action {
|
|
5463
|
+
margin-top: var(--Prompt-gap);
|
|
5464
|
+
}
|
|
5465
|
+
.wds-info-prompt__media {
|
|
5466
|
+
display: flex;
|
|
5467
|
+
}
|
|
5468
|
+
.wds-info-prompt__media svg {
|
|
5469
|
+
width: 24px;
|
|
5470
|
+
height: 24px;
|
|
5471
|
+
}
|
|
5472
|
+
.wds-info-prompt .wds-prompt__media-wrapper {
|
|
5473
|
+
padding: 0;
|
|
5474
|
+
}
|
|
5444
5475
|
.wds-radio-group .np-radio:last-child label {
|
|
5445
5476
|
margin-bottom: 0;
|
|
5446
5477
|
}
|
package/src/main.less
CHANGED
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
@import "./promoCard/PromoCard.less";
|
|
63
63
|
@import "./prompt/PrimitivePrompt/PrimitivePrompt.less";
|
|
64
64
|
@import "./prompt/InlinePrompt/InlinePrompt.less";
|
|
65
|
+
@import "./prompt/InfoPrompt/InfoPrompt.less";
|
|
65
66
|
@import "./radioGroup/RadioGroup.less";
|
|
66
67
|
@import "./section/Section.less";
|
|
67
68
|
@import "./slidingPanel/SlidingPanel.less";
|
|
@@ -89,4 +90,4 @@
|
|
|
89
90
|
@import "./prompt/ActionPrompt/ActionPrompt.less";
|
|
90
91
|
|
|
91
92
|
// List all less files in src in alphabetical order: find -s src -type f -name '*.less' ! -name 'main.less'
|
|
92
|
-
// Make sure you are not referencing main.less itself in this file!
|
|
93
|
+
// Make sure you are not referencing main.less itself in this file!
|
|
@@ -6,7 +6,7 @@ import { useState } from 'react';
|
|
|
6
6
|
import { Button, Modal, ModalProps } from '..';
|
|
7
7
|
import { CommonProps, Scroll } from '../common';
|
|
8
8
|
import { lorem10, lorem100, lorem1000 } from '../test-utils';
|
|
9
|
-
import {
|
|
9
|
+
import { allModes } from '../../.storybook/modes';
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
12
|
component: Modal,
|
|
@@ -78,7 +78,12 @@ export const Basic: Story = {
|
|
|
78
78
|
|
|
79
79
|
export const BasicMobile: Story = {
|
|
80
80
|
...Basic,
|
|
81
|
-
|
|
81
|
+
parameters: {
|
|
82
|
+
variants: ['mobile'],
|
|
83
|
+
chromatic: {
|
|
84
|
+
mobile: allModes.largeMobile,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
82
87
|
};
|
|
83
88
|
|
|
84
89
|
export const ContentScroll: Story = {
|
|
@@ -92,7 +97,12 @@ export const ContentScroll: Story = {
|
|
|
92
97
|
|
|
93
98
|
export const ContentScrollMobile: Story = {
|
|
94
99
|
...ContentScroll,
|
|
95
|
-
|
|
100
|
+
parameters: {
|
|
101
|
+
variants: ['mobile'],
|
|
102
|
+
chromatic: {
|
|
103
|
+
mobile: allModes.largeMobile,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
96
106
|
};
|
|
97
107
|
|
|
98
108
|
export const ViewportScroll: Story = {
|
|
@@ -106,7 +116,12 @@ export const ViewportScroll: Story = {
|
|
|
106
116
|
|
|
107
117
|
export const ViewportScrollMobile: Story = {
|
|
108
118
|
...ViewportScroll,
|
|
109
|
-
|
|
119
|
+
parameters: {
|
|
120
|
+
variants: ['mobile'],
|
|
121
|
+
chromatic: {
|
|
122
|
+
mobile: allModes.largeMobile,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
110
125
|
};
|
|
111
126
|
|
|
112
127
|
export const WithoutTitle: Story = {
|
|
@@ -119,7 +134,12 @@ export const WithoutTitle: Story = {
|
|
|
119
134
|
|
|
120
135
|
export const WithoutTitleMobile: Story = {
|
|
121
136
|
...WithoutTitle,
|
|
122
|
-
|
|
137
|
+
parameters: {
|
|
138
|
+
variants: ['mobile'],
|
|
139
|
+
chromatic: {
|
|
140
|
+
mobile: allModes.largeMobile,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
123
143
|
};
|
|
124
144
|
|
|
125
145
|
export const WithThemeProviderInContent: Story = {
|
|
@@ -141,5 +161,10 @@ export const WithThemeProviderInContent: Story = {
|
|
|
141
161
|
|
|
142
162
|
export const WithThemeProviderInContentMobile: Story = {
|
|
143
163
|
...WithThemeProviderInContent,
|
|
144
|
-
|
|
164
|
+
parameters: {
|
|
165
|
+
variants: ['mobile'],
|
|
166
|
+
chromatic: {
|
|
167
|
+
mobile: allModes.largeMobile,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
145
170
|
};
|
|
@@ -11,9 +11,7 @@ export type PrimitiveAnchorElementRef = React.Ref<HTMLAnchorElement>;
|
|
|
11
11
|
* Properties for the anchor component.
|
|
12
12
|
*/
|
|
13
13
|
export interface PrimitiveAnchorProps
|
|
14
|
-
extends BasePrimitiveProps,
|
|
15
|
-
StyleProp,
|
|
16
|
-
Omit<PrimitiveAnchorAttributes, 'role' | 'type'> {
|
|
14
|
+
extends BasePrimitiveProps, StyleProp, Omit<PrimitiveAnchorAttributes, 'role' | 'type'> {
|
|
17
15
|
/** Content of the anchor */
|
|
18
16
|
children?: ReactNode;
|
|
19
17
|
|
|
@@ -11,9 +11,7 @@ export type PrimitiveButtonElementRef = React.Ref<HTMLButtonElement>;
|
|
|
11
11
|
* Properties for the Button component.
|
|
12
12
|
*/
|
|
13
13
|
export interface PrimitiveButtonProps
|
|
14
|
-
extends BasePrimitiveProps,
|
|
15
|
-
StyleProp,
|
|
16
|
-
PrimitiveButtonAttributes {
|
|
14
|
+
extends BasePrimitiveProps, StyleProp, PrimitiveButtonAttributes {
|
|
17
15
|
/** Content of the button */
|
|
18
16
|
children?: ReactNode;
|
|
19
17
|
|
|
@@ -4,7 +4,7 @@ import { fn } from 'storybook/test';
|
|
|
4
4
|
import { Bank } from '@transferwise/icons';
|
|
5
5
|
import { ActionPrompt } from './ActionPrompt';
|
|
6
6
|
import { lorem10 } from '../../test-utils';
|
|
7
|
-
import {
|
|
7
|
+
import { allModes } from '../../../.storybook/modes';
|
|
8
8
|
|
|
9
9
|
const meta: Meta<typeof ActionPrompt> = {
|
|
10
10
|
title: 'Prompts/ActionPrompt',
|
|
@@ -60,7 +60,12 @@ export const AllSentiments: Story = {
|
|
|
60
60
|
|
|
61
61
|
export const Mobile: Story = {
|
|
62
62
|
...AllSentiments,
|
|
63
|
-
|
|
63
|
+
parameters: {
|
|
64
|
+
variants: ['mobile'],
|
|
65
|
+
chromatic: {
|
|
66
|
+
mobile: allModes.largeMobile,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
export const PrimaryActionOnly: Story = {
|
|
@@ -56,9 +56,7 @@ describe('ActionPrompt', () => {
|
|
|
56
56
|
it('calls primary action onClick when clicked', async () => {
|
|
57
57
|
const onClick = jest.fn();
|
|
58
58
|
const user = userEvent.setup();
|
|
59
|
-
render(
|
|
60
|
-
<ActionPrompt {...defaultProps} action={{ label: 'Primary Action', onClick }} />,
|
|
61
|
-
);
|
|
59
|
+
render(<ActionPrompt {...defaultProps} action={{ label: 'Primary Action', onClick }} />);
|
|
62
60
|
const button = screen.getByRole('button', { name: 'Primary Action' });
|
|
63
61
|
await user.click(button);
|
|
64
62
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
@@ -66,10 +64,7 @@ describe('ActionPrompt', () => {
|
|
|
66
64
|
|
|
67
65
|
it('renders primary action as link when href is provided', () => {
|
|
68
66
|
render(
|
|
69
|
-
<ActionPrompt
|
|
70
|
-
{...defaultProps}
|
|
71
|
-
action={{ label: 'Primary Action', href: '/test-url' }}
|
|
72
|
-
/>,
|
|
67
|
+
<ActionPrompt {...defaultProps} action={{ label: 'Primary Action', href: '/test-url' }} />,
|
|
73
68
|
);
|
|
74
69
|
const link = screen.getByRole('link', { name: 'Primary Action' });
|
|
75
70
|
expect(link).toHaveAttribute('href', '/test-url');
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.wds-info-prompt {
|
|
2
|
+
--Prompt-gap: var(--size-8);
|
|
3
|
+
--Prompt-padding: 12px;
|
|
4
|
+
}
|
|
5
|
+
.wds-info-prompt__content {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
}
|
|
10
|
+
.wds-info-prompt__content:has(.wds-info-prompt__title) {
|
|
11
|
+
justify-content: flex-start;
|
|
12
|
+
/* Top align when title exists */
|
|
13
|
+
}
|
|
14
|
+
.wds-info-prompt__title,
|
|
15
|
+
.wds-info-prompt__description {
|
|
16
|
+
display: block;
|
|
17
|
+
color: var(--color-sentiment-primary);
|
|
18
|
+
}
|
|
19
|
+
.wds-info-prompt__action {
|
|
20
|
+
margin-top: var(--Prompt-gap);
|
|
21
|
+
}
|
|
22
|
+
.wds-info-prompt__media {
|
|
23
|
+
display: flex;
|
|
24
|
+
}
|
|
25
|
+
.wds-info-prompt__media svg {
|
|
26
|
+
width: 24px;
|
|
27
|
+
height: 24px;
|
|
28
|
+
}
|
|
29
|
+
.wds-info-prompt .wds-prompt__media-wrapper {
|
|
30
|
+
padding: 0;
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.wds-info-prompt {
|
|
2
|
+
--Prompt-gap: var(--size-8);
|
|
3
|
+
--Prompt-padding: 12px;
|
|
4
|
+
|
|
5
|
+
&__content {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
|
|
10
|
+
&:has(.wds-info-prompt__title) {
|
|
11
|
+
justify-content: flex-start; /* Top align when title exists */
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&__title,
|
|
16
|
+
&__description {
|
|
17
|
+
display: block;
|
|
18
|
+
color: var(--color-sentiment-primary);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&__action {
|
|
22
|
+
margin-top: var(--Prompt-gap);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__media {
|
|
26
|
+
display: flex;
|
|
27
|
+
|
|
28
|
+
svg {
|
|
29
|
+
width: 24px;
|
|
30
|
+
height: 24px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.wds-prompt__media-wrapper {
|
|
35
|
+
padding: 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
|
+
import { action } from 'storybook/actions';
|
|
4
|
+
import { Confetti, GiftBox, Star, Travel } from '@transferwise/icons';
|
|
5
|
+
import { InfoPrompt, InfoPromptProps } from './InfoPrompt';
|
|
6
|
+
|
|
7
|
+
const withComponentGrid =
|
|
8
|
+
({ maxWidth = 'auto', gap = '1rem' } = {}) =>
|
|
9
|
+
(Story: () => ReactElement) => (
|
|
10
|
+
<div
|
|
11
|
+
style={{
|
|
12
|
+
width: '100%',
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
justifyContent: 'flex-start',
|
|
16
|
+
alignItems: 'flex-start',
|
|
17
|
+
alignContent: 'flex-start',
|
|
18
|
+
gap,
|
|
19
|
+
maxWidth,
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
<Story />
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
title: 'Prompts/InfoPrompt',
|
|
28
|
+
component: InfoPrompt,
|
|
29
|
+
tags: ['new'],
|
|
30
|
+
decorators: [withComponentGrid()],
|
|
31
|
+
args: {
|
|
32
|
+
description: 'Your payment is being processed.',
|
|
33
|
+
},
|
|
34
|
+
argTypes: {
|
|
35
|
+
sentiment: {
|
|
36
|
+
control: 'select',
|
|
37
|
+
options: ['success', 'negative', 'neutral', 'warning', 'proposition'],
|
|
38
|
+
},
|
|
39
|
+
title: {
|
|
40
|
+
control: 'text',
|
|
41
|
+
table: {
|
|
42
|
+
type: { summary: 'ReactNode' },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
description: {
|
|
46
|
+
control: 'text',
|
|
47
|
+
table: {
|
|
48
|
+
type: { summary: 'ReactNode' },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
parameters: {
|
|
53
|
+
docs: {
|
|
54
|
+
toc: true,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
} satisfies Meta<InfoPromptProps>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Convenience controls for previewing rich markup,
|
|
61
|
+
* not otherwise possible via Storybook
|
|
62
|
+
*/
|
|
63
|
+
type PreviewStoryArgs = InfoPromptProps & {
|
|
64
|
+
previewMedia: boolean;
|
|
65
|
+
previewOnDismiss: boolean;
|
|
66
|
+
previewAction: boolean;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const previewArgGroup = {
|
|
70
|
+
category: 'Storybook Preview options',
|
|
71
|
+
type: {
|
|
72
|
+
summary: undefined,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const previewArgTypes = {
|
|
77
|
+
previewMedia: {
|
|
78
|
+
name: 'Preview with `media`',
|
|
79
|
+
control: 'boolean',
|
|
80
|
+
table: previewArgGroup,
|
|
81
|
+
},
|
|
82
|
+
previewOnDismiss: {
|
|
83
|
+
name: 'Preview with `onDismiss`',
|
|
84
|
+
control: 'boolean',
|
|
85
|
+
table: previewArgGroup,
|
|
86
|
+
},
|
|
87
|
+
previewAction: {
|
|
88
|
+
name: 'Preview with `action`',
|
|
89
|
+
control: 'boolean',
|
|
90
|
+
table: previewArgGroup,
|
|
91
|
+
},
|
|
92
|
+
} as const;
|
|
93
|
+
|
|
94
|
+
const getPropsForPreview = (
|
|
95
|
+
args: PreviewStoryArgs,
|
|
96
|
+
): [InfoPromptProps, Partial<InfoPromptProps>] => {
|
|
97
|
+
const { previewMedia, previewOnDismiss, previewAction, ...props } = args;
|
|
98
|
+
|
|
99
|
+
return [
|
|
100
|
+
props,
|
|
101
|
+
{
|
|
102
|
+
media: previewMedia ? { asset: <Star title="Starred" /> } : undefined,
|
|
103
|
+
onDismiss: previewOnDismiss ? action('onDismiss') : undefined,
|
|
104
|
+
action: previewAction
|
|
105
|
+
? { label: 'Learn more', onClick: action('action.onClick') }
|
|
106
|
+
: undefined,
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const Playground: StoryObj<PreviewStoryArgs> = {
|
|
112
|
+
tags: ['!autodocs'],
|
|
113
|
+
argTypes: previewArgTypes,
|
|
114
|
+
args: {
|
|
115
|
+
previewMedia: false,
|
|
116
|
+
previewOnDismiss: false,
|
|
117
|
+
previewAction: false,
|
|
118
|
+
},
|
|
119
|
+
render: (args: PreviewStoryArgs) => {
|
|
120
|
+
const [props, previewProps] = getPropsForPreview(args);
|
|
121
|
+
return <InfoPrompt {...props} {...previewProps} />;
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* InfoPrompt supports multiple sentiments to communicate different types of messages:
|
|
127
|
+
* - `neutral` (default): General information
|
|
128
|
+
* - `success`: Success messages
|
|
129
|
+
* - `negative`: Error messages
|
|
130
|
+
* - `warning`: Warning messages
|
|
131
|
+
* - `proposition`: Promotional content (uses GiftBox icon by default)
|
|
132
|
+
*/
|
|
133
|
+
export const Sentiments: StoryObj<InfoPromptProps> = {
|
|
134
|
+
render: (args: InfoPromptProps) => (
|
|
135
|
+
<>
|
|
136
|
+
<InfoPrompt {...args} sentiment="neutral" description="This is a neutral message." />
|
|
137
|
+
<InfoPrompt {...args} sentiment="success" description="Your payment was successful!" />
|
|
138
|
+
<InfoPrompt {...args} sentiment="negative" description="Something went wrong." />
|
|
139
|
+
<InfoPrompt {...args} sentiment="warning" description="Please review your details." />
|
|
140
|
+
<InfoPrompt {...args} sentiment="proposition" description="Check out our new features!" />
|
|
141
|
+
</>
|
|
142
|
+
),
|
|
143
|
+
decorators: [withComponentGrid()],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* InfoPrompt can include both a title and description for more detailed messaging.
|
|
148
|
+
*/
|
|
149
|
+
export const WithTitle: StoryObj<InfoPromptProps> = {
|
|
150
|
+
render: (args: InfoPromptProps) => (
|
|
151
|
+
<>
|
|
152
|
+
<InfoPrompt
|
|
153
|
+
{...args}
|
|
154
|
+
sentiment="success"
|
|
155
|
+
title="Payment Successful"
|
|
156
|
+
description="Your money is on its way to the recipient."
|
|
157
|
+
/>
|
|
158
|
+
<InfoPrompt
|
|
159
|
+
{...args}
|
|
160
|
+
sentiment="warning"
|
|
161
|
+
title="Payment Delayed"
|
|
162
|
+
description="Payments sent today might not arrive in time for the holidays."
|
|
163
|
+
/>
|
|
164
|
+
<InfoPrompt
|
|
165
|
+
{...args}
|
|
166
|
+
sentiment="negative"
|
|
167
|
+
title="Payment Failed"
|
|
168
|
+
description="We couldn't process your payment. Please try again."
|
|
169
|
+
/>
|
|
170
|
+
</>
|
|
171
|
+
),
|
|
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
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Use the `action` prop to add a clickable link below the message.
|
|
202
|
+
* Actions can have an `href` for navigation or an `onClick` for custom behavior.
|
|
203
|
+
*/
|
|
204
|
+
export const WithAction: StoryObj<InfoPromptProps> = {
|
|
205
|
+
render: (args: InfoPromptProps) => (
|
|
206
|
+
<>
|
|
207
|
+
<InfoPrompt
|
|
208
|
+
{...args}
|
|
209
|
+
sentiment="neutral"
|
|
210
|
+
description="New feature available"
|
|
211
|
+
action={{ label: 'Learn more', href: '/features', target: '_blank' }}
|
|
212
|
+
/>
|
|
213
|
+
<InfoPrompt
|
|
214
|
+
{...args}
|
|
215
|
+
sentiment="warning"
|
|
216
|
+
title="Action Required"
|
|
217
|
+
description="Please verify your identity to continue."
|
|
218
|
+
action={{ label: 'Verify now', onClick: action('verify') }}
|
|
219
|
+
/>
|
|
220
|
+
<InfoPrompt
|
|
221
|
+
{...args}
|
|
222
|
+
sentiment="proposition"
|
|
223
|
+
title="Special Offer"
|
|
224
|
+
description="Get 50% off your next transfer!"
|
|
225
|
+
action={{ label: 'Claim offer', onClick: action('claim') }}
|
|
226
|
+
/>
|
|
227
|
+
</>
|
|
228
|
+
),
|
|
229
|
+
decorators: [withComponentGrid()],
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Use the `media` prop to override the default status icon with a custom icon.
|
|
234
|
+
* This is useful for matching the prompt's visual language to its content.
|
|
235
|
+
*
|
|
236
|
+
* Success and proposition sentiments support both standard checkmark and confetti variations.
|
|
237
|
+
*/
|
|
238
|
+
export const CustomMedia: StoryObj<InfoPromptProps> = {
|
|
239
|
+
render: (args: InfoPromptProps) => (
|
|
240
|
+
<>
|
|
241
|
+
<InfoPrompt
|
|
242
|
+
{...args}
|
|
243
|
+
sentiment="success"
|
|
244
|
+
description="Saved to favorites!"
|
|
245
|
+
media={{ asset: <Star title="Starred" /> }}
|
|
246
|
+
/>
|
|
247
|
+
<InfoPrompt
|
|
248
|
+
{...args}
|
|
249
|
+
sentiment="success"
|
|
250
|
+
title="Congratulations!"
|
|
251
|
+
description="You've completed all the steps."
|
|
252
|
+
media={{ asset: <Confetti size={24} title="Celebration" /> }}
|
|
253
|
+
/>
|
|
254
|
+
<InfoPrompt
|
|
255
|
+
{...args}
|
|
256
|
+
sentiment="proposition"
|
|
257
|
+
title="Check out more!"
|
|
258
|
+
description="New ways to send money with Wise!"
|
|
259
|
+
media={{ asset: <GiftBox title="Gift" /> }}
|
|
260
|
+
/>
|
|
261
|
+
<InfoPrompt
|
|
262
|
+
{...args}
|
|
263
|
+
sentiment="success"
|
|
264
|
+
description="Your travel account is ready!"
|
|
265
|
+
media={{ asset: <Travel title="Travel" /> }}
|
|
266
|
+
/>
|
|
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
|
+
<InfoPrompt
|
|
280
|
+
{...args}
|
|
281
|
+
sentiment="success"
|
|
282
|
+
description="Your profile has been saved"
|
|
283
|
+
role="status"
|
|
284
|
+
/>
|
|
285
|
+
<InfoPrompt
|
|
286
|
+
{...args}
|
|
287
|
+
sentiment="negative"
|
|
288
|
+
title="Error"
|
|
289
|
+
description="Your session has expired. Please log in again."
|
|
290
|
+
role="alert"
|
|
291
|
+
/>
|
|
292
|
+
</>
|
|
293
|
+
),
|
|
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
|
+
};
|