@transferwise/components 0.0.0-experimental-7646a35 → 0.0.0-experimental-32aec6a
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/dateInput/DateInput.js +1 -1
- package/build/dateInput/DateInput.js.map +1 -1
- package/build/dateInput/DateInput.mjs +1 -1
- package/build/dateInput/DateInput.mjs.map +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -1
- package/build/main.css +8 -189
- package/build/styles/dateInput/DateInput.css +8 -1
- package/build/styles/main.css +8 -189
- package/build/types/index.d.ts +0 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/test-utils/fake-data.d.ts +0 -2
- package/build/types/test-utils/fake-data.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dateInput/DateInput.css +8 -1
- package/src/dateInput/DateInput.less +15 -3
- package/src/dateInput/DateInput.tsx +1 -1
- package/src/index.ts +0 -2
- package/src/legacylistItem/LegacyListItem.story.tsx +5 -5
- package/src/legacylistItem/LegacyListItem.tests.story.tsx +6 -6
- package/src/main.css +8 -189
- package/src/main.less +0 -1
- package/src/test-utils/fake-data.ts +0 -5
- package/build/styles/listItem/ListItem.css +0 -188
- package/build/test-utils/assets/apple-pay-logo.svg +0 -84
- package/build/types/listItem/ListItem.d.ts +0 -44
- package/build/types/listItem/ListItem.d.ts.map +0 -1
- package/build/types/listItem/ListItemAdditionalInfo.d.ts +0 -9
- package/build/types/listItem/ListItemAdditionalInfo.d.ts.map +0 -1
- package/build/types/listItem/ListItemButton.d.ts +0 -4
- package/build/types/listItem/ListItemButton.d.ts.map +0 -1
- package/build/types/listItem/ListItemCheckbox.d.ts +0 -4
- package/build/types/listItem/ListItemCheckbox.d.ts.map +0 -1
- package/build/types/listItem/ListItemIconButton.d.ts +0 -7
- package/build/types/listItem/ListItemIconButton.d.ts.map +0 -1
- package/build/types/listItem/ListItemMedia.d.ts +0 -19
- package/build/types/listItem/ListItemMedia.d.ts.map +0 -1
- package/build/types/listItem/ListItemNavigation.d.ts +0 -4
- package/build/types/listItem/ListItemNavigation.d.ts.map +0 -1
- package/build/types/listItem/ListItemSwitch.d.ts +0 -3
- package/build/types/listItem/ListItemSwitch.d.ts.map +0 -1
- package/build/types/listItem/index.d.ts +0 -6
- package/build/types/listItem/index.d.ts.map +0 -1
- package/build/types/listItem/prompt/Prompt.d.ts +0 -12
- package/build/types/listItem/prompt/Prompt.d.ts.map +0 -1
- package/build/types/listItem/useItemControl.d.ts +0 -5
- package/build/types/listItem/useItemControl.d.ts.map +0 -1
- package/src/listItem/ListItem.css +0 -188
- package/src/listItem/ListItem.less +0 -182
- package/src/listItem/ListItem.spec.tsx +0 -35
- package/src/listItem/ListItem.story.tsx +0 -296
- package/src/listItem/ListItem.tsx +0 -190
- package/src/listItem/ListItemAdditionalInfo.tsx +0 -31
- package/src/listItem/ListItemButton.spec.tsx +0 -90
- package/src/listItem/ListItemButton.tsx +0 -18
- package/src/listItem/ListItemCheckbox.tsx +0 -14
- package/src/listItem/ListItemIconButton.tsx +0 -13
- package/src/listItem/ListItemMedia.tsx +0 -52
- package/src/listItem/ListItemNavigation.tsx +0 -11
- package/src/listItem/ListItemSwitch.tsx +0 -8
- package/src/listItem/index.ts +0 -10
- package/src/listItem/prompt/Prompt.spec.tsx +0 -77
- package/src/listItem/prompt/Prompt.story.tsx +0 -170
- package/src/listItem/prompt/Prompt.tsx +0 -44
- package/src/listItem/useItemControl.tsx +0 -12
- package/src/test-utils/assets/apple-pay-logo.svg +0 -84
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
.wds-list-item {
|
|
2
|
-
padding: var(--size-16);
|
|
3
|
-
border-radius: var(--radius-large);
|
|
4
|
-
background-color: var(--color-background-screen);
|
|
5
|
-
gap: var(--size-16);
|
|
6
|
-
|
|
7
|
-
&-interactive {
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
&:hover {
|
|
10
|
-
background-color: var(--color-background-screen-hover);
|
|
11
|
-
}
|
|
12
|
-
&:active {
|
|
13
|
-
background-color: var(--color-background-screen-active);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&-media {
|
|
18
|
-
|
|
19
|
-
&-image {
|
|
20
|
-
width: var(--item-media-image-size);
|
|
21
|
-
height: var(--item-media-image-size);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&-body {
|
|
26
|
-
width: 100%;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&-title {
|
|
30
|
-
color: var(--color-content-primary);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&-additional-info {
|
|
34
|
-
color: var(--color-content-tertiary);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&-value {
|
|
38
|
-
flex: 0 0 auto;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&-control {
|
|
42
|
-
flex: 0 0 auto;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&-spotlight {
|
|
46
|
-
&-active {
|
|
47
|
-
background-color: var(--color-background-neutral);
|
|
48
|
-
|
|
49
|
-
&:hover {
|
|
50
|
-
background-color: var(--color-background-neutral-hover);
|
|
51
|
-
}
|
|
52
|
-
&:active {
|
|
53
|
-
background-color: var(--color-background-neutral-active);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&-inactive {
|
|
58
|
-
background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
|
|
59
|
-
border: 1px dashed var(--color-border-neutral);
|
|
60
|
-
|
|
61
|
-
&:hover {
|
|
62
|
-
background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
|
|
63
|
-
}
|
|
64
|
-
&:active {
|
|
65
|
-
background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
&-prompt {
|
|
71
|
-
display: inline-flex;
|
|
72
|
-
padding-top: calc(var(--padding-x-small) / 2);
|
|
73
|
-
padding-bottom: calc(var(--padding-x-small) / 2);
|
|
74
|
-
padding-left: calc(var(--padding-x-small) - 1px);
|
|
75
|
-
padding-right: var(--padding-x-small);
|
|
76
|
-
border-radius: var(--radius-small);
|
|
77
|
-
word-break: break-word;
|
|
78
|
-
overflow-wrap: break-word;
|
|
79
|
-
|
|
80
|
-
.np-prompt-icon {
|
|
81
|
-
padding-right: calc(var(--size-12) / 2);
|
|
82
|
-
padding-top: calc(var(--size-4) - 1px);
|
|
83
|
-
padding-bottom: calc(var(--size-4) - 1px);
|
|
84
|
-
|
|
85
|
-
.tw-icon-tags,
|
|
86
|
-
.tw-icon-confetti {
|
|
87
|
-
color: var(--color-sentiment-positive-primary);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
a {
|
|
92
|
-
text-underline-offset: calc(var(--size-4) / 2);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
&.np-prompt-interactive {
|
|
96
|
-
text-decoration: none;
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
border: none;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
&.negative {
|
|
102
|
-
background-color: var(--color-sentiment-negative-secondary);
|
|
103
|
-
color: var(--color-sentiment-negative-primary);
|
|
104
|
-
a {
|
|
105
|
-
color: var(--color-sentiment-negative-primary);
|
|
106
|
-
&:hover {
|
|
107
|
-
color: var(--color-sentiment-negative-primary-hover);
|
|
108
|
-
}
|
|
109
|
-
&:active {
|
|
110
|
-
color: var(--color-sentiment-negative-primary-active);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
.np-prompt-interactive& {
|
|
114
|
-
&:hover {
|
|
115
|
-
background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 95%, var(--color-sentiment-negative-primary));
|
|
116
|
-
}
|
|
117
|
-
&:active {
|
|
118
|
-
background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 90%, var(--color-sentiment-negative-primary));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
&.positive,
|
|
123
|
-
&.discount,
|
|
124
|
-
&.savings {
|
|
125
|
-
background-color: var(--color-sentiment-positive-secondary);
|
|
126
|
-
color: var(--color-sentiment-positive-primary);
|
|
127
|
-
a {
|
|
128
|
-
color: var(--color-sentiment-positive-primary);
|
|
129
|
-
&:hover {
|
|
130
|
-
color: var(--color-sentiment-positive-primary-hover);
|
|
131
|
-
}
|
|
132
|
-
&:active {
|
|
133
|
-
color: var(--color-sentiment-positive-primary-active);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
.np-prompt-interactive& {
|
|
137
|
-
&:hover {
|
|
138
|
-
background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 95%, var(--color-sentiment-positive-primary));
|
|
139
|
-
}
|
|
140
|
-
&:active {
|
|
141
|
-
background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 90%, var(--color-sentiment-positive-primary));
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
&.neutral {
|
|
146
|
-
background-color: var(--color-background-neutral);
|
|
147
|
-
color: var(--color-content-primary);
|
|
148
|
-
a {
|
|
149
|
-
color: var(--color-content-primary);
|
|
150
|
-
}
|
|
151
|
-
.np-prompt-interactive& {
|
|
152
|
-
&:hover {
|
|
153
|
-
background-color: var(--color-background-neutral-hover);
|
|
154
|
-
}
|
|
155
|
-
&:active {
|
|
156
|
-
background-color: var(--color-background-neutral-active);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
&.warning {
|
|
161
|
-
background-color: var(--color-sentiment-warning-secondary);
|
|
162
|
-
color: var(--color-sentiment-warning-content);
|
|
163
|
-
a {
|
|
164
|
-
color: var(--color-sentiment-warning-content);
|
|
165
|
-
&:hover {
|
|
166
|
-
color: var(--color-sentiment-warning-content-hover);
|
|
167
|
-
}
|
|
168
|
-
&:active {
|
|
169
|
-
color: var(--color-sentiment-warning-content-active);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
.np-prompt-interactive& {
|
|
173
|
-
&:hover {
|
|
174
|
-
background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 90%, var(--color-sentiment-warning-primary));
|
|
175
|
-
}
|
|
176
|
-
&:active {
|
|
177
|
-
background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 80%, var(--color-sentiment-warning-primary));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '../test-utils';
|
|
2
|
-
import ListItem from './ListItem';
|
|
3
|
-
|
|
4
|
-
describe('ListItem', () => {
|
|
5
|
-
describe('spotlight', () => {
|
|
6
|
-
it('only fully interactive variant can have spotlight:active', () => {
|
|
7
|
-
render(<ListItem title="Test Title" spotlight="active" control={<ListItem.Navigation />} />);
|
|
8
|
-
const listItem = screen.getByRole('listitem');
|
|
9
|
-
expect(listItem).toHaveClass('wds-list-item-interactive');
|
|
10
|
-
expect(listItem).toHaveClass('wds-list-item-spotlight-active');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('only fully interactive variant can have spotlight:inactive', () => {
|
|
14
|
-
render(
|
|
15
|
-
<ListItem
|
|
16
|
-
title="Test Title"
|
|
17
|
-
spotlight="inactive"
|
|
18
|
-
control={<ListItem.Switch onClick={() => {}} />}
|
|
19
|
-
/>,
|
|
20
|
-
);
|
|
21
|
-
const listItem = screen.getByRole('listitem');
|
|
22
|
-
expect(listItem).toHaveClass('wds-list-item-interactive');
|
|
23
|
-
expect(listItem).toHaveClass('wds-list-item-spotlight-inactive');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('non interactive variant can have spotlight', () => {
|
|
27
|
-
render(<ListItem title="Test Title" spotlight="inactive" />);
|
|
28
|
-
const listItem = screen.getByRole('listitem');
|
|
29
|
-
expect(listItem).toHaveClass('wds-list-item-non-interactive');
|
|
30
|
-
expect(listItem).not.toHaveClass('wds-list-item-interactive');
|
|
31
|
-
expect(listItem).not.toHaveClass('wds-list-item-spotlight-inactive');
|
|
32
|
-
expect(listItem).not.toHaveClass('wds-list-item-spotlight-active');
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import ListItem, { Props as ItemProps } from './ListItem';
|
|
2
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
Bank,
|
|
6
|
-
BankTransfer,
|
|
7
|
-
FastFlag,
|
|
8
|
-
MultiCurrency,
|
|
9
|
-
Plus,
|
|
10
|
-
Receipt,
|
|
11
|
-
Savings,
|
|
12
|
-
} from '@transferwise/icons';
|
|
13
|
-
|
|
14
|
-
import { lorem10, lorem20, lorem40, lorem5 } from '../test-utils';
|
|
15
|
-
import { Flag } from '@wise/art';
|
|
16
|
-
import { List } from '../legacylistItem/List';
|
|
17
|
-
import Money from '../money';
|
|
18
|
-
import Section from '../section';
|
|
19
|
-
import Header from '../header';
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
component: ListItem,
|
|
23
|
-
title: 'Content/ListItem',
|
|
24
|
-
} satisfies Meta<ItemProps>;
|
|
25
|
-
|
|
26
|
-
type Story = StoryObj<ItemProps>;
|
|
27
|
-
|
|
28
|
-
// TODO: delete this story later when we have more peace of the List Item puzzle
|
|
29
|
-
export const TempPlayground: Story = {
|
|
30
|
-
render: () => {
|
|
31
|
-
const [checked, setChecked] = useState(false);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div>
|
|
35
|
-
<ListItem
|
|
36
|
-
media={
|
|
37
|
-
<ListItem.AvatarView badge={{ type: 'action' }}>
|
|
38
|
-
<Flag code="BBD" />
|
|
39
|
-
</ListItem.AvatarView>
|
|
40
|
-
}
|
|
41
|
-
title="Test title"
|
|
42
|
-
subtitle="Test subtitle"
|
|
43
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem10}</ListItem.AdditionalInfo>}
|
|
44
|
-
/>
|
|
45
|
-
<ListItem
|
|
46
|
-
media={
|
|
47
|
-
<ListItem.AvatarLayout
|
|
48
|
-
avatars={[{ asset: <Flag code="BBD" /> }, { asset: <Flag code="MXN" /> }]}
|
|
49
|
-
/>
|
|
50
|
-
}
|
|
51
|
-
title="Test title"
|
|
52
|
-
subtitle={lorem10}
|
|
53
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
54
|
-
/>
|
|
55
|
-
<ListItem
|
|
56
|
-
media={
|
|
57
|
-
<ListItem.AvatarLayout
|
|
58
|
-
size={72}
|
|
59
|
-
orientation="diagonal"
|
|
60
|
-
avatars={[{ asset: <Flag code="BBD" /> }, { asset: <Flag code="MXN" /> }]}
|
|
61
|
-
/>
|
|
62
|
-
}
|
|
63
|
-
title="Test title"
|
|
64
|
-
subtitle={lorem10}
|
|
65
|
-
valueTitle="100 GBP"
|
|
66
|
-
valueSubtitle="100 USD"
|
|
67
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
68
|
-
/>
|
|
69
|
-
<ListItem
|
|
70
|
-
media={<ListItem.AvatarView profileType="BUSINESS" notification />}
|
|
71
|
-
title="Test title"
|
|
72
|
-
subtitle="Test subtitle"
|
|
73
|
-
additionalInfo={
|
|
74
|
-
<ListItem.AdditionalInfo
|
|
75
|
-
action={{ label: 'Learn more', href: 'https://wise.com', target: '_blank' }}
|
|
76
|
-
>
|
|
77
|
-
{lorem10}
|
|
78
|
-
</ListItem.AdditionalInfo>
|
|
79
|
-
}
|
|
80
|
-
prompt={<ListItem.Prompt type="negative">You have done something wrong</ListItem.Prompt>}
|
|
81
|
-
/>
|
|
82
|
-
<ListItem
|
|
83
|
-
media={<ListItem.AvatarView imgSrc="../avatar-square-dude.webp" selected />}
|
|
84
|
-
title="Test title"
|
|
85
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem10}</ListItem.AdditionalInfo>}
|
|
86
|
-
prompt={
|
|
87
|
-
<ListItem.Prompt
|
|
88
|
-
type="discount"
|
|
89
|
-
action={{
|
|
90
|
-
href: 'https://wise.com',
|
|
91
|
-
target: '_blank',
|
|
92
|
-
'aria-label': 'clickable prompt',
|
|
93
|
-
}}
|
|
94
|
-
>
|
|
95
|
-
The whole prompt is secretly clickable
|
|
96
|
-
</ListItem.Prompt>
|
|
97
|
-
}
|
|
98
|
-
/>
|
|
99
|
-
|
|
100
|
-
<ListItem
|
|
101
|
-
media={<ListItem.Image src="../apple-pay-logo.svg" />}
|
|
102
|
-
title="Accepting Apple Pay"
|
|
103
|
-
subtitle={lorem10}
|
|
104
|
-
/>
|
|
105
|
-
|
|
106
|
-
<ListItem
|
|
107
|
-
media={<ListItem.Image src="../wise-card.svg" />}
|
|
108
|
-
title="Wise Business Card"
|
|
109
|
-
subtitle={lorem5}
|
|
110
|
-
/>
|
|
111
|
-
|
|
112
|
-
<ListItem
|
|
113
|
-
title="Test title"
|
|
114
|
-
disabled
|
|
115
|
-
subtitle={lorem10}
|
|
116
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
117
|
-
control={<ListItem.Button priority="secondary-neutral">as Button</ListItem.Button>}
|
|
118
|
-
/>
|
|
119
|
-
<ListItem
|
|
120
|
-
title="Test title"
|
|
121
|
-
disabled
|
|
122
|
-
subtitle={lorem10}
|
|
123
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
124
|
-
control={
|
|
125
|
-
<ListItem.IconButton>
|
|
126
|
-
<Plus />
|
|
127
|
-
</ListItem.IconButton>
|
|
128
|
-
}
|
|
129
|
-
/>
|
|
130
|
-
|
|
131
|
-
<ListItem
|
|
132
|
-
title="Test title"
|
|
133
|
-
subtitle={lorem10}
|
|
134
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
135
|
-
control={
|
|
136
|
-
<ListItem.Button
|
|
137
|
-
priority="secondary-neutral"
|
|
138
|
-
as="a"
|
|
139
|
-
target="dfdf"
|
|
140
|
-
aria-label="adsfasfd"
|
|
141
|
-
href="wise.com"
|
|
142
|
-
>
|
|
143
|
-
as Link
|
|
144
|
-
</ListItem.Button>
|
|
145
|
-
}
|
|
146
|
-
/>
|
|
147
|
-
|
|
148
|
-
<ListItem
|
|
149
|
-
media={
|
|
150
|
-
<ListItem.AvatarView>
|
|
151
|
-
<Bank />
|
|
152
|
-
</ListItem.AvatarView>
|
|
153
|
-
}
|
|
154
|
-
spotlight="inactive"
|
|
155
|
-
title="Test title"
|
|
156
|
-
subtitle={lorem5}
|
|
157
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem10}</ListItem.AdditionalInfo>}
|
|
158
|
-
control={<ListItem.Checkbox indeterminate />}
|
|
159
|
-
className="m-t-2"
|
|
160
|
-
/>
|
|
161
|
-
|
|
162
|
-
<ListItem
|
|
163
|
-
media={
|
|
164
|
-
<ListItem.AvatarLayout
|
|
165
|
-
orientation="diagonal"
|
|
166
|
-
avatars={[{ asset: <BankTransfer /> }, { asset: <Bank /> }]}
|
|
167
|
-
/>
|
|
168
|
-
}
|
|
169
|
-
spotlight="active"
|
|
170
|
-
title="Test title"
|
|
171
|
-
subtitle={lorem5}
|
|
172
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem10}</ListItem.AdditionalInfo>}
|
|
173
|
-
control={
|
|
174
|
-
<ListItem.Switch
|
|
175
|
-
checked={checked}
|
|
176
|
-
onClick={() => {
|
|
177
|
-
setChecked(!checked);
|
|
178
|
-
}}
|
|
179
|
-
/>
|
|
180
|
-
}
|
|
181
|
-
className="m-t-2 m-b-4"
|
|
182
|
-
/>
|
|
183
|
-
</div>
|
|
184
|
-
);
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export const Radio: Story = {
|
|
189
|
-
render: () => (
|
|
190
|
-
<div>
|
|
191
|
-
{/* Basic */}
|
|
192
|
-
{/* with additional info */}
|
|
193
|
-
{/* with prompt */}
|
|
194
|
-
{/* Disabled */}
|
|
195
|
-
{/* Spotlight */}
|
|
196
|
-
{/* Active */}
|
|
197
|
-
</div>
|
|
198
|
-
),
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export const Button: Story = {
|
|
202
|
-
render: () => (
|
|
203
|
-
<div>
|
|
204
|
-
{/* Basic */}
|
|
205
|
-
{/* with additional info */}
|
|
206
|
-
{/* with prompt */}
|
|
207
|
-
{/* partially interactive */}
|
|
208
|
-
{/* Disabled */}
|
|
209
|
-
{/* Spotlight */}
|
|
210
|
-
{/* Active */}
|
|
211
|
-
</div>
|
|
212
|
-
),
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
export const NonInteractive: Story = {
|
|
216
|
-
render: () => (
|
|
217
|
-
<div>
|
|
218
|
-
<Section>
|
|
219
|
-
<Header title="Transcation Details" />
|
|
220
|
-
<List>
|
|
221
|
-
<ListItem
|
|
222
|
-
media={
|
|
223
|
-
<ListItem.AvatarView>
|
|
224
|
-
<MultiCurrency />
|
|
225
|
-
</ListItem.AvatarView>
|
|
226
|
-
}
|
|
227
|
-
title="Estimated costs"
|
|
228
|
-
subtitle="Other providers"
|
|
229
|
-
valueTitle={<Money amount={100} currency="GBP" />}
|
|
230
|
-
/>
|
|
231
|
-
<ListItem
|
|
232
|
-
media={
|
|
233
|
-
<ListItem.AvatarView>
|
|
234
|
-
<FastFlag />
|
|
235
|
-
</ListItem.AvatarView>
|
|
236
|
-
}
|
|
237
|
-
title="Total paid"
|
|
238
|
-
subtitle="Wise"
|
|
239
|
-
valueTitle={<Money amount={12.15} currency="GBP" />}
|
|
240
|
-
valueSubtitle={<Money amount={100.9} currency="GBP" />}
|
|
241
|
-
/>
|
|
242
|
-
<ListItem
|
|
243
|
-
media={
|
|
244
|
-
<ListItem.AvatarView>
|
|
245
|
-
<Receipt />
|
|
246
|
-
</ListItem.AvatarView>
|
|
247
|
-
}
|
|
248
|
-
title="Total fees"
|
|
249
|
-
subtitle={lorem5}
|
|
250
|
-
valueSubtitle={<Money amount={5.5} currency="GBP" />}
|
|
251
|
-
/>
|
|
252
|
-
<ListItem
|
|
253
|
-
media={
|
|
254
|
-
<ListItem.AvatarView>
|
|
255
|
-
<Savings />
|
|
256
|
-
</ListItem.AvatarView>
|
|
257
|
-
}
|
|
258
|
-
title="You saved"
|
|
259
|
-
valueSubtitle={<Money amount={1000} currency="GBP" />}
|
|
260
|
-
/>
|
|
261
|
-
</List>
|
|
262
|
-
</Section>
|
|
263
|
-
|
|
264
|
-
<ListItem
|
|
265
|
-
as="div"
|
|
266
|
-
title="Bank name and address"
|
|
267
|
-
subtitle="Bank Ltd, 2 Street Boulevard, Singapore, 1213423"
|
|
268
|
-
additionalInfo={
|
|
269
|
-
<ListItem.AdditionalInfo
|
|
270
|
-
action={{ label: 'Learn more', href: 'https://wise.com', target: '_blank' }}
|
|
271
|
-
>
|
|
272
|
-
This is our partner bank in Singapore.
|
|
273
|
-
</ListItem.AdditionalInfo>
|
|
274
|
-
}
|
|
275
|
-
/>
|
|
276
|
-
<ListItem
|
|
277
|
-
as="div"
|
|
278
|
-
title="Bank name and address"
|
|
279
|
-
subtitle="Capital Ltd, 2 Canal Street, London, E14 111"
|
|
280
|
-
additionalInfo={
|
|
281
|
-
<ListItem.AdditionalInfo
|
|
282
|
-
action={{ label: 'Learn more', href: 'https://wise.com', target: '_blank' }}
|
|
283
|
-
/>
|
|
284
|
-
}
|
|
285
|
-
/>
|
|
286
|
-
{/* Basic */}
|
|
287
|
-
{/* with additional info */}
|
|
288
|
-
{/* with prompt */}
|
|
289
|
-
{/* Disabled */}
|
|
290
|
-
{/* Spotlight */}
|
|
291
|
-
{/* Active */}
|
|
292
|
-
</div>
|
|
293
|
-
),
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
// add intaces with dark mode
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { createContext, ReactNode, useId, useMemo, useState } from 'react';
|
|
2
|
-
import { Typography } from '../common';
|
|
3
|
-
import Body from '../body';
|
|
4
|
-
import { AdditionalInfo } from './ListItemAdditionalInfo';
|
|
5
|
-
import { IconButton } from './ListItemIconButton';
|
|
6
|
-
import { Checkbox } from './ListItemCheckbox';
|
|
7
|
-
import { Navigation } from './ListItemNavigation';
|
|
8
|
-
import { clsx } from 'clsx';
|
|
9
|
-
import { Button } from './ListItemButton';
|
|
10
|
-
import { Switch } from './ListItemSwitch';
|
|
11
|
-
import { AvatarLayout, AvatarView, Image } from './ListItemMedia';
|
|
12
|
-
import Prompt from './prompt/Prompt';
|
|
13
|
-
|
|
14
|
-
export type ListItemTypes =
|
|
15
|
-
| 'non-interactive'
|
|
16
|
-
| 'navigation'
|
|
17
|
-
| 'radio'
|
|
18
|
-
| 'checkbox'
|
|
19
|
-
| 'switch'
|
|
20
|
-
| 'button'
|
|
21
|
-
| 'icon-button';
|
|
22
|
-
|
|
23
|
-
export type Props = {
|
|
24
|
-
as?: 'li' | 'div' | 'span';
|
|
25
|
-
inverted?: boolean;
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
spotlight?: 'active' | 'inactive';
|
|
28
|
-
title: ReactNode;
|
|
29
|
-
subtitle?: ReactNode;
|
|
30
|
-
additionalInfo?: ReactNode;
|
|
31
|
-
valueTitle?: ReactNode;
|
|
32
|
-
valueSubtitle?: ReactNode;
|
|
33
|
-
media?: ReactNode;
|
|
34
|
-
control?: ReactNode;
|
|
35
|
-
prompt?: ReactNode;
|
|
36
|
-
className?: string;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type ListItemContextData = {
|
|
40
|
-
setControlType: (type: ListItemTypes) => void;
|
|
41
|
-
ids: {
|
|
42
|
-
label: string;
|
|
43
|
-
additionalInfo: string;
|
|
44
|
-
value: string;
|
|
45
|
-
control: string;
|
|
46
|
-
prompt: string;
|
|
47
|
-
};
|
|
48
|
-
props: Pick<Props, 'as' | 'disabled' | 'inverted'>;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// @ts-expect-error for now let's mock it with `null` value
|
|
52
|
-
// but actually by default we should specify `setControlType('none')`
|
|
53
|
-
export const ListItemContext = createContext<ListItemContextData>(null);
|
|
54
|
-
|
|
55
|
-
export const ListItem = ({
|
|
56
|
-
as: View = 'li',
|
|
57
|
-
title,
|
|
58
|
-
subtitle,
|
|
59
|
-
additionalInfo,
|
|
60
|
-
prompt,
|
|
61
|
-
inverted,
|
|
62
|
-
media,
|
|
63
|
-
spotlight = undefined,
|
|
64
|
-
valueTitle,
|
|
65
|
-
valueSubtitle,
|
|
66
|
-
control = null,
|
|
67
|
-
disabled,
|
|
68
|
-
className,
|
|
69
|
-
}: Props) => {
|
|
70
|
-
/*
|
|
71
|
-
const returnType = (): ReactNode => {
|
|
72
|
-
switch (type) {
|
|
73
|
-
case 'Navigation':
|
|
74
|
-
return <Chevron orientation={Position.RIGHT} disabled />;
|
|
75
|
-
case 'Radio':
|
|
76
|
-
return <RadioButton name="Hello" checked />;
|
|
77
|
-
case 'Checkbox':
|
|
78
|
-
return <CheckboxButton name="Hello" checked />;
|
|
79
|
-
case 'Switch':
|
|
80
|
-
return <Switch onClick={() => console.log('clicked')} />;
|
|
81
|
-
case 'Button':
|
|
82
|
-
return <Button v2>Hello</Button>;
|
|
83
|
-
case 'IconButton':
|
|
84
|
-
return (
|
|
85
|
-
<IconButton size={40} priority="minimal">
|
|
86
|
-
<InfoCircle />
|
|
87
|
-
</IconButton>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
*/
|
|
92
|
-
const idPrefix = useId();
|
|
93
|
-
|
|
94
|
-
const [controlType, setControlType] = useState<ListItemTypes>('non-interactive');
|
|
95
|
-
const ids = {
|
|
96
|
-
label: `${idPrefix}_label`,
|
|
97
|
-
value: `${idPrefix}_value`,
|
|
98
|
-
control: `${idPrefix}_control`,
|
|
99
|
-
prompt: `${idPrefix}_prompt`,
|
|
100
|
-
additionalInfo: `${idPrefix}_additional-info`,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// TODO: add partially interactive check from Button and IconButtons
|
|
104
|
-
// (https://transferwise.atlassian.net/browse/DS-7562)
|
|
105
|
-
const isFullyInteractive = controlType !== 'non-interactive';
|
|
106
|
-
|
|
107
|
-
const listItemContext = useMemo(
|
|
108
|
-
() => ({ setControlType, ids, props: { as: View, disabled, inverted } }),
|
|
109
|
-
[],
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<ListItemContext.Provider value={listItemContext}>
|
|
114
|
-
<View
|
|
115
|
-
className={clsx(
|
|
116
|
-
'wds-list-item',
|
|
117
|
-
{ 'wds-list-item-interactive': controlType !== 'non-interactive' },
|
|
118
|
-
`wds-list-item-${controlType}`,
|
|
119
|
-
'd-flex flex-row',
|
|
120
|
-
{ 'align-items-center': !subtitle },
|
|
121
|
-
{
|
|
122
|
-
[`wds-list-item-spotlight-${spotlight}`]: isFullyInteractive && !!spotlight,
|
|
123
|
-
},
|
|
124
|
-
className,
|
|
125
|
-
)}
|
|
126
|
-
aria-describedby={[ids.additionalInfo].join(' ')}
|
|
127
|
-
>
|
|
128
|
-
{media && <div className="wds-list-item-media">{media}</div>}
|
|
129
|
-
|
|
130
|
-
{/* Title + Subtitle + Values + Additional Info - Group */}
|
|
131
|
-
<div className="wds-list-item-body">
|
|
132
|
-
{/* Title + Subtitle + Values - Group */}
|
|
133
|
-
<div className="d-flex justify-content-between">
|
|
134
|
-
<span>
|
|
135
|
-
{/* @ts-expect-error div can have role and aria-lavel props */}
|
|
136
|
-
<Body
|
|
137
|
-
type={Typography.BODY_LARGE_BOLD}
|
|
138
|
-
className="wds-list-item-title"
|
|
139
|
-
// for a11y this needs to be a header but for SEO it shouldn't be `h*` tag
|
|
140
|
-
// so we enable header semantics via `role` and `aria-level` attrs
|
|
141
|
-
role="heading"
|
|
142
|
-
aria-level="4"
|
|
143
|
-
>
|
|
144
|
-
{title}
|
|
145
|
-
</Body>
|
|
146
|
-
<Body className="wds-list-item-subtitle">{subtitle}</Body>
|
|
147
|
-
</span>
|
|
148
|
-
{(valueTitle || valueSubtitle) && (
|
|
149
|
-
<span
|
|
150
|
-
id={ids.value}
|
|
151
|
-
className={clsx('wds-list-item-value', 'd-flex align-items-center', {
|
|
152
|
-
'flex-column': valueTitle !== undefined && valueSubtitle !== undefined,
|
|
153
|
-
})}
|
|
154
|
-
>
|
|
155
|
-
{valueTitle && (
|
|
156
|
-
<Body type={Typography.BODY_LARGE_BOLD} className="wds-list-item-title-value">
|
|
157
|
-
{valueTitle}
|
|
158
|
-
</Body>
|
|
159
|
-
)}
|
|
160
|
-
{valueSubtitle && (
|
|
161
|
-
<Body className="wds-list-item-subtitle-value">{valueSubtitle}</Body>
|
|
162
|
-
)}
|
|
163
|
-
</span>
|
|
164
|
-
)}
|
|
165
|
-
</div>
|
|
166
|
-
|
|
167
|
-
{/* Additional Info and Prompt here */}
|
|
168
|
-
{Boolean(subtitle) && additionalInfo}
|
|
169
|
-
</div>
|
|
170
|
-
{control === null ? null : <Body className="wds-list-item-control">{control}</Body>}
|
|
171
|
-
{prompt}
|
|
172
|
-
</View>
|
|
173
|
-
</ListItemContext.Provider>
|
|
174
|
-
);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/* eslint-disable functional/immutable-data */
|
|
178
|
-
ListItem.Image = Image;
|
|
179
|
-
ListItem.AvatarView = AvatarView;
|
|
180
|
-
ListItem.AvatarLayout = AvatarLayout;
|
|
181
|
-
ListItem.AdditionalInfo = AdditionalInfo;
|
|
182
|
-
ListItem.Checkbox = Checkbox;
|
|
183
|
-
ListItem.IconButton = IconButton;
|
|
184
|
-
ListItem.Navigation = Navigation;
|
|
185
|
-
ListItem.Button = Button;
|
|
186
|
-
ListItem.Switch = Switch;
|
|
187
|
-
ListItem.Prompt = Prompt;
|
|
188
|
-
/* eslint-enable functional/immutable-data */
|
|
189
|
-
|
|
190
|
-
export default ListItem;
|