@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,236 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { Edit, Heart } from '@transferwise/icons';
|
|
3
|
+
import { ListItem } from '../ListItem';
|
|
4
|
+
import {
|
|
5
|
+
SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
|
|
6
|
+
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
7
|
+
SB_LIST_ITEM_PROMPTS as PROMPTS,
|
|
8
|
+
} from '../_stories/subcomponents';
|
|
9
|
+
import type { ListItemIconButtonProps } from './ListItemIconButton';
|
|
10
|
+
import { fn } from 'storybook/test';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Use IconButton to provide compact action controls within a ListItem context using iconography.
|
|
14
|
+
*
|
|
15
|
+
* Refer to the [design documentation](https://wise.design/components/list-item) for more details.
|
|
16
|
+
*/
|
|
17
|
+
const meta: Meta<ListItemIconButtonProps> = {
|
|
18
|
+
component: ListItem.IconButton,
|
|
19
|
+
title: 'Content/ListItem/ListItem.IconButton',
|
|
20
|
+
parameters: {
|
|
21
|
+
docs: {
|
|
22
|
+
toc: true,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
args: {
|
|
26
|
+
partiallyInteractive: false,
|
|
27
|
+
priority: undefined,
|
|
28
|
+
type: undefined,
|
|
29
|
+
children: <Edit />,
|
|
30
|
+
href: undefined,
|
|
31
|
+
target: undefined,
|
|
32
|
+
onClick: fn(),
|
|
33
|
+
},
|
|
34
|
+
argTypes: {
|
|
35
|
+
children: {
|
|
36
|
+
description: 'Once of the [Icon components](https://transferwise.github.io/icons/).',
|
|
37
|
+
table: {
|
|
38
|
+
type: { summary: 'ReactNode' },
|
|
39
|
+
},
|
|
40
|
+
control: false,
|
|
41
|
+
},
|
|
42
|
+
priority: {
|
|
43
|
+
control: 'radio',
|
|
44
|
+
options: ['unset (undefined)', 'primary', 'secondary', 'tertiary', 'minimal'],
|
|
45
|
+
mapping: {
|
|
46
|
+
'unset (undefined)': undefined,
|
|
47
|
+
},
|
|
48
|
+
description: 'IconButton priority/style variant',
|
|
49
|
+
},
|
|
50
|
+
type: {
|
|
51
|
+
control: 'radio',
|
|
52
|
+
options: ['unset (undefined)', 'default', 'negative'],
|
|
53
|
+
mapping: {
|
|
54
|
+
'unset (undefined)': undefined,
|
|
55
|
+
},
|
|
56
|
+
description:
|
|
57
|
+
'Sets a visual hierarchy amongst the buttons displayed on the screen. <br /> **NB:** `negative` sentiment only affects the `primary` and `secondary` priorities.',
|
|
58
|
+
},
|
|
59
|
+
partiallyInteractive: {
|
|
60
|
+
control: 'boolean',
|
|
61
|
+
description: 'Whether the icon button allows partial interactivity in the ListItem',
|
|
62
|
+
},
|
|
63
|
+
href: {
|
|
64
|
+
control: 'text',
|
|
65
|
+
description: 'URL for icon button rendered as link',
|
|
66
|
+
},
|
|
67
|
+
target: {
|
|
68
|
+
control: 'select',
|
|
69
|
+
options: [undefined, '_blank', '_self', '_parent', '_top'],
|
|
70
|
+
description:
|
|
71
|
+
'The `target` attribute for HTML anchor. If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
} satisfies Meta<ListItemIconButtonProps>;
|
|
75
|
+
|
|
76
|
+
export default meta;
|
|
77
|
+
|
|
78
|
+
type Story = StoryObj<ListItemIconButtonProps>;
|
|
79
|
+
|
|
80
|
+
export const Playground: Story = {
|
|
81
|
+
tags: ['!autodocs'],
|
|
82
|
+
render: (args: ListItemIconButtonProps) => {
|
|
83
|
+
return (
|
|
84
|
+
<ListItem
|
|
85
|
+
title="List item title"
|
|
86
|
+
subtitle="Subtitle goes here"
|
|
87
|
+
media={MEDIA.avatarSingle}
|
|
88
|
+
control={<ListItem.IconButton {...args} />}
|
|
89
|
+
additionalInfo={INFO.nonInteractive}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* By default, ListItem is fully interactive, which means its whole surface is clickable
|
|
97
|
+
* and triggers the control. To remain WCAG-compliant there can be no nested interactive
|
|
98
|
+
* elements inside the item.<br />
|
|
99
|
+
*
|
|
100
|
+
* To work around this limitation, this control also allows for a partially interactive mode,
|
|
101
|
+
* which can be enabled via `partiallyInteractive` prop. Once set, only the control will
|
|
102
|
+
* remain interactive, which allows for interactive element to be attached to the
|
|
103
|
+
* `ListItem.AdditionalInfo`. This allows for more complex layouts while still providing a
|
|
104
|
+
* clear, accessible action point for users. <br />
|
|
105
|
+
*
|
|
106
|
+
* If you still require a fully interactive ListItem, you can alternatively use `ListItem.Prompt`
|
|
107
|
+
* which allows for a single instance of a link or an inline button.
|
|
108
|
+
*
|
|
109
|
+
* Refer to the [design documentation](https://wise.design/components/list-item#interaction) for details.
|
|
110
|
+
*/
|
|
111
|
+
export const Interactivity: Story = {
|
|
112
|
+
args: {
|
|
113
|
+
children: <Edit />,
|
|
114
|
+
},
|
|
115
|
+
render: (args: ListItemIconButtonProps) => {
|
|
116
|
+
return (
|
|
117
|
+
<ol className="list-unstyled">
|
|
118
|
+
<ListItem
|
|
119
|
+
control={<ListItem.IconButton {...args} />}
|
|
120
|
+
title="Fully interactive ListItem"
|
|
121
|
+
subtitle="IconButton in fully interactive context"
|
|
122
|
+
media={MEDIA.avatarSingle}
|
|
123
|
+
additionalInfo={INFO.nonInteractive}
|
|
124
|
+
prompt={PROMPTS.interactive}
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
<ListItem
|
|
128
|
+
control={<ListItem.IconButton {...args} partiallyInteractive />}
|
|
129
|
+
title="Partially interactive ListItem"
|
|
130
|
+
subtitle="IconButton in partially interactive context"
|
|
131
|
+
media={MEDIA.avatarSingle}
|
|
132
|
+
additionalInfo={INFO.interactive}
|
|
133
|
+
prompt={PROMPTS.interactive}
|
|
134
|
+
/>
|
|
135
|
+
</ol>
|
|
136
|
+
);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* There are two different types of icon button – default and negative – designed to emphasise the nature of the action. <br />
|
|
142
|
+
* **NB:** Sentiment only applies to `primary` and `secondary` priorities. <br />
|
|
143
|
+
* [Design documentation](https://wise.design/components/icon-button#types)
|
|
144
|
+
*/
|
|
145
|
+
export const Sentiment: Story = {
|
|
146
|
+
render: (args) => {
|
|
147
|
+
return (
|
|
148
|
+
<ol className="list-unstyled">
|
|
149
|
+
<ListItem
|
|
150
|
+
control={<ListItem.IconButton {...args} priority="primary" type="default" />}
|
|
151
|
+
title="Default Sentiment - Primary"
|
|
152
|
+
subtitle="Default sentiment with primary priority"
|
|
153
|
+
media={MEDIA.avatarSingle}
|
|
154
|
+
/>
|
|
155
|
+
<ListItem
|
|
156
|
+
control={<ListItem.IconButton {...args} priority="secondary" type="default" />}
|
|
157
|
+
title="Default Sentiment - Secondary"
|
|
158
|
+
subtitle="Default sentiment with secondary priority"
|
|
159
|
+
media={MEDIA.avatarSingle}
|
|
160
|
+
/>
|
|
161
|
+
<ListItem
|
|
162
|
+
control={<ListItem.IconButton {...args} priority="primary" type="negative" />}
|
|
163
|
+
title="Negative Sentiment - Primary"
|
|
164
|
+
subtitle="Negative sentiment with primary priority"
|
|
165
|
+
media={MEDIA.avatarSingle}
|
|
166
|
+
/>
|
|
167
|
+
<ListItem
|
|
168
|
+
control={<ListItem.IconButton {...args} priority="secondary" type="negative" />}
|
|
169
|
+
title="Negative Sentiment - Secondary"
|
|
170
|
+
subtitle="Negative sentiment with secondary priority"
|
|
171
|
+
media={MEDIA.avatarSingle}
|
|
172
|
+
/>
|
|
173
|
+
</ol>
|
|
174
|
+
);
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Priorities set a visual hierarchy amongst the buttons displayed on the
|
|
180
|
+
* screen to help more important buttons to take precedence over others. <br />
|
|
181
|
+
* [Design documentation](https://wise.design/components/icon-button#priorities)
|
|
182
|
+
*/
|
|
183
|
+
export const Priority: Story = {
|
|
184
|
+
render: (args) => {
|
|
185
|
+
return (
|
|
186
|
+
<ol className="list-unstyled">
|
|
187
|
+
<ListItem
|
|
188
|
+
title="Primary Priority"
|
|
189
|
+
subtitle="Primary priority (default)"
|
|
190
|
+
media={MEDIA.avatarSingle}
|
|
191
|
+
control={<ListItem.IconButton {...args} priority="primary" />}
|
|
192
|
+
/>
|
|
193
|
+
<ListItem
|
|
194
|
+
title="Secondary Priority"
|
|
195
|
+
subtitle="Secondary priority"
|
|
196
|
+
media={MEDIA.avatarSingle}
|
|
197
|
+
control={<ListItem.IconButton {...args} priority="secondary" />}
|
|
198
|
+
/>
|
|
199
|
+
<ListItem
|
|
200
|
+
title="Secondary Neutral Priority"
|
|
201
|
+
subtitle="Secondary neutral priority"
|
|
202
|
+
media={MEDIA.avatarSingle}
|
|
203
|
+
control={<ListItem.IconButton {...args} priority="tertiary" />}
|
|
204
|
+
/>
|
|
205
|
+
<ListItem
|
|
206
|
+
title="Tertiary Priority"
|
|
207
|
+
subtitle="Tertiary priority"
|
|
208
|
+
media={MEDIA.avatarSingle}
|
|
209
|
+
control={<ListItem.IconButton {...args} priority="minimal" />}
|
|
210
|
+
/>
|
|
211
|
+
</ol>
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* If `href` prop is set, the component will be automatically rendered as an HTML anchor element.
|
|
218
|
+
*/
|
|
219
|
+
export const AsAnchor: Story = {
|
|
220
|
+
args: {
|
|
221
|
+
children: <Edit />,
|
|
222
|
+
href: 'https://wise.com',
|
|
223
|
+
target: '_blank',
|
|
224
|
+
onClick: undefined,
|
|
225
|
+
},
|
|
226
|
+
render: (args: ListItemIconButtonProps) => {
|
|
227
|
+
return (
|
|
228
|
+
<ListItem
|
|
229
|
+
control={<ListItem.IconButton {...args} />}
|
|
230
|
+
title="List item with icon button link"
|
|
231
|
+
subtitle="IconButton rendered as anchor element"
|
|
232
|
+
media={MEDIA.avatarSingle}
|
|
233
|
+
/>
|
|
234
|
+
);
|
|
235
|
+
},
|
|
236
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { useContext, type ReactNode } from 'react';
|
|
3
|
+
import IconButtonComp, { type IconButtonProps } from '../../iconButton';
|
|
4
|
+
import { useListItemControl } from '../useListItemControl';
|
|
5
|
+
import { ListItemContext } from '../ListItemContext';
|
|
6
|
+
|
|
7
|
+
export type ListItemIconButtonProps = Pick<
|
|
8
|
+
IconButtonProps,
|
|
9
|
+
'priority' | 'type' | 'onClick' | 'href' | 'target' | 'aria-label'
|
|
10
|
+
> & {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
partiallyInteractive?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This component allows for rendering a IconButton control. It's a thin wrapper around the
|
|
17
|
+
* [IconButton component](https://storybook.wise.design/?path=/docs/actions-iconbutton--docs), but offers only
|
|
18
|
+
* a subset of its features in line with the ListItem's constraints. <br />
|
|
19
|
+
* <br />
|
|
20
|
+
* Please refer to the [Design documentation](https://wise.design/components/list-item---icon-button) for details.
|
|
21
|
+
*/
|
|
22
|
+
export const IconButton = function ({ priority = 'minimal', ...props }: ListItemIconButtonProps) {
|
|
23
|
+
const { partiallyInteractive, ...restProps } = props;
|
|
24
|
+
|
|
25
|
+
const { ids, props: itemProps } = useContext(ListItemContext);
|
|
26
|
+
const { baseItemProps } = useListItemControl('icon-button', {
|
|
27
|
+
partiallyInteractive,
|
|
28
|
+
...restProps,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const descriptorIds = [
|
|
32
|
+
itemProps.inverted ? ids.subtitle : ids.title,
|
|
33
|
+
itemProps.inverted ? ids.title : ids.subtitle,
|
|
34
|
+
itemProps.inverted ? ids.valueSubtitle : ids.valueTitle,
|
|
35
|
+
itemProps.inverted ? ids.valueTitle : ids.valueSubtitle,
|
|
36
|
+
ids.additionalInfo,
|
|
37
|
+
ids.prompt,
|
|
38
|
+
].join(' ');
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<IconButtonComp
|
|
42
|
+
{...restProps}
|
|
43
|
+
aria-describedby={descriptorIds}
|
|
44
|
+
className={clsx(
|
|
45
|
+
'wds-list-item-control',
|
|
46
|
+
!partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element',
|
|
47
|
+
)}
|
|
48
|
+
id={ids.control}
|
|
49
|
+
size={40}
|
|
50
|
+
priority={priority}
|
|
51
|
+
disabled={baseItemProps.disabled}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
IconButton.displayName = 'ListItem.IconButton';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { ListItem } from '../ListItem';
|
|
3
|
+
import {
|
|
4
|
+
SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
|
|
5
|
+
SB_LIST_ITEM_CONTROLS as CONTROLS,
|
|
6
|
+
} from '../_stories/subcomponents';
|
|
7
|
+
import { ListItemImageProps } from './ListItemImage';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: ListItem.Image,
|
|
11
|
+
title: 'Content/ListItem/ListItem.Image',
|
|
12
|
+
parameters: {
|
|
13
|
+
docs: {
|
|
14
|
+
toc: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
args: {
|
|
18
|
+
src: 'https://wise.com/public-resources/assets/spend/card-asset/medium/v2/personal_green_wise_2023_active.svg',
|
|
19
|
+
size: undefined,
|
|
20
|
+
loading: undefined,
|
|
21
|
+
alt: undefined,
|
|
22
|
+
},
|
|
23
|
+
} satisfies Meta<ListItemImageProps>;
|
|
24
|
+
|
|
25
|
+
type Story = StoryObj<ListItemImageProps>;
|
|
26
|
+
|
|
27
|
+
export const Playground: Story = {
|
|
28
|
+
render: (args: ListItemImageProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<ListItem
|
|
31
|
+
title="List item title"
|
|
32
|
+
subtitle="Subtitle goes here"
|
|
33
|
+
media={<ListItem.Image {...args} />}
|
|
34
|
+
control={CONTROLS.partialButton}
|
|
35
|
+
additionalInfo={INFO.nonInteractive}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import ImageComp, { type ImageProps } from '../../image';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
|
|
4
|
+
type SizeProp = {};
|
|
5
|
+
|
|
6
|
+
export type ListItemImageProps = Omit<ImageProps, 'stretch' | 'shrink' | 'id' | 'alt' | 'role'> & {
|
|
7
|
+
/**
|
|
8
|
+
* The size of square container for the image, matching available avatar sizes.
|
|
9
|
+
*/
|
|
10
|
+
size?: 32 | 40 | 48 | 56 | 72;
|
|
11
|
+
/**
|
|
12
|
+
* When unset, it will force `role="presentation"` on the image. Otherwise, it will set `role="graphics-symbol"`.
|
|
13
|
+
*/
|
|
14
|
+
alt?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This component should be used as a last resort, for rare cases when `<ListItem.AvatarView />`
|
|
19
|
+
* or `<ListItem.AvatarLayout />` are insufficient.
|
|
20
|
+
* It's a wrapper around the
|
|
21
|
+
* [Image component](https://storybook.wise.design/?path=/docs/content-image--docs), but offers only
|
|
22
|
+
* a subset of its props, in line with the ListItem's constraints.
|
|
23
|
+
*
|
|
24
|
+
* > **NB**: This component is [not intended for use with illustrations](https://wise.design/foundations/illustration#scale).
|
|
25
|
+
*/
|
|
26
|
+
export const Image = ({ alt = '', size = 48, ...props }: ListItemImageProps) => {
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
className={clsx('wds-list-item-media-image')}
|
|
30
|
+
style={
|
|
31
|
+
{
|
|
32
|
+
'--item-media-image-size': `${size}px`,
|
|
33
|
+
} as React.CSSProperties
|
|
34
|
+
}
|
|
35
|
+
>
|
|
36
|
+
<ImageComp {...props} alt={alt} role={alt ? 'graphics-symbol' : 'presentation'} />
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
Image.displayName = 'ListItem.Image';
|