@transferwise/components 46.106.0 → 46.108.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.
- package/build/actionOption/ActionOption.js.map +1 -1
- package/build/actionOption/ActionOption.mjs.map +1 -1
- package/build/checkboxOption/CheckboxOption.js.map +1 -1
- package/build/checkboxOption/CheckboxOption.mjs.map +1 -1
- package/build/header/Header.js +1 -0
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -0
- package/build/header/Header.mjs.map +1 -1
- package/build/legacylistItem/LegacyListItem.js.map +1 -1
- package/build/legacylistItem/LegacyListItem.mjs.map +1 -1
- package/build/link/Link.js +6 -2
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +6 -2
- package/build/link/Link.mjs.map +1 -1
- package/build/listItem/ListItem.js +28 -16
- package/build/listItem/ListItem.js.map +1 -1
- package/build/listItem/ListItem.mjs +28 -16
- package/build/listItem/ListItem.mjs.map +1 -1
- package/build/listItem/ListItemContext.js.map +1 -1
- package/build/listItem/ListItemContext.mjs.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.js +1 -3
- package/build/listItem/Navigation/ListItemNavigation.js.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.mjs +2 -4
- package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -1
- package/build/listItem/Prompt/InlinePrompt/InlinePrompt.js +74 -0
- package/build/listItem/Prompt/InlinePrompt/InlinePrompt.js.map +1 -0
- package/build/listItem/Prompt/InlinePrompt/InlinePrompt.mjs +72 -0
- package/build/listItem/Prompt/InlinePrompt/InlinePrompt.mjs.map +1 -0
- package/build/listItem/Prompt/ListItemPrompt.js +10 -15
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +11 -16
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/main.css +122 -81
- package/build/navigationOption/NavigationOption.js.map +1 -1
- package/build/navigationOption/NavigationOption.mjs.map +1 -1
- package/build/navigationOptionsList/NavigationOptionsList.js.map +1 -1
- package/build/navigationOptionsList/NavigationOptionsList.mjs.map +1 -1
- package/build/radioOption/RadioOption.js.map +1 -1
- package/build/radioOption/RadioOption.mjs.map +1 -1
- package/build/styles/link/Link.css +7 -0
- package/build/styles/listItem/ListItem.css +115 -81
- package/build/styles/listItem/ListItem.grid.css +11 -3
- package/build/styles/listItem/ListItem.vars.css +0 -0
- package/build/styles/listItem/Prompt/InlinePrompt/InlinePrompt.css +153 -0
- package/build/styles/listItem/Prompt/ListItemPrompt.css +72 -72
- package/build/styles/main.css +122 -81
- package/build/summary/Summary.js +8 -0
- package/build/summary/Summary.js.map +1 -1
- package/build/summary/Summary.mjs +8 -0
- package/build/summary/Summary.mjs.map +1 -1
- package/build/switchOption/SwitchOption.js +8 -0
- package/build/switchOption/SwitchOption.js.map +1 -1
- package/build/switchOption/SwitchOption.mjs +8 -0
- package/build/switchOption/SwitchOption.mjs.map +1 -1
- package/build/types/actionOption/ActionOption.d.ts +8 -0
- package/build/types/actionOption/ActionOption.d.ts.map +1 -1
- package/build/types/checkboxOption/CheckboxOption.d.ts +8 -0
- package/build/types/checkboxOption/CheckboxOption.d.ts.map +1 -1
- package/build/types/header/Header.d.ts +1 -0
- package/build/types/header/Header.d.ts.map +1 -1
- package/build/types/legacylistItem/LegacyListItem.d.ts +8 -0
- package/build/types/legacylistItem/LegacyListItem.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +1 -1
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/listItem/ListItem.d.ts +10 -1
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/listItem/ListItemContext.d.ts +2 -1
- package/build/types/listItem/ListItemContext.d.ts.map +1 -1
- package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +1 -1
- package/build/types/listItem/Prompt/InlinePrompt/InlinePrompt.d.ts +15 -0
- package/build/types/listItem/Prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -0
- package/build/types/listItem/Prompt/InlinePrompt/index.d.ts +3 -0
- package/build/types/listItem/Prompt/InlinePrompt/index.d.ts.map +1 -0
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts +4 -6
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -1
- package/build/types/listItem/_stories/helpers.d.ts +1 -1
- package/build/types/listItem/_stories/helpers.d.ts.map +1 -1
- package/build/types/listItem/_stories/subcomponents.d.ts +4 -0
- package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -1
- package/build/types/listItem/_stories/variants/helpers.d.ts.map +1 -1
- package/build/types/listItem/constants.d.ts +16 -0
- package/build/types/listItem/constants.d.ts.map +1 -0
- package/build/types/listItem/useListItemControl.d.ts +1 -1
- package/build/types/navigationOption/NavigationOption.d.ts +8 -0
- package/build/types/navigationOption/NavigationOption.d.ts.map +1 -1
- package/build/types/navigationOptionsList/NavigationOptionsList.d.ts +9 -0
- package/build/types/navigationOptionsList/NavigationOptionsList.d.ts.map +1 -1
- package/build/types/radioOption/RadioOption.d.ts +8 -0
- package/build/types/radioOption/RadioOption.d.ts.map +1 -1
- package/build/types/summary/Summary.d.ts +8 -0
- package/build/types/summary/Summary.d.ts.map +1 -1
- package/build/types/switchOption/SwitchOption.d.ts +8 -0
- package/build/types/switchOption/SwitchOption.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/actionOption/ActionOption.story.tsx +4 -0
- package/src/actionOption/ActionOption.tsx +8 -0
- package/src/checkboxOption/CheckboxOption.story.tsx +4 -0
- package/src/checkboxOption/CheckboxOption.tsx +8 -0
- package/src/header/Header.story.tsx +14 -0
- package/src/header/Header.tsx +2 -0
- package/src/legacylistItem/LegacyListItem.story.tsx +4 -0
- package/src/legacylistItem/LegacyListItem.tsx +8 -0
- package/src/link/Link.css +7 -0
- package/src/link/Link.less +8 -0
- package/src/link/Link.spec.tsx +28 -0
- package/src/link/Link.story.tsx +72 -16
- package/src/link/Link.tsx +5 -1
- package/src/listItem/ListItem.css +115 -81
- package/src/listItem/ListItem.grid.css +11 -3
- package/src/listItem/ListItem.grid.less +14 -4
- package/src/listItem/ListItem.less +35 -8
- package/src/listItem/ListItem.spec.tsx +37 -1
- package/src/listItem/ListItem.tsx +47 -21
- package/src/listItem/ListItem.vars.css +0 -0
- package/src/listItem/ListItem.vars.less +11 -0
- package/src/listItem/ListItemContext.tsx +2 -1
- package/src/listItem/Navigation/ListItemNavigation.spec.tsx +1 -10
- package/src/listItem/Navigation/ListItemNavigation.story.tsx +0 -22
- package/src/listItem/Navigation/ListItemNavigation.tsx +2 -3
- package/src/listItem/Prompt/InlinePrompt/InlinePrompt.css +153 -0
- package/src/listItem/Prompt/InlinePrompt/InlinePrompt.less +162 -0
- package/src/listItem/Prompt/InlinePrompt/InlinePrompt.spec.tsx +66 -0
- package/src/listItem/Prompt/InlinePrompt/InlinePrompt.tsx +56 -0
- package/src/listItem/Prompt/InlinePrompt/index.ts +2 -0
- package/src/listItem/Prompt/ListItemPrompt.css +72 -72
- package/src/listItem/Prompt/ListItemPrompt.less +2 -130
- package/src/listItem/Prompt/ListItemPrompt.spec.tsx +36 -0
- package/src/listItem/Prompt/ListItemPrompt.story.tsx +4 -2
- package/src/listItem/Prompt/ListItemPrompt.tsx +14 -14
- package/src/listItem/_stories/ListItem.disabled.story.tsx +433 -0
- package/src/listItem/_stories/ListItem.layout.test.story.tsx +10 -155
- package/src/listItem/_stories/ListItem.scenarios.story.tsx +4 -25
- package/src/listItem/_stories/ListItem.story.tsx +17 -187
- package/src/listItem/_stories/helpers.tsx +23 -6
- package/src/listItem/_stories/subcomponents.tsx +19 -2
- package/src/listItem/_stories/variants/ListItem.medium.test.story.tsx +1 -1
- package/src/listItem/_stories/variants/ListItem.neutral.test.story.tsx +55 -0
- package/src/listItem/_stories/variants/ListItem.small.test.story.tsx +1 -1
- package/src/listItem/_stories/variants/helpers.tsx +28 -1
- package/src/listItem/constants.ts +15 -0
- package/src/main.css +122 -81
- package/src/navigationOption/NavigationOption.story.tsx +4 -1
- package/src/navigationOption/NavigationOption.tsx +8 -0
- package/src/navigationOptionsList/NavigationOptionsList.story.tsx +4 -0
- package/src/navigationOptionsList/NavigationOptionsList.tsx +9 -0
- package/src/radioOption/RadioOption.story.tsx +4 -0
- package/src/radioOption/RadioOption.tsx +8 -0
- package/src/summary/Summary.story.tsx +4 -0
- package/src/summary/Summary.tsx +8 -0
- package/src/switchOption/SwitchOption.story.tsx +4 -1
- package/src/switchOption/SwitchOption.tsx +8 -0
- package/src/table/Table.story.tsx +1 -1
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { Title, Subtitle, Description, Stories } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
|
+
import { MultiCurrency, Plus } from '@transferwise/icons';
|
|
4
|
+
import { lorem10, lorem5 } from '../../test-utils';
|
|
5
|
+
import List from '../../list';
|
|
6
|
+
import Link from '../../link';
|
|
7
|
+
import { ListItem, type ListItemProps } from '../ListItem';
|
|
8
|
+
import type { ListItemPromptProps } from '../Prompt';
|
|
9
|
+
import { disableControls, withoutKey } from './helpers';
|
|
10
|
+
import {
|
|
11
|
+
SB_LIST_ITEM_TEXT as TEXT,
|
|
12
|
+
SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
|
|
13
|
+
SB_LIST_ITEM_CONTROLS as CONTROLS,
|
|
14
|
+
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
15
|
+
} from './subcomponents';
|
|
16
|
+
|
|
17
|
+
const hideControls = disableControls([
|
|
18
|
+
'title',
|
|
19
|
+
'subtitle',
|
|
20
|
+
'valueTitle',
|
|
21
|
+
'valueSubtitle',
|
|
22
|
+
'media',
|
|
23
|
+
'additionalInfo',
|
|
24
|
+
'prompt',
|
|
25
|
+
'control',
|
|
26
|
+
'as',
|
|
27
|
+
'inverted',
|
|
28
|
+
'className',
|
|
29
|
+
'id',
|
|
30
|
+
'valueColumnWidth',
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const renderPrompt = (sentiment: ListItemPromptProps['sentiment']) => (
|
|
34
|
+
<ListItem.Prompt sentiment={sentiment}>
|
|
35
|
+
This prompt contains an <Link href="#target">external link</Link> too.
|
|
36
|
+
</ListItem.Prompt>
|
|
37
|
+
);
|
|
38
|
+
const disabledPromptMessage = (
|
|
39
|
+
<>
|
|
40
|
+
This item is disabled because <Link href="#target">some reason</Link> has not been satisfied.
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Please refer to the [design documentation](https://wise.design/components/list-item#accessibility:~:text=-,Disabled%20states,-) for more details
|
|
46
|
+
*/
|
|
47
|
+
export default {
|
|
48
|
+
component: ListItem,
|
|
49
|
+
title: 'Content/ListItem/Disabled State',
|
|
50
|
+
tags: ['autodocs'],
|
|
51
|
+
decorators: [withoutKey],
|
|
52
|
+
argTypes: hideControls(),
|
|
53
|
+
args: {
|
|
54
|
+
disabled: true,
|
|
55
|
+
subtitle: TEXT.subtitle,
|
|
56
|
+
valueTitle: TEXT.valueTitle,
|
|
57
|
+
valueSubtitle: TEXT.valueSubtitle,
|
|
58
|
+
media: MEDIA.avatarFlag,
|
|
59
|
+
},
|
|
60
|
+
parameters: {
|
|
61
|
+
docs: {
|
|
62
|
+
canvas: {
|
|
63
|
+
sourceState: 'hidden',
|
|
64
|
+
},
|
|
65
|
+
toc: true,
|
|
66
|
+
page: () => (
|
|
67
|
+
<>
|
|
68
|
+
<Title>Disabled state</Title>
|
|
69
|
+
<Subtitle />
|
|
70
|
+
<Description />
|
|
71
|
+
<Stories />
|
|
72
|
+
</>
|
|
73
|
+
),
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
} satisfies Meta<ListItemProps>;
|
|
77
|
+
type Story = StoryObj<ListItemProps>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* When dealing with dynamic content, e.g. BFFs or general form submissions, it's a common practice
|
|
81
|
+
* to stop the users from making changes to the inputs while the form is being processed.
|
|
82
|
+
*
|
|
83
|
+
* Because these form states are usually short-lived, and would take at most few seconds to
|
|
84
|
+
* complete, we don't want to introduce any major content changes that could distract
|
|
85
|
+
* the user or, even worse, cause layout shift. That's why, by default, toggling the `disabled`
|
|
86
|
+
* prop will not show any additional visual indicators, apart from the luminosity and opacity
|
|
87
|
+
* changes.
|
|
88
|
+
*/
|
|
89
|
+
export const ShortLived: Story = {
|
|
90
|
+
name: 'Short-lived: fully interactive',
|
|
91
|
+
args: {
|
|
92
|
+
control: CONTROLS.button,
|
|
93
|
+
},
|
|
94
|
+
argTypes: hideControls(['disabledPromptMessage']),
|
|
95
|
+
render: function Render(args) {
|
|
96
|
+
return (
|
|
97
|
+
<List>
|
|
98
|
+
<ListItem {...args} title="No prompt" control={CONTROLS.navigation} />
|
|
99
|
+
<ListItem
|
|
100
|
+
{...args}
|
|
101
|
+
title="Neutral prompt"
|
|
102
|
+
prompt={renderPrompt('neutral')}
|
|
103
|
+
control={CONTROLS.navigation}
|
|
104
|
+
/>
|
|
105
|
+
<ListItem {...args} title="Positive prompt" prompt={renderPrompt('positive')} />
|
|
106
|
+
<ListItem {...args} title="Warning prompt" prompt={renderPrompt('warning')} />
|
|
107
|
+
<ListItem {...args} title="Negative prompt" prompt={renderPrompt('negative')} />
|
|
108
|
+
</List>
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* There's a difference between fully and partially interactive ListItems. While setting `disabled`
|
|
115
|
+
* prop on the former applies the visual treatment to the whole item, on the latter ones it only
|
|
116
|
+
* affects the control element (`ListItem.Button` or `ListItem.IconButton`).
|
|
117
|
+
*
|
|
118
|
+
* That way, the inline link or button in the additional info section remains interactive and
|
|
119
|
+
* accessible.
|
|
120
|
+
*/
|
|
121
|
+
export const ShortLivedPartially: Story = {
|
|
122
|
+
name: 'Short-lived: partially interactive',
|
|
123
|
+
args: {
|
|
124
|
+
additionalInfo: INFO.interactive,
|
|
125
|
+
},
|
|
126
|
+
argTypes: hideControls(['spotlight', 'disabledPromptMessage']),
|
|
127
|
+
render: function Render(args) {
|
|
128
|
+
return (
|
|
129
|
+
<List>
|
|
130
|
+
<ListItem
|
|
131
|
+
{...args}
|
|
132
|
+
title="No prompt and disabled control"
|
|
133
|
+
control={CONTROLS.partialButton}
|
|
134
|
+
/>
|
|
135
|
+
<ListItem
|
|
136
|
+
{...args}
|
|
137
|
+
title="Prompt and disabled Button control"
|
|
138
|
+
prompt={renderPrompt('warning')}
|
|
139
|
+
control={CONTROLS.partialButton}
|
|
140
|
+
/>
|
|
141
|
+
<ListItem
|
|
142
|
+
{...args}
|
|
143
|
+
title="Prompt and disabled IconButton control"
|
|
144
|
+
prompt={renderPrompt('positive')}
|
|
145
|
+
control={CONTROLS.partialIconButton}
|
|
146
|
+
/>
|
|
147
|
+
</List>
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* On the other hand, instances of ListItems that are disabled for longer periods of time and
|
|
154
|
+
* remain in such state until some user interaction or event occur, can and should offer extended
|
|
155
|
+
* affordances to the user, so they are aware of the current state of the item and the reason why
|
|
156
|
+
* it's not available to them.
|
|
157
|
+
*
|
|
158
|
+
* To achieve that, we're introducing additional prop `disabledPromptMessage` – it's a
|
|
159
|
+
* prompt content override only used when ListItem is in the disabled state, and it's expected to
|
|
160
|
+
* offer reasoning for why given list item has been disabled.
|
|
161
|
+
*
|
|
162
|
+
* If set, it will render a variant of the `ListItem.Prompt` component with an icon and colour
|
|
163
|
+
* scheme designed specifically for this scenario.
|
|
164
|
+
*
|
|
165
|
+
* Similarly to the short-lived scenario, fully interactive items will apply the visual treatment
|
|
166
|
+
* to the whole item. Prompts will remain interactive.
|
|
167
|
+
*/
|
|
168
|
+
export const LongLived: Story = {
|
|
169
|
+
name: 'Long-lived: fully interactive',
|
|
170
|
+
args: {
|
|
171
|
+
disabledPromptMessage,
|
|
172
|
+
control: CONTROLS.button,
|
|
173
|
+
},
|
|
174
|
+
argTypes: hideControls(['disabledPromptMessage']),
|
|
175
|
+
render: function Render(args) {
|
|
176
|
+
return (
|
|
177
|
+
<List>
|
|
178
|
+
<ListItem
|
|
179
|
+
{...args}
|
|
180
|
+
title="No prompt, no disabledPromptMessage"
|
|
181
|
+
disabledPromptMessage={undefined}
|
|
182
|
+
control={CONTROLS.navigation}
|
|
183
|
+
/>
|
|
184
|
+
<ListItem
|
|
185
|
+
{...args}
|
|
186
|
+
title="No prompt, disabledPromptMessage set"
|
|
187
|
+
control={CONTROLS.navigation}
|
|
188
|
+
/>
|
|
189
|
+
<ListItem
|
|
190
|
+
{...args}
|
|
191
|
+
title="Neutral prompt, disabledPromptMessage set"
|
|
192
|
+
prompt={renderPrompt('neutral')}
|
|
193
|
+
control={CONTROLS.navigation}
|
|
194
|
+
/>
|
|
195
|
+
<ListItem
|
|
196
|
+
{...args}
|
|
197
|
+
title="Positive prompt, disabledPromptMessage set"
|
|
198
|
+
prompt={renderPrompt('positive')}
|
|
199
|
+
/>
|
|
200
|
+
<ListItem
|
|
201
|
+
{...args}
|
|
202
|
+
title="Warning prompt, disabledPromptMessage set"
|
|
203
|
+
prompt={renderPrompt('warning')}
|
|
204
|
+
/>
|
|
205
|
+
<ListItem
|
|
206
|
+
{...args}
|
|
207
|
+
title="Negative prompt, disabledPromptMessage set"
|
|
208
|
+
prompt={renderPrompt('negative')}
|
|
209
|
+
/>
|
|
210
|
+
</List>
|
|
211
|
+
);
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Similarly to the short-lived scenario, partially interactive items will only apply the visual
|
|
217
|
+
* treatment to the control element, leaving the additional info section fully interactive and
|
|
218
|
+
* accessible.
|
|
219
|
+
*
|
|
220
|
+
* While programmatically not required, you will be expected to use the `disabledPromptMessage`
|
|
221
|
+
* prop to offer an explanation to the user on why the item was disabled.
|
|
222
|
+
*/
|
|
223
|
+
export const LongLivedPartially: Story = {
|
|
224
|
+
name: 'Long-lived: partially interactive',
|
|
225
|
+
args: {
|
|
226
|
+
disabledPromptMessage,
|
|
227
|
+
additionalInfo: INFO.interactive,
|
|
228
|
+
},
|
|
229
|
+
argTypes: hideControls(['spotlight', 'disabledPromptMessage']),
|
|
230
|
+
render: function Render(args) {
|
|
231
|
+
return (
|
|
232
|
+
<List>
|
|
233
|
+
<ListItem
|
|
234
|
+
{...args}
|
|
235
|
+
disabledPromptMessage={undefined}
|
|
236
|
+
title="No prompt, no disabledPromptMessage"
|
|
237
|
+
control={CONTROLS.partialButton}
|
|
238
|
+
/>
|
|
239
|
+
<ListItem
|
|
240
|
+
{...args}
|
|
241
|
+
title="No prompt, disabledPromptMessage set"
|
|
242
|
+
control={CONTROLS.partialButton}
|
|
243
|
+
/>
|
|
244
|
+
<ListItem
|
|
245
|
+
{...args}
|
|
246
|
+
title="Prompt set, disabledPromptMessage set"
|
|
247
|
+
prompt={renderPrompt('warning')}
|
|
248
|
+
control={CONTROLS.partialIconButton}
|
|
249
|
+
/>
|
|
250
|
+
<ListItem
|
|
251
|
+
{...args}
|
|
252
|
+
title="Prompt set, disabledPromptMessage set"
|
|
253
|
+
prompt={renderPrompt('positive')}
|
|
254
|
+
control={CONTROLS.partialIconButton}
|
|
255
|
+
/>
|
|
256
|
+
</List>
|
|
257
|
+
);
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export const AllControls: Story = {
|
|
262
|
+
parameters: {
|
|
263
|
+
docs: {
|
|
264
|
+
canvas: {
|
|
265
|
+
sourceState: 'hidden',
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
controls: { disable: true },
|
|
269
|
+
knobs: { disable: true },
|
|
270
|
+
},
|
|
271
|
+
render: (args) => (
|
|
272
|
+
<List>
|
|
273
|
+
<ListItem
|
|
274
|
+
disabled
|
|
275
|
+
media={
|
|
276
|
+
<ListItem.AvatarView>
|
|
277
|
+
<MultiCurrency />
|
|
278
|
+
</ListItem.AvatarView>
|
|
279
|
+
}
|
|
280
|
+
title="Navigation"
|
|
281
|
+
subtitle={lorem5}
|
|
282
|
+
control={<ListItem.Navigation onClick={() => {}} />}
|
|
283
|
+
/>
|
|
284
|
+
<ListItem
|
|
285
|
+
disabled
|
|
286
|
+
media={
|
|
287
|
+
<ListItem.AvatarView>
|
|
288
|
+
<MultiCurrency />
|
|
289
|
+
</ListItem.AvatarView>
|
|
290
|
+
}
|
|
291
|
+
title="Button primary"
|
|
292
|
+
subtitle={lorem5}
|
|
293
|
+
control={<ListItem.Button priority="primary">Primary</ListItem.Button>}
|
|
294
|
+
/>
|
|
295
|
+
<ListItem
|
|
296
|
+
disabled
|
|
297
|
+
media={
|
|
298
|
+
<ListItem.AvatarView>
|
|
299
|
+
<MultiCurrency />
|
|
300
|
+
</ListItem.AvatarView>
|
|
301
|
+
}
|
|
302
|
+
title="Button secondary neutral"
|
|
303
|
+
subtitle={lorem5}
|
|
304
|
+
control={<ListItem.Button>Secondary</ListItem.Button>}
|
|
305
|
+
/>
|
|
306
|
+
<ListItem
|
|
307
|
+
disabled
|
|
308
|
+
media={
|
|
309
|
+
<ListItem.AvatarView>
|
|
310
|
+
<MultiCurrency />
|
|
311
|
+
</ListItem.AvatarView>
|
|
312
|
+
}
|
|
313
|
+
title="Button secondary neutral"
|
|
314
|
+
subtitle={lorem5}
|
|
315
|
+
control={<ListItem.Button priority="secondary-neutral">Secondary Neutral</ListItem.Button>}
|
|
316
|
+
/>
|
|
317
|
+
<ListItem
|
|
318
|
+
disabled
|
|
319
|
+
media={
|
|
320
|
+
<ListItem.AvatarView>
|
|
321
|
+
<MultiCurrency />
|
|
322
|
+
</ListItem.AvatarView>
|
|
323
|
+
}
|
|
324
|
+
title="Button tertiary"
|
|
325
|
+
subtitle={lorem5}
|
|
326
|
+
control={<ListItem.Button priority="tertiary">Tertiary</ListItem.Button>}
|
|
327
|
+
/>
|
|
328
|
+
<ListItem
|
|
329
|
+
disabled
|
|
330
|
+
media={
|
|
331
|
+
<ListItem.AvatarView>
|
|
332
|
+
<MultiCurrency />
|
|
333
|
+
</ListItem.AvatarView>
|
|
334
|
+
}
|
|
335
|
+
title="Icon Button"
|
|
336
|
+
subtitle={lorem5}
|
|
337
|
+
control={
|
|
338
|
+
<ListItem.IconButton>
|
|
339
|
+
<Plus />
|
|
340
|
+
</ListItem.IconButton>
|
|
341
|
+
}
|
|
342
|
+
/>
|
|
343
|
+
<ListItem
|
|
344
|
+
disabled
|
|
345
|
+
media={
|
|
346
|
+
<ListItem.AvatarView>
|
|
347
|
+
<MultiCurrency />
|
|
348
|
+
</ListItem.AvatarView>
|
|
349
|
+
}
|
|
350
|
+
title="Checkbox"
|
|
351
|
+
subtitle={lorem5}
|
|
352
|
+
control={<ListItem.Checkbox />}
|
|
353
|
+
/>
|
|
354
|
+
<ListItem
|
|
355
|
+
disabled
|
|
356
|
+
media={
|
|
357
|
+
<ListItem.AvatarView>
|
|
358
|
+
<MultiCurrency />
|
|
359
|
+
</ListItem.AvatarView>
|
|
360
|
+
}
|
|
361
|
+
title="Checkbox checked"
|
|
362
|
+
subtitle={lorem5}
|
|
363
|
+
control={<ListItem.Checkbox checked />}
|
|
364
|
+
/>
|
|
365
|
+
<ListItem
|
|
366
|
+
disabled
|
|
367
|
+
media={
|
|
368
|
+
<ListItem.AvatarView>
|
|
369
|
+
<MultiCurrency />
|
|
370
|
+
</ListItem.AvatarView>
|
|
371
|
+
}
|
|
372
|
+
title="Checkbox indeterminate"
|
|
373
|
+
subtitle={lorem5}
|
|
374
|
+
control={<ListItem.Checkbox indeterminate />}
|
|
375
|
+
/>
|
|
376
|
+
<ListItem
|
|
377
|
+
disabled
|
|
378
|
+
media={
|
|
379
|
+
<ListItem.AvatarView>
|
|
380
|
+
<MultiCurrency />
|
|
381
|
+
</ListItem.AvatarView>
|
|
382
|
+
}
|
|
383
|
+
title="Switch on"
|
|
384
|
+
subtitle={lorem5}
|
|
385
|
+
control={<ListItem.Switch checked onClick={() => {}} />}
|
|
386
|
+
/>
|
|
387
|
+
<ListItem
|
|
388
|
+
disabled
|
|
389
|
+
media={
|
|
390
|
+
<ListItem.AvatarView>
|
|
391
|
+
<MultiCurrency />
|
|
392
|
+
</ListItem.AvatarView>
|
|
393
|
+
}
|
|
394
|
+
title="Switch off"
|
|
395
|
+
subtitle={lorem5}
|
|
396
|
+
control={<ListItem.Switch onClick={() => {}} />}
|
|
397
|
+
/>
|
|
398
|
+
<ListItem
|
|
399
|
+
disabled
|
|
400
|
+
media={
|
|
401
|
+
<ListItem.AvatarView>
|
|
402
|
+
<MultiCurrency />
|
|
403
|
+
</ListItem.AvatarView>
|
|
404
|
+
}
|
|
405
|
+
title="Switch off"
|
|
406
|
+
subtitle={lorem5}
|
|
407
|
+
control={<ListItem.Radio name="radio" checked />}
|
|
408
|
+
/>
|
|
409
|
+
<ListItem
|
|
410
|
+
disabled
|
|
411
|
+
media={
|
|
412
|
+
<ListItem.AvatarView>
|
|
413
|
+
<MultiCurrency />
|
|
414
|
+
</ListItem.AvatarView>
|
|
415
|
+
}
|
|
416
|
+
title="Switch off"
|
|
417
|
+
subtitle={lorem5}
|
|
418
|
+
control={<ListItem.Radio name="radios" />}
|
|
419
|
+
/>
|
|
420
|
+
<ListItem
|
|
421
|
+
disabled
|
|
422
|
+
media={
|
|
423
|
+
<ListItem.AvatarView>
|
|
424
|
+
<MultiCurrency />
|
|
425
|
+
</ListItem.AvatarView>
|
|
426
|
+
}
|
|
427
|
+
title="Non-interactive"
|
|
428
|
+
subtitle={lorem10}
|
|
429
|
+
additionalInfo={INFO.nonInteractive}
|
|
430
|
+
/>
|
|
431
|
+
</List>
|
|
432
|
+
),
|
|
433
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Fragment } from 'react';
|
|
2
2
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
|
-
import { Bank, FastFlag, MultiCurrency, Receipt, Savings } from '@transferwise/icons';
|
|
4
|
-
import Link from '../../link';
|
|
5
3
|
import List from '../../list';
|
|
6
4
|
import { ListItem, type ListItemProps } from '../ListItem';
|
|
7
5
|
import { lorem10, lorem20, lorem5 } from '../../test-utils';
|
|
@@ -9,20 +7,8 @@ import portraitImage from '../../test-utils/assets/placeholder-landscape.svg';
|
|
|
9
7
|
import landscapeImage from '../../test-utils/assets/placeholder-portrait.svg';
|
|
10
8
|
import { SB_LIST_ITEM_CONTROLS as CONTROLS, SB_LIST_ITEM_MEDIA as MEDIA } from './subcomponents';
|
|
11
9
|
import { ListItemMediaSize } from '../ListItemContext';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<List
|
|
15
|
-
className="list-unstyled"
|
|
16
|
-
style={{
|
|
17
|
-
width,
|
|
18
|
-
display: 'flex',
|
|
19
|
-
flexDirection: 'column',
|
|
20
|
-
gap: 16,
|
|
21
|
-
}}
|
|
22
|
-
>
|
|
23
|
-
<Story />
|
|
24
|
-
</List>
|
|
25
|
-
);
|
|
10
|
+
import { withSizedContainer } from './helpers';
|
|
11
|
+
import { LISTITEM_CQ } from '../constants';
|
|
26
12
|
|
|
27
13
|
export default {
|
|
28
14
|
title: 'Content/ListItem/tests/layout',
|
|
@@ -36,143 +22,6 @@ export default {
|
|
|
36
22
|
} satisfies Meta<ListItemProps>;
|
|
37
23
|
type Story = StoryObj<ListItemProps>;
|
|
38
24
|
|
|
39
|
-
const variants = [
|
|
40
|
-
<ListItem
|
|
41
|
-
key="button"
|
|
42
|
-
title="Button only"
|
|
43
|
-
control={
|
|
44
|
-
<ListItem.Button priority="secondary-neutral" onClick={() => {}}>
|
|
45
|
-
Click me
|
|
46
|
-
</ListItem.Button>
|
|
47
|
-
}
|
|
48
|
-
/>,
|
|
49
|
-
<ListItem
|
|
50
|
-
key="media"
|
|
51
|
-
title="With media"
|
|
52
|
-
subtitle="Short subtitle"
|
|
53
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem5}</ListItem.AdditionalInfo>}
|
|
54
|
-
media={
|
|
55
|
-
<ListItem.AvatarView>
|
|
56
|
-
<FastFlag />
|
|
57
|
-
</ListItem.AvatarView>
|
|
58
|
-
}
|
|
59
|
-
/>,
|
|
60
|
-
<ListItem key="value" title="With value" valueTitle="100 GBP" valueSubtitle="100 USD" />,
|
|
61
|
-
<ListItem
|
|
62
|
-
key="prompt"
|
|
63
|
-
title="With prompt"
|
|
64
|
-
prompt={
|
|
65
|
-
<ListItem.Prompt sentiment="positive">
|
|
66
|
-
This is a prompt with <Link href="https://wise.com">a link</Link>.
|
|
67
|
-
</ListItem.Prompt>
|
|
68
|
-
}
|
|
69
|
-
/>,
|
|
70
|
-
<ListItem
|
|
71
|
-
key="button-media"
|
|
72
|
-
title="Button + media"
|
|
73
|
-
media={
|
|
74
|
-
<ListItem.AvatarView>
|
|
75
|
-
<MultiCurrency />
|
|
76
|
-
</ListItem.AvatarView>
|
|
77
|
-
}
|
|
78
|
-
control={
|
|
79
|
-
<ListItem.Button priority="primary" onClick={() => {}}>
|
|
80
|
-
Action
|
|
81
|
-
</ListItem.Button>
|
|
82
|
-
}
|
|
83
|
-
/>,
|
|
84
|
-
<ListItem
|
|
85
|
-
key="button-value"
|
|
86
|
-
title="Button + value"
|
|
87
|
-
valueTitle="42 EUR"
|
|
88
|
-
control={
|
|
89
|
-
<ListItem.Button priority="secondary-neutral" onClick={() => {}}>
|
|
90
|
-
Pay
|
|
91
|
-
</ListItem.Button>
|
|
92
|
-
}
|
|
93
|
-
/>,
|
|
94
|
-
<ListItem
|
|
95
|
-
key="media-value"
|
|
96
|
-
valueColumnWidth={80}
|
|
97
|
-
title="Media + value"
|
|
98
|
-
subtitle="this column is 20% wide"
|
|
99
|
-
media={
|
|
100
|
-
<ListItem.AvatarView>
|
|
101
|
-
<Bank />
|
|
102
|
-
</ListItem.AvatarView>
|
|
103
|
-
}
|
|
104
|
-
valueTitle="1,000 USD"
|
|
105
|
-
/>,
|
|
106
|
-
<ListItem
|
|
107
|
-
key="prompt-value"
|
|
108
|
-
title="Prompt + value"
|
|
109
|
-
valueTitle="10 GBP"
|
|
110
|
-
prompt={<ListItem.Prompt sentiment="warning">Warning prompt!</ListItem.Prompt>}
|
|
111
|
-
/>,
|
|
112
|
-
<ListItem
|
|
113
|
-
key="media-prompt"
|
|
114
|
-
title="Media + prompt"
|
|
115
|
-
media={
|
|
116
|
-
<ListItem.AvatarView>
|
|
117
|
-
<Receipt />
|
|
118
|
-
</ListItem.AvatarView>
|
|
119
|
-
}
|
|
120
|
-
prompt={<ListItem.Prompt sentiment="positive">Discount available!</ListItem.Prompt>}
|
|
121
|
-
/>,
|
|
122
|
-
<ListItem
|
|
123
|
-
key="most"
|
|
124
|
-
title="Everything but button"
|
|
125
|
-
subtitle="No control"
|
|
126
|
-
media={
|
|
127
|
-
<ListItem.AvatarView>
|
|
128
|
-
<Savings />
|
|
129
|
-
</ListItem.AvatarView>
|
|
130
|
-
}
|
|
131
|
-
valueTitle="999 GBP"
|
|
132
|
-
prompt={
|
|
133
|
-
<ListItem.Prompt sentiment="positive">
|
|
134
|
-
<Link href="https://wise.com">See details</Link>
|
|
135
|
-
</ListItem.Prompt>
|
|
136
|
-
}
|
|
137
|
-
/>,
|
|
138
|
-
<ListItem
|
|
139
|
-
key="all"
|
|
140
|
-
title="All together"
|
|
141
|
-
subtitle="Everything in one"
|
|
142
|
-
media={
|
|
143
|
-
<ListItem.AvatarView>
|
|
144
|
-
<Savings />
|
|
145
|
-
</ListItem.AvatarView>
|
|
146
|
-
}
|
|
147
|
-
valueTitle="999 GBP"
|
|
148
|
-
prompt={
|
|
149
|
-
<ListItem.Prompt sentiment="positive">
|
|
150
|
-
<Link href="https://wise.com">See details</Link>
|
|
151
|
-
</ListItem.Prompt>
|
|
152
|
-
}
|
|
153
|
-
control={
|
|
154
|
-
<ListItem.Button priority="secondary-neutral" onClick={() => {}}>
|
|
155
|
-
Go
|
|
156
|
-
</ListItem.Button>
|
|
157
|
-
}
|
|
158
|
-
/>,
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
export const Under320: Story = {
|
|
162
|
-
render: () => <>{variants}</>,
|
|
163
|
-
decorators: [withSizedContainer(320)],
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export const Between321And399: Story = {
|
|
167
|
-
render: () => <>{variants}</>,
|
|
168
|
-
decorators: [withSizedContainer(360)],
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
export const Over400: Story = {
|
|
172
|
-
render: () => <>{variants}</>,
|
|
173
|
-
decorators: [withSizedContainer(400)],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
25
|
export const LongButton: Story = {
|
|
177
26
|
render: () => (
|
|
178
27
|
<ListItem
|
|
@@ -190,7 +39,7 @@ export const LongButton: Story = {
|
|
|
190
39
|
}
|
|
191
40
|
/>
|
|
192
41
|
),
|
|
193
|
-
decorators: [withSizedContainer(400)],
|
|
42
|
+
decorators: [withSizedContainer(400, false)],
|
|
194
43
|
};
|
|
195
44
|
|
|
196
45
|
export const GapsBetweenItems: Story = {
|
|
@@ -317,7 +166,13 @@ const ImageAlignmentStory: StoryObj<PreviewStoryArgs> = {
|
|
|
317
166
|
)}
|
|
318
167
|
<List
|
|
319
168
|
className="list-unstyled"
|
|
320
|
-
style={{
|
|
169
|
+
style={{
|
|
170
|
+
display: 'grid',
|
|
171
|
+
gridTemplateColumns: [LISTITEM_CQ.MAX, LISTITEM_CQ.MAX + 10]
|
|
172
|
+
.map((size) => `${size}px`)
|
|
173
|
+
.join(' '),
|
|
174
|
+
gap: '16px',
|
|
175
|
+
}}
|
|
321
176
|
>
|
|
322
177
|
<Story />
|
|
323
178
|
</List>
|
|
@@ -235,23 +235,16 @@ export const CopyAndPasteWithSnackbar: Story = storySourceWithoutNoise({
|
|
|
235
235
|
},
|
|
236
236
|
});
|
|
237
237
|
|
|
238
|
-
export const Summary: Story = {
|
|
238
|
+
export const Summary: Story = storySourceWithoutNoise({
|
|
239
239
|
parameters: {
|
|
240
240
|
docs: {
|
|
241
241
|
canvas: {
|
|
242
242
|
sourceState: 'shown',
|
|
243
243
|
},
|
|
244
244
|
},
|
|
245
|
-
backgrounds: {
|
|
246
|
-
default: 'light',
|
|
247
|
-
values: [
|
|
248
|
-
{ name: 'light', value: '#f8f9fa' },
|
|
249
|
-
{ name: 'dark', value: '#343a40' },
|
|
250
|
-
],
|
|
251
|
-
},
|
|
252
245
|
},
|
|
253
|
-
render: ()
|
|
254
|
-
|
|
246
|
+
render: function Summary() {
|
|
247
|
+
return (
|
|
255
248
|
<List>
|
|
256
249
|
<ListItem
|
|
257
250
|
title="System maintenance"
|
|
@@ -327,19 +320,5 @@ export const Summary: Story = {
|
|
|
327
320
|
/>
|
|
328
321
|
</List>
|
|
329
322
|
);
|
|
330
|
-
return (
|
|
331
|
-
<>
|
|
332
|
-
<div style={{ padding: '24px', width: '450px' }}>{listItems}</div>
|
|
333
|
-
<div
|
|
334
|
-
style={{
|
|
335
|
-
padding: '24px',
|
|
336
|
-
width: '450px',
|
|
337
|
-
backgroundColor: 'var(--color-background-neutral)',
|
|
338
|
-
}}
|
|
339
|
-
>
|
|
340
|
-
{listItems}
|
|
341
|
-
</div>
|
|
342
|
-
</>
|
|
343
|
-
);
|
|
344
323
|
},
|
|
345
|
-
};
|
|
324
|
+
});
|