@transferwise/components 0.0.0-experimental-15914a5 → 0.0.0-experimental-e1870f3
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/flowNavigation/animatedLabel/AnimatedLabel.js +2 -2
- package/build/flowNavigation/animatedLabel/AnimatedLabel.js.map +1 -1
- package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs +2 -2
- package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs.map +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +0 -2
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -1
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +0 -2
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -1
- package/build/listItem/AvatarView/ListItemAvatarView.js +0 -2
- package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -1
- package/build/listItem/AvatarView/ListItemAvatarView.mjs +0 -2
- package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -1
- package/build/listItem/Image/ListItemImage.js +1 -3
- package/build/listItem/Image/ListItemImage.js.map +1 -1
- package/build/listItem/Image/ListItemImage.mjs +1 -3
- package/build/listItem/Image/ListItemImage.mjs.map +1 -1
- package/build/{legacylistItem → listItem}/List.js +3 -2
- package/build/listItem/List.js.map +1 -0
- package/build/{legacylistItem → listItem}/List.mjs +3 -2
- package/build/listItem/List.mjs.map +1 -0
- package/build/listItem/ListItem.js +14 -16
- package/build/listItem/ListItem.js.map +1 -1
- package/build/listItem/ListItem.mjs +14 -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 -1
- package/build/listItem/Navigation/ListItemNavigation.js.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.mjs +1 -1
- package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -1
- package/build/main.css +99 -51
- package/build/styles/avatarView/AvatarView.css +3 -1
- package/build/styles/listItem/ListItem.css +96 -50
- package/build/styles/listItem/ListItem.grid.css +9 -15
- package/build/styles/main.css +99 -51
- package/build/types/index.d.ts +4 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/legacylistItem/index.d.ts +0 -2
- package/build/types/legacylistItem/index.d.ts.map +1 -1
- package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -1
- package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -1
- package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -1
- package/build/types/listItem/List.d.ts +7 -0
- package/build/types/listItem/List.d.ts.map +1 -0
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/listItem/ListItemContext.d.ts +0 -4
- package/build/types/listItem/ListItemContext.d.ts.map +1 -1
- package/build/types/listItem/index.d.ts +2 -0
- package/build/types/listItem/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/avatarView/AvatarView.css +3 -1
- package/src/avatarView/AvatarView.less +2 -1
- package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +1 -1
- package/src/index.ts +9 -4
- package/src/legacylistItem/LegacyListItem.story.tsx +2 -2
- package/src/legacylistItem/LegacyListItem.tests.story.tsx +2 -1
- package/src/legacylistItem/index.ts +0 -2
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +5 -4
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +0 -3
- package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +5 -4
- package/src/listItem/AvatarView/ListItemAvatarView.tsx +0 -3
- package/src/listItem/Button/ListItemButton.spec.tsx +35 -10
- package/src/listItem/Button/ListItemButton.story.tsx +9 -8
- package/src/listItem/IconButton/ListItemIconButton.story.tsx +8 -8
- package/src/listItem/Image/ListItemImage.spec.tsx +5 -8
- package/src/listItem/Image/ListItemImage.story.tsx +6 -23
- package/src/listItem/Image/ListItemImage.tsx +1 -4
- package/src/listItem/List.tsx +11 -0
- package/src/listItem/ListItem.css +96 -50
- package/src/listItem/ListItem.grid.css +9 -15
- package/src/listItem/ListItem.grid.less +14 -22
- package/src/listItem/ListItem.less +111 -46
- package/src/listItem/ListItem.tsx +18 -24
- package/src/listItem/ListItemContext.tsx +0 -5
- package/src/listItem/Navigation/ListItemNavigation.tsx +1 -1
- package/src/listItem/Prompt/ListItemPrompt.story.tsx +7 -7
- package/src/listItem/Switch/ListItemSwitch.story.tsx +3 -2
- package/src/listItem/_stories/ListItem.scenarios.story.tsx +226 -0
- package/src/listItem/_stories/ListItem.story.tsx +45 -7
- package/src/listItem/_stories/ListItem.variants.test.story.tsx +7 -11
- package/src/listItem/index.ts +3 -0
- package/src/main.css +99 -51
- package/build/legacylistItem/List.js.map +0 -1
- package/build/legacylistItem/List.mjs.map +0 -1
- package/build/listItem/useListItemMedia.js +0 -21
- package/build/listItem/useListItemMedia.js.map +0 -1
- package/build/listItem/useListItemMedia.mjs +0 -19
- package/build/listItem/useListItemMedia.mjs.map +0 -1
- package/build/types/legacylistItem/List.d.ts +0 -6
- package/build/types/legacylistItem/List.d.ts.map +0 -1
- package/build/types/listItem/test-utils.d.ts +0 -7
- package/build/types/listItem/test-utils.d.ts.map +0 -1
- package/build/types/listItem/useListItemMedia.d.ts +0 -6
- package/build/types/listItem/useListItemMedia.d.ts.map +0 -1
- package/src/legacylistItem/List.tsx +0 -10
- package/src/listItem/test-utils.tsx +0 -33
- package/src/listItem/useListItemMedia.tsx +0 -13
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import AvatarLayoutComp, { type AvatarLayoutProps } from '../../avatarLayout';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import { useListItemMedia } from '../useListItemMedia';
|
|
4
3
|
|
|
5
4
|
type SizeProp = { size?: 32 | 40 | 48 | 56 | 72 };
|
|
6
5
|
|
|
@@ -14,8 +13,6 @@ export type ListItemAvatarLayoutProps = Omit<AvatarLayoutProps, 'size' | 'intera
|
|
|
14
13
|
* Please refer to the [Design documentation](https://wise.design/components/list-item#avatar) for details.
|
|
15
14
|
*/
|
|
16
15
|
export const AvatarLayout = ({ className, size = 48, ...props }: ListItemAvatarLayoutProps) => {
|
|
17
|
-
useListItemMedia(size);
|
|
18
|
-
|
|
19
16
|
return (
|
|
20
17
|
<AvatarLayoutComp
|
|
21
18
|
{...props}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { ListItemAvatarViewProps } from './ListItemAvatarView';
|
|
9
9
|
import { lorem10 } from '../../test-utils';
|
|
10
10
|
import { ProfileType } from '../../common';
|
|
11
|
+
import { List } from '../List';
|
|
11
12
|
|
|
12
13
|
const SIZES = [32, 40, 48, 56, 72] as const;
|
|
13
14
|
const BADGES = {
|
|
@@ -212,7 +213,7 @@ export const Sizes: Story = {
|
|
|
212
213
|
},
|
|
213
214
|
render: (args) => {
|
|
214
215
|
return (
|
|
215
|
-
<
|
|
216
|
+
<List as="ol">
|
|
216
217
|
{SIZES.map((size) => (
|
|
217
218
|
<ListItem
|
|
218
219
|
key={size}
|
|
@@ -226,7 +227,7 @@ export const Sizes: Story = {
|
|
|
226
227
|
control={CONTROLS.iconButton}
|
|
227
228
|
/>
|
|
228
229
|
))}
|
|
229
|
-
</
|
|
230
|
+
</List>
|
|
230
231
|
);
|
|
231
232
|
},
|
|
232
233
|
};
|
|
@@ -248,7 +249,7 @@ export const Notification: Story = {
|
|
|
248
249
|
},
|
|
249
250
|
render: (args) => {
|
|
250
251
|
return (
|
|
251
|
-
<
|
|
252
|
+
<List as="ol">
|
|
252
253
|
{SIZES.map((size) => (
|
|
253
254
|
<ListItem
|
|
254
255
|
key={size}
|
|
@@ -262,7 +263,7 @@ export const Notification: Story = {
|
|
|
262
263
|
control={CONTROLS.iconButton}
|
|
263
264
|
/>
|
|
264
265
|
))}
|
|
265
|
-
</
|
|
266
|
+
</List>
|
|
266
267
|
);
|
|
267
268
|
},
|
|
268
269
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import AvatarViewComp, { AvatarViewProps } from '../../avatarView';
|
|
3
|
-
import { useListItemMedia } from '../useListItemMedia';
|
|
4
3
|
|
|
5
4
|
export type ListItemAvatarViewProps = Omit<AvatarViewProps, 'size' | 'interactive'> & {
|
|
6
5
|
size?: 32 | 40 | 48 | 56 | 72;
|
|
@@ -14,8 +13,6 @@ export type ListItemAvatarViewProps = Omit<AvatarViewProps, 'size' | 'interactiv
|
|
|
14
13
|
* Please refer to the [Design documentation](https://wise.design/components/list-item#avatar) for details.
|
|
15
14
|
*/
|
|
16
15
|
export const AvatarView = ({ className, size = 48, ...props }: ListItemAvatarViewProps) => {
|
|
17
|
-
useListItemMedia(size);
|
|
18
|
-
|
|
19
16
|
return (
|
|
20
17
|
<AvatarViewComp
|
|
21
18
|
{...props}
|
|
@@ -1,24 +1,49 @@
|
|
|
1
|
-
import { screen, mockMatchMedia } from '../../test-utils';
|
|
1
|
+
import { render, screen, mockMatchMedia } from '../../test-utils';
|
|
2
2
|
import { Button as ItemButton } from './ListItemButton';
|
|
3
3
|
import { ButtonPriority } from '../../button/Button.types';
|
|
4
|
-
import {
|
|
4
|
+
import { ListItemContext } from '../ListItemContext';
|
|
5
5
|
|
|
6
6
|
mockMatchMedia();
|
|
7
7
|
|
|
8
8
|
describe('ItemButton', () => {
|
|
9
|
+
const mockSetControlType = jest.fn();
|
|
10
|
+
const mockSetControlProps = jest.fn();
|
|
11
|
+
|
|
12
|
+
const renderWithItemContext = (ui: React.ReactNode) => {
|
|
13
|
+
return render(
|
|
14
|
+
<ListItemContext.Provider
|
|
15
|
+
value={{
|
|
16
|
+
setControlType: mockSetControlType,
|
|
17
|
+
setControlProps: mockSetControlProps,
|
|
18
|
+
ids: {
|
|
19
|
+
title: 'title',
|
|
20
|
+
additionalInfo: 'additional Info',
|
|
21
|
+
valueTitle: 'value title',
|
|
22
|
+
control: 'control',
|
|
23
|
+
prompt: 'prompt',
|
|
24
|
+
},
|
|
25
|
+
props: {},
|
|
26
|
+
describedByIds: 'described-by-ids',
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
{ui}
|
|
30
|
+
</ListItemContext.Provider>,
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
9
34
|
beforeEach(() => {
|
|
10
|
-
|
|
35
|
+
jest.clearAllMocks();
|
|
11
36
|
});
|
|
12
37
|
|
|
13
38
|
it('always sets v2 to true', () => {
|
|
14
|
-
|
|
39
|
+
renderWithItemContext(<ItemButton priority="primary">Test Button</ItemButton>);
|
|
15
40
|
const button = screen.getByRole('button');
|
|
16
41
|
expect(button).toBeInTheDocument();
|
|
17
42
|
expect(mockSetControlType).toHaveBeenCalledWith('button');
|
|
18
43
|
});
|
|
19
44
|
|
|
20
45
|
it('always sets size to "sm"', () => {
|
|
21
|
-
|
|
46
|
+
renderWithItemContext(<ItemButton priority="primary">Test Button</ItemButton>);
|
|
22
47
|
const button = screen.getByRole('button');
|
|
23
48
|
expect(button).toHaveClass('wds-Button--small');
|
|
24
49
|
});
|
|
@@ -26,21 +51,21 @@ describe('ItemButton', () => {
|
|
|
26
51
|
it('supports all priorities', () => {
|
|
27
52
|
const priorities: ButtonPriority[] = ['primary', 'secondary', 'tertiary'];
|
|
28
53
|
priorities.forEach((priority) => {
|
|
29
|
-
|
|
54
|
+
renderWithItemContext(<ItemButton priority={priority}>Test {priority}</ItemButton>);
|
|
30
55
|
const button = screen.getByRole('button', { name: `Test ${priority}` });
|
|
31
56
|
expect(button).toBeInTheDocument();
|
|
32
57
|
});
|
|
33
58
|
});
|
|
34
59
|
|
|
35
60
|
it('renders as a button by default', () => {
|
|
36
|
-
|
|
61
|
+
renderWithItemContext(<ItemButton>Click me</ItemButton>);
|
|
37
62
|
const button = screen.getByRole('button');
|
|
38
63
|
expect(button).toBeInTheDocument();
|
|
39
64
|
expect(button.tagName).toBe('BUTTON');
|
|
40
65
|
});
|
|
41
66
|
|
|
42
67
|
it('renders as an anchor when href is provided', () => {
|
|
43
|
-
|
|
68
|
+
renderWithItemContext(<ItemButton href="https://example.com">Go to Example</ItemButton>);
|
|
44
69
|
const link = screen.getByRole('link', { name: 'Go to Example' });
|
|
45
70
|
expect(link).toBeInTheDocument();
|
|
46
71
|
expect(link.tagName).toBe('A');
|
|
@@ -48,14 +73,14 @@ describe('ItemButton', () => {
|
|
|
48
73
|
});
|
|
49
74
|
|
|
50
75
|
it('spreads additional props to the button', () => {
|
|
51
|
-
|
|
76
|
+
renderWithItemContext(<ItemButton aria-label="Custom Button">Custom</ItemButton>);
|
|
52
77
|
const button = screen.getByRole('button', { name: 'Custom Button' });
|
|
53
78
|
expect(button).toBeInTheDocument();
|
|
54
79
|
expect(button).toHaveAttribute('aria-label', 'Custom Button');
|
|
55
80
|
});
|
|
56
81
|
|
|
57
82
|
it('spreads additional props to the anchor', () => {
|
|
58
|
-
|
|
83
|
+
renderWithItemContext(
|
|
59
84
|
<ItemButton href="https://example.com" target="_blank" aria-label="Custom Link">
|
|
60
85
|
Custom Link
|
|
61
86
|
</ItemButton>,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
8
8
|
} from '../_stories/subcomponents';
|
|
9
9
|
import type { ListItemButtonProps } from './ListItemButton';
|
|
10
|
+
import { List } from '../List';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Convenience controls for previewing rich markup,
|
|
@@ -181,7 +182,7 @@ export const Interactivity: Story = {
|
|
|
181
182
|
},
|
|
182
183
|
render: (args: ListItemButtonProps) => {
|
|
183
184
|
return (
|
|
184
|
-
<
|
|
185
|
+
<List as="ol">
|
|
185
186
|
<ListItem
|
|
186
187
|
title="Fully interactive ListItem"
|
|
187
188
|
subtitle="Button in fully interactive context"
|
|
@@ -195,7 +196,7 @@ export const Interactivity: Story = {
|
|
|
195
196
|
media={MEDIA.avatarSingle}
|
|
196
197
|
control={<ListItem.Button {...args} partiallyInteractive />}
|
|
197
198
|
/>
|
|
198
|
-
</
|
|
199
|
+
</List>
|
|
199
200
|
);
|
|
200
201
|
},
|
|
201
202
|
};
|
|
@@ -230,7 +231,7 @@ export const AsAnchor: Story = {
|
|
|
230
231
|
export const Sentiment: Story = {
|
|
231
232
|
render: (args: ListItemButtonProps) => {
|
|
232
233
|
return (
|
|
233
|
-
<
|
|
234
|
+
<List as="ol">
|
|
234
235
|
<ListItem
|
|
235
236
|
title="Default Sentiment - Primary"
|
|
236
237
|
subtitle="Default sentiment with primary priority"
|
|
@@ -271,7 +272,7 @@ export const Sentiment: Story = {
|
|
|
271
272
|
</ListItem.Button>
|
|
272
273
|
}
|
|
273
274
|
/>
|
|
274
|
-
</
|
|
275
|
+
</List>
|
|
275
276
|
);
|
|
276
277
|
},
|
|
277
278
|
args: {
|
|
@@ -287,7 +288,7 @@ export const Sentiment: Story = {
|
|
|
287
288
|
export const Priority: Story = {
|
|
288
289
|
render: (args: ListItemButtonProps) => {
|
|
289
290
|
return (
|
|
290
|
-
<
|
|
291
|
+
<List as="ol">
|
|
291
292
|
<ListItem
|
|
292
293
|
title="Primary Priority"
|
|
293
294
|
subtitle="Primary priority (default)"
|
|
@@ -328,7 +329,7 @@ export const Priority: Story = {
|
|
|
328
329
|
</ListItem.Button>
|
|
329
330
|
}
|
|
330
331
|
/>
|
|
331
|
-
</
|
|
332
|
+
</List>
|
|
332
333
|
);
|
|
333
334
|
},
|
|
334
335
|
args: {
|
|
@@ -368,7 +369,7 @@ const addonProps = {
|
|
|
368
369
|
export const WithIcons: Story = {
|
|
369
370
|
render: (args: ListItemButtonProps) => {
|
|
370
371
|
return (
|
|
371
|
-
<
|
|
372
|
+
<List as="ol">
|
|
372
373
|
<ListItem
|
|
373
374
|
title="With Start Icon"
|
|
374
375
|
subtitle="Button with icon before the label"
|
|
@@ -399,7 +400,7 @@ export const WithIcons: Story = {
|
|
|
399
400
|
</ListItem.Button>
|
|
400
401
|
}
|
|
401
402
|
/>
|
|
402
|
-
</
|
|
403
|
+
</List>
|
|
403
404
|
);
|
|
404
405
|
},
|
|
405
406
|
args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import ListItem, { List } from '..';
|
|
3
|
+
import { Edit } from '@transferwise/icons';
|
|
4
4
|
import {
|
|
5
5
|
SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
|
|
6
6
|
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
@@ -114,7 +114,7 @@ export const Interactivity: Story = {
|
|
|
114
114
|
},
|
|
115
115
|
render: (args: ListItemIconButtonProps) => {
|
|
116
116
|
return (
|
|
117
|
-
<
|
|
117
|
+
<List as="ol">
|
|
118
118
|
<ListItem
|
|
119
119
|
control={<ListItem.IconButton {...args} />}
|
|
120
120
|
title="Fully interactive ListItem"
|
|
@@ -132,7 +132,7 @@ export const Interactivity: Story = {
|
|
|
132
132
|
additionalInfo={INFO.interactive}
|
|
133
133
|
prompt={PROMPTS.interactive}
|
|
134
134
|
/>
|
|
135
|
-
</
|
|
135
|
+
</List>
|
|
136
136
|
);
|
|
137
137
|
},
|
|
138
138
|
};
|
|
@@ -145,7 +145,7 @@ export const Interactivity: Story = {
|
|
|
145
145
|
export const Sentiment: Story = {
|
|
146
146
|
render: (args) => {
|
|
147
147
|
return (
|
|
148
|
-
<
|
|
148
|
+
<List as="ol">
|
|
149
149
|
<ListItem
|
|
150
150
|
control={<ListItem.IconButton {...args} priority="primary" type="default" />}
|
|
151
151
|
title="Default Sentiment - Primary"
|
|
@@ -170,7 +170,7 @@ export const Sentiment: Story = {
|
|
|
170
170
|
subtitle="Negative sentiment with secondary priority"
|
|
171
171
|
media={MEDIA.avatarSingle}
|
|
172
172
|
/>
|
|
173
|
-
</
|
|
173
|
+
</List>
|
|
174
174
|
);
|
|
175
175
|
},
|
|
176
176
|
};
|
|
@@ -183,7 +183,7 @@ export const Sentiment: Story = {
|
|
|
183
183
|
export const Priority: Story = {
|
|
184
184
|
render: (args) => {
|
|
185
185
|
return (
|
|
186
|
-
<
|
|
186
|
+
<List as="ol">
|
|
187
187
|
<ListItem
|
|
188
188
|
title="Primary Priority"
|
|
189
189
|
subtitle="Primary priority (default)"
|
|
@@ -208,7 +208,7 @@ export const Priority: Story = {
|
|
|
208
208
|
media={MEDIA.avatarSingle}
|
|
209
209
|
control={<ListItem.IconButton {...args} priority="minimal" />}
|
|
210
210
|
/>
|
|
211
|
-
</
|
|
211
|
+
</List>
|
|
212
212
|
);
|
|
213
213
|
},
|
|
214
214
|
};
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { render, screen } from '../../test-utils';
|
|
2
|
-
import { ListItem
|
|
3
|
-
|
|
4
|
-
const renderWithMedia = (media: ListItemProps['media']) =>
|
|
5
|
-
render(<ListItem title="Test Title" media={media} />);
|
|
2
|
+
import { ListItem } from '../ListItem';
|
|
6
3
|
|
|
7
4
|
describe('ListItem.Image', () => {
|
|
8
5
|
it('renders image with presentation role when no alt text', () => {
|
|
9
|
-
|
|
6
|
+
render(<ListItem.Image src="test-image.jpg" />);
|
|
10
7
|
expect(screen.getByRole('presentation')).toHaveAttribute('src', 'test-image.jpg');
|
|
11
8
|
});
|
|
12
9
|
|
|
13
10
|
it('renders image with graphics-symbol role when alt text provided', () => {
|
|
14
|
-
|
|
11
|
+
render(<ListItem.Image src="test-image.jpg" alt="Test image description" />);
|
|
15
12
|
|
|
16
13
|
const image = screen.getByRole('graphics-symbol');
|
|
17
14
|
expect(image).toHaveAttribute('alt', 'Test image description');
|
|
@@ -19,12 +16,12 @@ describe('ListItem.Image', () => {
|
|
|
19
16
|
});
|
|
20
17
|
|
|
21
18
|
it('renders image with loading prop', () => {
|
|
22
|
-
|
|
19
|
+
render(<ListItem.Image src="test-image.jpg" loading="lazy" />);
|
|
23
20
|
expect(screen.getByRole('presentation')).toHaveAttribute('loading', 'lazy');
|
|
24
21
|
});
|
|
25
22
|
|
|
26
23
|
it('renders image with className prop', () => {
|
|
27
|
-
|
|
24
|
+
render(<ListItem.Image src="test-image.jpg" className="custom-image-class" />);
|
|
28
25
|
expect(screen.getByRole('presentation')).toHaveClass('custom-image-class');
|
|
29
26
|
});
|
|
30
27
|
});
|
|
@@ -6,12 +6,6 @@ import {
|
|
|
6
6
|
} from '../_stories/subcomponents';
|
|
7
7
|
import { ListItemImageProps } from './ListItemImage';
|
|
8
8
|
|
|
9
|
-
const IMAGE_URLS = {
|
|
10
|
-
portrait: 'https://cdn-icons-png.flaticon.com/512/656/656404.png',
|
|
11
|
-
landscape:
|
|
12
|
-
'https://wise.com/public-resources/assets/spend/card-asset/medium/v2/personal_green_wise_2023_active.svg',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
9
|
export default {
|
|
16
10
|
component: ListItem.Image,
|
|
17
11
|
title: 'Content/ListItem/ListItem.Image',
|
|
@@ -21,33 +15,22 @@ export default {
|
|
|
21
15
|
},
|
|
22
16
|
},
|
|
23
17
|
args: {
|
|
24
|
-
src:
|
|
25
|
-
size:
|
|
18
|
+
src: 'https://wise.com/public-resources/assets/spend/card-asset/medium/v2/personal_green_wise_2023_active.svg',
|
|
19
|
+
size: undefined,
|
|
26
20
|
loading: undefined,
|
|
27
21
|
alt: undefined,
|
|
28
|
-
imageOrientation: 'landscape' as keyof typeof IMAGE_URLS,
|
|
29
22
|
},
|
|
30
|
-
|
|
31
|
-
imageOrientation: {
|
|
32
|
-
control: { type: 'radio' },
|
|
33
|
-
options: ['portrait', 'landscape'],
|
|
34
|
-
description: 'Switch between portrait and landscape images',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
} satisfies Meta<ListItemImageProps & { imageOrientation: keyof typeof IMAGE_URLS }>;
|
|
23
|
+
} satisfies Meta<ListItemImageProps>;
|
|
38
24
|
|
|
39
|
-
type Story = StoryObj<ListItemImageProps
|
|
25
|
+
type Story = StoryObj<ListItemImageProps>;
|
|
40
26
|
|
|
41
27
|
export const Playground: Story = {
|
|
42
|
-
render: (args: ListItemImageProps
|
|
43
|
-
const { imageOrientation, ...imageProps } = args;
|
|
44
|
-
const src = IMAGE_URLS[imageOrientation];
|
|
45
|
-
|
|
28
|
+
render: (args: ListItemImageProps) => {
|
|
46
29
|
return (
|
|
47
30
|
<ListItem
|
|
48
31
|
title="List item title"
|
|
49
32
|
subtitle="Subtitle goes here"
|
|
50
|
-
media={<ListItem.Image {...
|
|
33
|
+
media={<ListItem.Image {...args} />}
|
|
51
34
|
control={CONTROLS.partialButton}
|
|
52
35
|
additionalInfo={INFO.nonInteractive}
|
|
53
36
|
/>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import ImageComp, { type ImageProps } from '../../image';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import { useListItemMedia } from '../useListItemMedia';
|
|
4
3
|
|
|
5
4
|
type SizeProp = {};
|
|
6
5
|
|
|
@@ -25,14 +24,12 @@ export type ListItemImageProps = Omit<ImageProps, 'stretch' | 'shrink' | 'id' |
|
|
|
25
24
|
* > **NB**: This component is [not intended for use with illustrations](https://wise.design/foundations/illustration#scale).
|
|
26
25
|
*/
|
|
27
26
|
export const Image = ({ alt = '', size = 48, ...props }: ListItemImageProps) => {
|
|
28
|
-
useListItemMedia(size);
|
|
29
|
-
|
|
30
27
|
return (
|
|
31
28
|
<div
|
|
32
29
|
className={clsx('wds-list-item-media-image')}
|
|
33
30
|
style={
|
|
34
31
|
{
|
|
35
|
-
'--
|
|
32
|
+
'--item-media-image-size': `${size}px`,
|
|
36
33
|
} as React.CSSProperties
|
|
37
34
|
}
|
|
38
35
|
>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
|
|
3
|
+
export interface ListProps {
|
|
4
|
+
as?: 'ul' | 'ol' | 'div';
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function List({ as: Element = 'ul', className, children }: ListProps) {
|
|
10
|
+
return <Element className={clsx('wds-list', 'list-unstyled', className)}>{children}</Element>;
|
|
11
|
+
}
|