@transferwise/components 0.0.0-experimental-2242f8a → 0.0.0-experimental-5759f4d
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/button/Button.js +1 -0
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +1 -0
- package/build/button/Button.mjs.map +1 -1
- package/build/common/RadioButton/RadioButton.js +5 -2
- package/build/common/RadioButton/RadioButton.js.map +1 -1
- package/build/common/RadioButton/RadioButton.mjs +5 -2
- package/build/common/RadioButton/RadioButton.mjs.map +1 -1
- package/build/i18n/en.json +2 -0
- package/build/i18n/en.json.js +2 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +2 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/iconButton/IconButton.js.map +1 -1
- package/build/iconButton/IconButton.mjs.map +1 -1
- package/build/image/Image.js.map +1 -1
- package/build/image/Image.mjs.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +56 -0
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js.map +1 -0
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +54 -0
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs.map +1 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +21 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +19 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -0
- package/build/listItem/AvatarView/ListItemAvatarView.js +21 -0
- package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -0
- package/build/listItem/AvatarView/ListItemAvatarView.mjs +19 -0
- package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -0
- package/build/listItem/Button/ListItemButton.js +43 -0
- package/build/listItem/Button/ListItemButton.js.map +1 -0
- package/build/listItem/Button/ListItemButton.mjs +41 -0
- package/build/listItem/Button/ListItemButton.mjs.map +1 -0
- package/build/listItem/Checkbox/ListItemCheckbox.js +30 -0
- package/build/listItem/Checkbox/ListItemCheckbox.js.map +1 -0
- package/build/listItem/Checkbox/ListItemCheckbox.mjs +28 -0
- package/build/listItem/Checkbox/ListItemCheckbox.mjs.map +1 -0
- package/build/listItem/IconButton/ListItemIconButton.js +42 -0
- package/build/listItem/IconButton/ListItemIconButton.js.map +1 -0
- package/build/listItem/IconButton/ListItemIconButton.mjs +40 -0
- package/build/listItem/IconButton/ListItemIconButton.mjs.map +1 -0
- package/build/listItem/Image/ListItemImage.js +27 -0
- package/build/listItem/Image/ListItemImage.js.map +1 -0
- package/build/listItem/Image/ListItemImage.mjs +25 -0
- package/build/listItem/Image/ListItemImage.mjs.map +1 -0
- package/build/listItem/ListItem.js +302 -0
- package/build/listItem/ListItem.js.map +1 -0
- package/build/listItem/ListItem.mjs +297 -0
- package/build/listItem/ListItem.mjs.map +1 -0
- package/build/listItem/ListItemContext.js +8 -0
- package/build/listItem/ListItemContext.js.map +1 -0
- package/build/listItem/ListItemContext.mjs +6 -0
- package/build/listItem/ListItemContext.mjs.map +1 -0
- package/build/listItem/Navigation/ListItemNavigation.js +45 -0
- package/build/listItem/Navigation/ListItemNavigation.js.map +1 -0
- package/build/listItem/Navigation/ListItemNavigation.mjs +43 -0
- package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -0
- package/build/listItem/Prompt/ListItemPrompt.js +59 -0
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -0
- package/build/listItem/Prompt/ListItemPrompt.mjs +54 -0
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -0
- package/build/listItem/Radio/ListItemRadio.js +30 -0
- package/build/listItem/Radio/ListItemRadio.js.map +1 -0
- package/build/listItem/Radio/ListItemRadio.mjs +28 -0
- package/build/listItem/Radio/ListItemRadio.mjs.map +1 -0
- package/build/listItem/Switch/ListItemSwitch.js +30 -0
- package/build/listItem/Switch/ListItemSwitch.js.map +1 -0
- package/build/listItem/Switch/ListItemSwitch.mjs +28 -0
- package/build/listItem/Switch/ListItemSwitch.mjs.map +1 -0
- package/build/listItem/useListItemControl.js +22 -0
- package/build/listItem/useListItemControl.js.map +1 -0
- package/build/listItem/useListItemControl.mjs +20 -0
- package/build/listItem/useListItemControl.mjs.map +1 -0
- package/build/main.css +657 -0
- package/build/styles/listItem/ListItem.css +657 -0
- package/build/styles/listItem/ListItem.grid.css +362 -0
- package/build/styles/main.css +657 -0
- package/build/switch/Switch.js +2 -0
- package/build/switch/Switch.js.map +1 -1
- package/build/switch/Switch.mjs +2 -0
- package/build/switch/Switch.mjs.map +1 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.types.d.ts +1 -1
- package/build/types/button/Button.types.d.ts.map +1 -1
- package/build/types/button/index.d.ts +1 -1
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/common/RadioButton/RadioButton.d.ts +3 -1
- package/build/types/common/RadioButton/RadioButton.d.ts.map +1 -1
- package/build/types/iconButton/IconButton.d.ts +2 -2
- package/build/types/iconButton/IconButton.d.ts.map +1 -1
- package/build/types/image/Image.d.ts +3 -0
- package/build/types/image/Image.d.ts.map +1 -1
- package/build/types/image/index.d.ts +1 -0
- package/build/types/image/index.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts +15 -0
- package/build/types/listItem/AdditionalInfo/ListItemAdditionalInfo.d.ts.map +1 -0
- package/build/types/listItem/AdditionalInfo/index.d.ts +3 -0
- package/build/types/listItem/AdditionalInfo/index.d.ts.map +1 -0
- package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts +18 -0
- package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -0
- package/build/types/listItem/AvatarLayout/index.d.ts +3 -0
- package/build/types/listItem/AvatarLayout/index.d.ts.map +1 -0
- package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts +16 -0
- package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -0
- package/build/types/listItem/AvatarView/index.d.ts +3 -0
- package/build/types/listItem/AvatarView/index.d.ts.map +1 -0
- package/build/types/listItem/Button/ListItemButton.d.ts +20 -0
- package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -0
- package/build/types/listItem/Button/index.d.ts +3 -0
- package/build/types/listItem/Button/index.d.ts.map +1 -0
- package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts +14 -0
- package/build/types/listItem/Checkbox/ListItemCheckbox.d.ts.map +1 -0
- package/build/types/listItem/Checkbox/index.d.ts +3 -0
- package/build/types/listItem/Checkbox/index.d.ts.map +1 -0
- package/build/types/listItem/IconButton/ListItemIconButton.d.ts +18 -0
- package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +1 -0
- package/build/types/listItem/IconButton/index.d.ts +3 -0
- package/build/types/listItem/IconButton/index.d.ts.map +1 -0
- package/build/types/listItem/Image/ListItemImage.d.ts +25 -0
- package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -0
- package/build/types/listItem/Image/index.d.ts +3 -0
- package/build/types/listItem/Image/index.d.ts.map +1 -0
- package/build/types/listItem/ListItem.d.ts +113 -0
- package/build/types/listItem/ListItem.d.ts.map +1 -0
- package/build/types/listItem/ListItemContext.d.ts +18 -0
- package/build/types/listItem/ListItemContext.d.ts.map +1 -0
- package/build/types/listItem/Navigation/ListItemNavigation.d.ts +15 -0
- package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +1 -0
- package/build/types/listItem/Navigation/index.d.ts +3 -0
- package/build/types/listItem/Navigation/index.d.ts.map +1 -0
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts +16 -0
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -0
- package/build/types/listItem/Prompt/index.d.ts +3 -0
- package/build/types/listItem/Prompt/index.d.ts.map +1 -0
- package/build/types/listItem/Radio/ListItemRadio.d.ts +14 -0
- package/build/types/listItem/Radio/ListItemRadio.d.ts.map +1 -0
- package/build/types/listItem/Radio/index.d.ts +3 -0
- package/build/types/listItem/Radio/index.d.ts.map +1 -0
- package/build/types/listItem/Switch/ListItemSwitch.d.ts +14 -0
- package/build/types/listItem/Switch/ListItemSwitch.d.ts.map +1 -0
- package/build/types/listItem/Switch/index.d.ts +3 -0
- package/build/types/listItem/Switch/index.d.ts.map +1 -0
- package/build/types/listItem/_stories/subcomponents.d.ts +18 -0
- package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -0
- package/build/types/listItem/index.d.ts +14 -0
- package/build/types/listItem/index.d.ts.map +1 -0
- package/build/types/listItem/useListItemControl.d.ts +5 -0
- package/build/types/listItem/useListItemControl.d.ts.map +1 -0
- package/build/types/switch/Switch.d.ts +2 -0
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +4 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/types/upload/Upload.d.ts +6 -2
- package/build/types/upload/Upload.d.ts.map +1 -1
- package/build/types/upload/Upload.messages.d.ts +8 -0
- package/build/types/upload/Upload.messages.d.ts.map +1 -1
- package/build/types/uploadInput/UploadInput.d.ts +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts +4 -2
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/build/upload/Upload.js +16 -9
- package/build/upload/Upload.js.map +1 -1
- package/build/upload/Upload.messages.js +6 -0
- package/build/upload/Upload.messages.js.map +1 -1
- package/build/upload/Upload.messages.mjs +6 -0
- package/build/upload/Upload.messages.mjs.map +1 -1
- package/build/upload/Upload.mjs +16 -9
- package/build/upload/Upload.mjs.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/uploadInput/uploadButton/UploadButton.js +7 -4
- package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.mjs +7 -4
- package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
- package/package.json +1 -1
- package/src/button/Button.spec.tsx +18 -0
- package/src/button/Button.tsx +5 -1
- package/src/button/Button.types.ts +1 -1
- package/src/button/index.ts +1 -1
- package/src/checkboxButton/CheckboxButton.story.tsx +4 -4
- package/src/common/RadioButton/RadioButton.tsx +6 -1
- package/src/i18n/en.json +2 -0
- package/src/iconButton/IconButton.story.tsx +1 -1
- package/src/iconButton/IconButton.tsx +1 -1
- package/src/image/Image.tsx +3 -0
- package/src/image/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +145 -0
- package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.tsx +36 -0
- package/src/listItem/AdditionalInfo/index.ts +2 -0
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +118 -0
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +24 -0
- package/src/listItem/AvatarLayout/index.ts +2 -0
- package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +318 -0
- package/src/listItem/AvatarView/ListItemAvatarView.tsx +24 -0
- package/src/listItem/AvatarView/index.ts +2 -0
- package/src/listItem/Button/ListItemButton.spec.tsx +93 -0
- package/src/listItem/Button/ListItemButton.story.tsx +408 -0
- package/src/listItem/Button/ListItemButton.tsx +56 -0
- package/src/listItem/Button/index.ts +2 -0
- package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +107 -0
- package/src/listItem/Checkbox/ListItemCheckbox.tsx +33 -0
- package/src/listItem/Checkbox/index.ts +2 -0
- package/src/listItem/IconButton/ListItemIconButton.story.tsx +236 -0
- package/src/listItem/IconButton/ListItemIconButton.tsx +56 -0
- package/src/listItem/IconButton/index.ts +2 -0
- package/src/listItem/Image/ListItemImage.story.tsx +39 -0
- package/src/listItem/Image/ListItemImage.tsx +40 -0
- package/src/listItem/Image/index.ts +2 -0
- package/src/listItem/ListItem.css +657 -0
- package/src/listItem/ListItem.grid.css +362 -0
- package/src/listItem/ListItem.grid.less +612 -0
- package/src/listItem/ListItem.less +312 -0
- package/src/listItem/ListItem.spec.tsx +97 -0
- package/src/listItem/ListItem.tsx +428 -0
- package/src/listItem/ListItemContext.tsx +22 -0
- package/src/listItem/Navigation/ListItemNavigation.story.tsx +106 -0
- package/src/listItem/Navigation/ListItemNavigation.tsx +40 -0
- package/src/listItem/Navigation/index.ts +2 -0
- package/src/listItem/Prompt/ListItemPrompt.spec.tsx +49 -0
- package/src/listItem/Prompt/ListItemPrompt.story.tsx +199 -0
- package/src/listItem/Prompt/ListItemPrompt.tsx +32 -0
- package/src/listItem/Prompt/index.ts +2 -0
- package/src/listItem/Radio/ListItemRadio.story.tsx +98 -0
- package/src/listItem/Radio/ListItemRadio.tsx +33 -0
- package/src/listItem/Radio/index.ts +2 -0
- package/src/listItem/Switch/ListItemSwitch.story.tsx +69 -0
- package/src/listItem/Switch/ListItemSwitch.tsx +33 -0
- package/src/listItem/Switch/index.ts +2 -0
- package/src/listItem/_stories/ListItem.focus.test.story.tsx +250 -0
- package/src/listItem/_stories/ListItem.layout.test.story.tsx +169 -0
- package/src/listItem/_stories/ListItem.story.tsx +670 -0
- package/src/listItem/_stories/ListItem.variants.test.story.tsx +266 -0
- package/src/listItem/_stories/subcomponents.tsx +139 -0
- package/src/listItem/index.ts +14 -0
- package/src/listItem/useListItemControl.tsx +18 -0
- package/src/main.css +657 -0
- package/src/main.less +1 -0
- package/src/switch/Switch.tsx +4 -0
- package/src/upload/Upload.messages.ts +8 -0
- package/src/upload/Upload.spec.tsx +6 -0
- package/src/upload/Upload.story.tsx +118 -3
- package/src/upload/Upload.tests.story.tsx +5 -3
- package/src/upload/Upload.tsx +24 -15
- package/src/uploadInput/UploadInput.tests.story.tsx +7 -0
- package/src/uploadInput/UploadInput.tsx +2 -2
- package/src/uploadInput/uploadButton/UploadButton.spec.tsx +6 -0
- package/src/uploadInput/uploadButton/UploadButton.tsx +12 -6
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { Flag } from '@wise/art';
|
|
3
|
+
import { lorem10 } from '../../test-utils';
|
|
4
|
+
import { ListItem } from '../ListItem';
|
|
5
|
+
import {
|
|
6
|
+
SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
|
|
7
|
+
SB_LIST_ITEM_CONTROLS as CONTROLS,
|
|
8
|
+
} from '../_stories/subcomponents';
|
|
9
|
+
import { ListItemAvatarLayoutProps } from './ListItemAvatarLayout';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: ListItem.AvatarLayout,
|
|
13
|
+
title: 'Content/ListItem/ListItem.AvatarLayout',
|
|
14
|
+
parameters: {
|
|
15
|
+
docs: {
|
|
16
|
+
toc: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
args: {
|
|
20
|
+
avatars: [{ asset: <Flag code="gb" /> }, { asset: <Flag code="eur" /> }],
|
|
21
|
+
orientation: 'horizontal',
|
|
22
|
+
size: 48,
|
|
23
|
+
},
|
|
24
|
+
argTypes: {
|
|
25
|
+
avatars: {
|
|
26
|
+
description: 'Array of avatar objects with asset and optional styling properties',
|
|
27
|
+
table: {
|
|
28
|
+
type: { summary: 'SingleAvatarType[]' },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
orientation: {
|
|
32
|
+
control: 'inline-radio',
|
|
33
|
+
options: ['horizontal', 'diagonal'],
|
|
34
|
+
description: 'Layout orientation for multiple avatars',
|
|
35
|
+
},
|
|
36
|
+
size: {
|
|
37
|
+
control: 'select',
|
|
38
|
+
options: [32, 40, 48, 56, 72],
|
|
39
|
+
description: 'Size of the avatar layout',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
} satisfies Meta<ListItemAvatarLayoutProps>;
|
|
43
|
+
|
|
44
|
+
type Story = StoryObj<ListItemAvatarLayoutProps>;
|
|
45
|
+
|
|
46
|
+
export const Playground: Story = {
|
|
47
|
+
tags: ['!autodocs'],
|
|
48
|
+
render: (args: ListItemAvatarLayoutProps) => {
|
|
49
|
+
return (
|
|
50
|
+
<ListItem
|
|
51
|
+
title="Transfer from GBP to EUR"
|
|
52
|
+
subtitle="Currency exchange"
|
|
53
|
+
media={<ListItem.AvatarLayout {...args} />}
|
|
54
|
+
control={CONTROLS.iconButton}
|
|
55
|
+
additionalInfo={INFO.nonInteractive}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* AvatarLayout supports two orientations: horizontal (default) and diagonal. <br />
|
|
63
|
+
* Please refer to the [design documentation](https://wise.design/components/avatar#double) for more details.
|
|
64
|
+
*/
|
|
65
|
+
export const Orientations: Story = {
|
|
66
|
+
render: (args) => {
|
|
67
|
+
return (
|
|
68
|
+
<ol className="list-unstyled">
|
|
69
|
+
<ListItem
|
|
70
|
+
title="Horizontal orientation"
|
|
71
|
+
subtitle={lorem10}
|
|
72
|
+
media={<ListItem.AvatarLayout {...args} orientation="horizontal" />}
|
|
73
|
+
control={CONTROLS.iconButton}
|
|
74
|
+
/>
|
|
75
|
+
|
|
76
|
+
<ListItem
|
|
77
|
+
title="Diagonal orientation"
|
|
78
|
+
subtitle={lorem10}
|
|
79
|
+
media={<ListItem.AvatarLayout {...args} orientation="diagonal" />}
|
|
80
|
+
control={CONTROLS.iconButton}
|
|
81
|
+
/>
|
|
82
|
+
</ol>
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* AvatarLayout supports various sizes to fit different list item contexts.
|
|
89
|
+
*/
|
|
90
|
+
export const Sizes: Story = {
|
|
91
|
+
parameters: {
|
|
92
|
+
docs: {
|
|
93
|
+
canvas: {
|
|
94
|
+
sourceState: 'hidden',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
render: (args) => {
|
|
99
|
+
const sizes = [32, 40, 48, 56, 72] as const;
|
|
100
|
+
const orientations = ['horizontal', 'diagonal'] as const;
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<ol className="list-unstyled">
|
|
104
|
+
{orientations.map((orientation) =>
|
|
105
|
+
sizes.map((size) => (
|
|
106
|
+
<ListItem
|
|
107
|
+
key={`${orientation}-${size}`}
|
|
108
|
+
title={`Size ${size}`}
|
|
109
|
+
subtitle={lorem10}
|
|
110
|
+
media={<ListItem.AvatarLayout {...args} size={size} orientation={orientation} />}
|
|
111
|
+
control={CONTROLS.iconButton}
|
|
112
|
+
/>
|
|
113
|
+
)),
|
|
114
|
+
)}
|
|
115
|
+
</ol>
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import AvatarLayoutComp, { type AvatarLayoutProps } from '../../avatarLayout';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
|
|
4
|
+
type SizeProp = { size?: 32 | 40 | 48 | 56 | 72 };
|
|
5
|
+
|
|
6
|
+
export type ListItemAvatarLayoutProps = Omit<AvatarLayoutProps, 'size' | 'interactive'> & SizeProp;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This component allows for rendering 2 avatars. It's a thin wrapper around the
|
|
10
|
+
* [AvatarLayout component](https://storybook.wise.design/?path=/docs/content-avatarlayout--docs), but offers only
|
|
11
|
+
* a subset of its sizes, and disallows interactive mode, in line with the ListItem's constraints. <br />
|
|
12
|
+
* <br />
|
|
13
|
+
* Please refer to the [Design documentation](https://wise.design/components/list-item#avatar) for details.
|
|
14
|
+
*/
|
|
15
|
+
export const AvatarLayout = ({ className, size = 48, ...props }: ListItemAvatarLayoutProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<AvatarLayoutComp
|
|
18
|
+
{...props}
|
|
19
|
+
size={size}
|
|
20
|
+
className={clsx('wds-list-item-media-avatar-layout', className)}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
AvatarLayout.displayName = 'ListItem.AvatarLayout';
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { Leaf, Taxi } from '@transferwise/icons';
|
|
3
|
+
import { ListItem } from '../ListItem';
|
|
4
|
+
import {
|
|
5
|
+
SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
|
|
6
|
+
SB_LIST_ITEM_CONTROLS as CONTROLS,
|
|
7
|
+
} from '../_stories/subcomponents';
|
|
8
|
+
import { ListItemAvatarViewProps } from './ListItemAvatarView';
|
|
9
|
+
import { lorem10 } from '../../test-utils';
|
|
10
|
+
import { ProfileType } from '../../common';
|
|
11
|
+
|
|
12
|
+
const SIZES = [32, 40, 48, 56, 72] as const;
|
|
13
|
+
const BADGES = {
|
|
14
|
+
'Country flag badge': { flagCode: 'GBP' },
|
|
15
|
+
'StatusIcon badge': { status: 'warning' },
|
|
16
|
+
'Icon badge': { icon: <Taxi /> },
|
|
17
|
+
'Default action badge': {
|
|
18
|
+
type: 'action',
|
|
19
|
+
},
|
|
20
|
+
'Default reference badge': {
|
|
21
|
+
type: 'reference',
|
|
22
|
+
},
|
|
23
|
+
'Action badge with custom icon': {
|
|
24
|
+
type: 'action',
|
|
25
|
+
icon: <Taxi />,
|
|
26
|
+
},
|
|
27
|
+
'Reference badge with custom icon': {
|
|
28
|
+
type: 'reference',
|
|
29
|
+
icon: <Taxi />,
|
|
30
|
+
},
|
|
31
|
+
'Custom badge': {
|
|
32
|
+
asset: (
|
|
33
|
+
<div
|
|
34
|
+
className="d-flex align-items-center justify-content-center"
|
|
35
|
+
style={{
|
|
36
|
+
backgroundColor: 'var(--color-bright-pink)',
|
|
37
|
+
color: 'var(--color-interactive-primary)',
|
|
38
|
+
width: '100%',
|
|
39
|
+
height: '100%',
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<Leaf />
|
|
43
|
+
</div>
|
|
44
|
+
),
|
|
45
|
+
},
|
|
46
|
+
} as const;
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
component: ListItem.AvatarView,
|
|
50
|
+
title: 'Content/ListItem/ListItem.AvatarView',
|
|
51
|
+
parameters: {
|
|
52
|
+
docs: {
|
|
53
|
+
toc: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
args: {
|
|
57
|
+
size: 48,
|
|
58
|
+
selected: false,
|
|
59
|
+
badge: { type: 'action' },
|
|
60
|
+
notification: false,
|
|
61
|
+
profileName: undefined,
|
|
62
|
+
profileType: undefined,
|
|
63
|
+
imgSrc: undefined,
|
|
64
|
+
},
|
|
65
|
+
argTypes: {
|
|
66
|
+
size: {
|
|
67
|
+
control: 'select',
|
|
68
|
+
options: SIZES,
|
|
69
|
+
description: 'Size of the avatar',
|
|
70
|
+
},
|
|
71
|
+
profileName: {
|
|
72
|
+
control: 'text',
|
|
73
|
+
description: 'Name used to generate initials when no image or icon is provided',
|
|
74
|
+
},
|
|
75
|
+
imgSrc: {
|
|
76
|
+
control: 'text',
|
|
77
|
+
description: 'URL of the profile image',
|
|
78
|
+
},
|
|
79
|
+
profileType: {
|
|
80
|
+
control: 'select',
|
|
81
|
+
options: ['personal', 'business'],
|
|
82
|
+
description: 'Type of profile for default icons',
|
|
83
|
+
},
|
|
84
|
+
notification: {
|
|
85
|
+
control: 'boolean',
|
|
86
|
+
description: 'Shows notification dot',
|
|
87
|
+
},
|
|
88
|
+
selected: {
|
|
89
|
+
control: 'boolean',
|
|
90
|
+
description: 'Toggles selected state',
|
|
91
|
+
},
|
|
92
|
+
badge: {
|
|
93
|
+
description: 'Badge configuration object',
|
|
94
|
+
table: {
|
|
95
|
+
type: { summary: 'AvatarViewBadgeProps' },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
children: {
|
|
99
|
+
table: {
|
|
100
|
+
type: { summary: 'ReactNode' },
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
style: {
|
|
104
|
+
table: {
|
|
105
|
+
disable: true,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
} satisfies Meta<ListItemAvatarViewProps>;
|
|
110
|
+
|
|
111
|
+
type Story = StoryObj<ListItemAvatarViewProps>;
|
|
112
|
+
|
|
113
|
+
export const Playground: Story = {
|
|
114
|
+
tags: ['!autodocs'],
|
|
115
|
+
render: (args: ListItemAvatarViewProps) => {
|
|
116
|
+
return (
|
|
117
|
+
<ListItem
|
|
118
|
+
title="John Smith"
|
|
119
|
+
subtitle="Personal account"
|
|
120
|
+
media={<ListItem.AvatarView {...args} />}
|
|
121
|
+
control={CONTROLS.iconButton}
|
|
122
|
+
additionalInfo={INFO.nonInteractive}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* AvatarView can display different types of content including icons, profile images, and initials. <br />
|
|
130
|
+
* Refer to the [design documentation](https://wise.design/components/avatar#:~:text=56%2C%20%E2%80%A8and%2072.-,Media,-There%20are%204) for details.
|
|
131
|
+
*/
|
|
132
|
+
export const ContentTypes: Story = {
|
|
133
|
+
args: {
|
|
134
|
+
badge: undefined,
|
|
135
|
+
},
|
|
136
|
+
parameters: {
|
|
137
|
+
docs: {
|
|
138
|
+
canvas: {
|
|
139
|
+
sourceState: 'hidden',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
render: (args) => {
|
|
144
|
+
return (
|
|
145
|
+
<ol className="list-unstyled">
|
|
146
|
+
<ListItem
|
|
147
|
+
title="With icon"
|
|
148
|
+
subtitle="Default icon content"
|
|
149
|
+
media={
|
|
150
|
+
<ListItem.AvatarView {...args}>
|
|
151
|
+
<Taxi />
|
|
152
|
+
</ListItem.AvatarView>
|
|
153
|
+
}
|
|
154
|
+
control={CONTROLS.iconButton}
|
|
155
|
+
/>
|
|
156
|
+
|
|
157
|
+
<ListItem
|
|
158
|
+
title="With profile image"
|
|
159
|
+
subtitle="User profile picture."
|
|
160
|
+
media={
|
|
161
|
+
<ListItem.AvatarView
|
|
162
|
+
{...args}
|
|
163
|
+
imgSrc="../avatar-square-dude.webp"
|
|
164
|
+
profileName="John Smith"
|
|
165
|
+
/>
|
|
166
|
+
}
|
|
167
|
+
control={CONTROLS.iconButton}
|
|
168
|
+
/>
|
|
169
|
+
|
|
170
|
+
<ListItem
|
|
171
|
+
title="With initials"
|
|
172
|
+
subtitle="Fallback for when no profile image is available."
|
|
173
|
+
media={<ListItem.AvatarView {...args} profileName="Sarah Johnson" />}
|
|
174
|
+
control={CONTROLS.iconButton}
|
|
175
|
+
/>
|
|
176
|
+
|
|
177
|
+
<ListItem
|
|
178
|
+
title="Business profile"
|
|
179
|
+
subtitle="Fallback for when no logo is available"
|
|
180
|
+
media={<ListItem.AvatarView {...args} profileType={ProfileType.BUSINESS} />}
|
|
181
|
+
control={CONTROLS.iconButton}
|
|
182
|
+
/>
|
|
183
|
+
|
|
184
|
+
<ListItem
|
|
185
|
+
title="Personal profile"
|
|
186
|
+
subtitle="Fallback for when no personal data is available or when image fails to load."
|
|
187
|
+
media={
|
|
188
|
+
<ListItem.AvatarView
|
|
189
|
+
{...args}
|
|
190
|
+
profileType={ProfileType.PERSONAL}
|
|
191
|
+
profileName="Alex Chen"
|
|
192
|
+
/>
|
|
193
|
+
}
|
|
194
|
+
control={CONTROLS.iconButton}
|
|
195
|
+
/>
|
|
196
|
+
</ol>
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* AvatarView supports 5 sizes to fit different list item contexts: `32`, `40`, `48`, `56`, `72`. If decorated with a Badge, those will be sized accordingly as well. <br />
|
|
203
|
+
* Please refer to the [design documentation](https://wise.design/components/list-item#avatar:~:text=of%20the%20avatar.-,Avatar%20sizes,-List%20item%20supports) for details on when to use which one.
|
|
204
|
+
*/
|
|
205
|
+
export const Sizes: Story = {
|
|
206
|
+
parameters: {
|
|
207
|
+
docs: {
|
|
208
|
+
canvas: {
|
|
209
|
+
sourceState: 'hidden',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
render: (args) => {
|
|
214
|
+
return (
|
|
215
|
+
<ol>
|
|
216
|
+
{SIZES.map((size) => (
|
|
217
|
+
<ListItem
|
|
218
|
+
key={size}
|
|
219
|
+
title={`Size ${size}`}
|
|
220
|
+
subtitle={lorem10}
|
|
221
|
+
media={
|
|
222
|
+
<ListItem.AvatarView {...args} size={size}>
|
|
223
|
+
<Taxi />
|
|
224
|
+
</ListItem.AvatarView>
|
|
225
|
+
}
|
|
226
|
+
control={CONTROLS.iconButton}
|
|
227
|
+
/>
|
|
228
|
+
))}
|
|
229
|
+
</ol>
|
|
230
|
+
);
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Similarly, AvatarView also support a notification dot, which also adjusts to the Avatar's size. <br />
|
|
236
|
+
* **NB:** You cannot use notification and badge at the same time – badge will always take precedence over notification.
|
|
237
|
+
*/
|
|
238
|
+
export const Notification: Story = {
|
|
239
|
+
parameters: {
|
|
240
|
+
docs: {
|
|
241
|
+
canvas: {
|
|
242
|
+
sourceState: 'hidden',
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
args: {
|
|
247
|
+
badge: undefined,
|
|
248
|
+
},
|
|
249
|
+
render: (args) => {
|
|
250
|
+
return (
|
|
251
|
+
<ol>
|
|
252
|
+
{SIZES.map((size) => (
|
|
253
|
+
<ListItem
|
|
254
|
+
key={size}
|
|
255
|
+
title={`Size ${size}`}
|
|
256
|
+
subtitle={lorem10}
|
|
257
|
+
media={
|
|
258
|
+
<ListItem.AvatarView {...args} size={size} notification>
|
|
259
|
+
<Taxi />
|
|
260
|
+
</ListItem.AvatarView>
|
|
261
|
+
}
|
|
262
|
+
control={CONTROLS.iconButton}
|
|
263
|
+
/>
|
|
264
|
+
))}
|
|
265
|
+
</ol>
|
|
266
|
+
);
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* AvatarView supports different type of badges for additional context and information. <br />
|
|
272
|
+
* Refer to the [design documentation](https://wise.design/components/avatar#:~:text=support%20the%20information.-,With%20badge,-Badges%20contain%20additional) for details.
|
|
273
|
+
*/
|
|
274
|
+
export const Badges: Story = {
|
|
275
|
+
args: {
|
|
276
|
+
imgSrc: '../avatar-square-dude.webp',
|
|
277
|
+
},
|
|
278
|
+
parameters: {
|
|
279
|
+
docs: {
|
|
280
|
+
canvas: {
|
|
281
|
+
sourceState: 'hidden',
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
render: (args) => {
|
|
286
|
+
return (
|
|
287
|
+
<ol className="list-unstyled">
|
|
288
|
+
{Object.entries(BADGES).map(([title, badge]) => (
|
|
289
|
+
<ListItem
|
|
290
|
+
key={title}
|
|
291
|
+
title={title}
|
|
292
|
+
subtitle={lorem10}
|
|
293
|
+
media={<ListItem.AvatarView {...args} badge={badge} />}
|
|
294
|
+
control={CONTROLS.iconButton}
|
|
295
|
+
/>
|
|
296
|
+
))}
|
|
297
|
+
</ol>
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* AvatarView supports selected state for interactive contexts.
|
|
304
|
+
*/
|
|
305
|
+
export const Selected: Story = {
|
|
306
|
+
render: (args) => {
|
|
307
|
+
return (
|
|
308
|
+
<ol className="list-unstyled">
|
|
309
|
+
<ListItem
|
|
310
|
+
title="Selected state"
|
|
311
|
+
subtitle="Currently selected item"
|
|
312
|
+
media={<ListItem.AvatarView profileName="Alex Chen" selected />}
|
|
313
|
+
control={CONTROLS.iconButton}
|
|
314
|
+
/>
|
|
315
|
+
</ol>
|
|
316
|
+
);
|
|
317
|
+
},
|
|
318
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import AvatarViewComp, { AvatarViewProps } from '../../avatarView';
|
|
3
|
+
|
|
4
|
+
export type ListItemAvatarViewProps = Omit<AvatarViewProps, 'size' | 'interactive'> & {
|
|
5
|
+
size?: 32 | 40 | 48 | 56 | 72;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This component renders a single avatar. It's a thin wrapper around the
|
|
10
|
+
* [AvatarView component](https://storybook.wise.design/?path=/docs/content-avatarview--docs), but offers only
|
|
11
|
+
* a subset of its sizes, in line with the ListItem's constraints. <br />
|
|
12
|
+
* <br />
|
|
13
|
+
* Please refer to the [Design documentation](https://wise.design/components/list-item#avatar) for details.
|
|
14
|
+
*/
|
|
15
|
+
export const AvatarView = ({ className, size = 48, ...props }: ListItemAvatarViewProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<AvatarViewComp
|
|
18
|
+
{...props}
|
|
19
|
+
size={size}
|
|
20
|
+
className={clsx('wds-list-item-media-avatar-view', className)}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
AvatarView.displayName = 'ListItem.AvatarView';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { render, screen, mockMatchMedia } from '../../test-utils';
|
|
2
|
+
import { Button as ItemButton } from './ListItemButton';
|
|
3
|
+
import { ButtonPriority } from '../../button/Button.types';
|
|
4
|
+
import { ListItemContext } from '../ListItemContext';
|
|
5
|
+
|
|
6
|
+
mockMatchMedia();
|
|
7
|
+
|
|
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
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
jest.clearAllMocks();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('always sets v2 to true', () => {
|
|
39
|
+
renderWithItemContext(<ItemButton priority="primary">Test Button</ItemButton>);
|
|
40
|
+
const button = screen.getByRole('button');
|
|
41
|
+
expect(button).toBeInTheDocument();
|
|
42
|
+
expect(mockSetControlType).toHaveBeenCalledWith('button');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('always sets size to "sm"', () => {
|
|
46
|
+
renderWithItemContext(<ItemButton priority="primary">Test Button</ItemButton>);
|
|
47
|
+
const button = screen.getByRole('button');
|
|
48
|
+
expect(button).toHaveClass('wds-Button--small');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('supports all priorities', () => {
|
|
52
|
+
const priorities: ButtonPriority[] = ['primary', 'secondary', 'tertiary'];
|
|
53
|
+
priorities.forEach((priority) => {
|
|
54
|
+
renderWithItemContext(<ItemButton priority={priority}>Test {priority}</ItemButton>);
|
|
55
|
+
const button = screen.getByRole('button', { name: `Test ${priority}` });
|
|
56
|
+
expect(button).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renders as a button by default', () => {
|
|
61
|
+
renderWithItemContext(<ItemButton>Click me</ItemButton>);
|
|
62
|
+
const button = screen.getByRole('button');
|
|
63
|
+
expect(button).toBeInTheDocument();
|
|
64
|
+
expect(button.tagName).toBe('BUTTON');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('renders as an anchor when href is provided', () => {
|
|
68
|
+
renderWithItemContext(<ItemButton href="https://example.com">Go to Example</ItemButton>);
|
|
69
|
+
const link = screen.getByRole('link', { name: 'Go to Example' });
|
|
70
|
+
expect(link).toBeInTheDocument();
|
|
71
|
+
expect(link.tagName).toBe('A');
|
|
72
|
+
expect(link).toHaveAttribute('href', 'https://example.com');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('spreads additional props to the button', () => {
|
|
76
|
+
renderWithItemContext(<ItemButton aria-label="Custom Button">Custom</ItemButton>);
|
|
77
|
+
const button = screen.getByRole('button', { name: 'Custom Button' });
|
|
78
|
+
expect(button).toBeInTheDocument();
|
|
79
|
+
expect(button).toHaveAttribute('aria-label', 'Custom Button');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('spreads additional props to the anchor', () => {
|
|
83
|
+
renderWithItemContext(
|
|
84
|
+
<ItemButton href="https://example.com" target="_blank" aria-label="Custom Link">
|
|
85
|
+
Custom Link
|
|
86
|
+
</ItemButton>,
|
|
87
|
+
);
|
|
88
|
+
const link = screen.getByRole('link', { name: 'Custom Link' });
|
|
89
|
+
expect(link).toBeInTheDocument();
|
|
90
|
+
expect(link).toHaveAttribute('href', 'https://example.com');
|
|
91
|
+
expect(link).toHaveAttribute('target', '_blank');
|
|
92
|
+
});
|
|
93
|
+
});
|