@transferwise/components 0.0.0-experimental-a8f3db2 → 0.0.0-experimental-8abc58f
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/main.css +11 -15
- package/build/styles/main.css +11 -15
- package/build/styles/switch/Switch.css +22 -41
- package/build/styles/switchOption/SwitchOption.css +4 -0
- package/build/switch/Switch.js +7 -18
- package/build/switch/Switch.js.map +1 -1
- package/build/switch/Switch.mjs +8 -19
- package/build/switch/Switch.mjs.map +1 -1
- package/build/switchOption/SwitchOption.js +1 -0
- package/build/switchOption/SwitchOption.js.map +1 -1
- package/build/switchOption/SwitchOption.mjs +1 -0
- package/build/switchOption/SwitchOption.mjs.map +1 -1
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/build/types/switchOption/SwitchOption.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/accordion/Accordion.story.tsx +31 -21
- package/src/avatarView/AvatarView.story.tsx +1 -6
- package/src/carousel/Carousel.story.tsx +1 -0
- package/src/common/bottomSheet/BottomSheet.story.tsx +5 -4
- package/src/common/circle/Circle.story.tsx +1 -0
- package/src/dateLookup/DateLookup.story.tsx +1 -0
- package/src/decision/Decision.story.tsx +1 -0
- package/src/definitionList/DefinitionList.story.tsx +1 -0
- package/src/dimmer/Dimmer.story.tsx +1 -0
- package/src/display/Display.story.tsx +1 -0
- package/src/drawer/Drawer.story.tsx +1 -0
- package/src/dropFade/DropFade.story.tsx +1 -0
- package/src/flowNavigation/FlowNavigation.story.tsx +1 -0
- package/src/header/Header.story.tsx +1 -0
- package/src/iconButton/IconButton.story.tsx +1 -0
- package/src/image/Image.story.tsx +1 -0
- package/src/info/Info.story.tsx +1 -0
- package/src/inlineAlert/InlineAlert.story.tsx +1 -0
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +1 -0
- package/src/inputs/InputGroup.story.tsx +1 -0
- package/src/inputs/SearchInput.story.tsx +1 -0
- package/src/legacylistItem/LegacyListItem.tests.story.tsx +1 -0
- package/src/link/Link.story.tsx +1 -0
- package/src/main.css +11 -15
- package/src/main.less +1 -0
- package/src/modal/Modal.story.tsx +11 -6
- package/src/money/Money.story.tsx +1 -0
- package/src/navigationOptionsList/NavigationOptionsList.story.tsx +1 -0
- package/src/nudge/Nudge.story.tsx +1 -0
- package/src/overlayHeader/OverlayHeader.story.tsx +1 -0
- package/src/progress/Progress.story.tsx +1 -0
- package/src/provider/Provider.story.tsx +1 -0
- package/src/radio/Radio.story.tsx +1 -0
- package/src/radioGroup/RadioGroup.story.tsx +1 -0
- package/src/radioOption/RadioOption.story.tsx +1 -0
- package/src/section/Section.story.tsx +1 -0
- package/src/segmentedControl/SegmentedControl.story.tsx +1 -0
- package/src/select/Select.story.tsx +1 -0
- package/src/slidingPanel/SlidingPanel.story.tsx +1 -0
- package/src/snackbar/Snackbar.story.tsx +1 -0
- package/src/summary/Summary.story.tsx +1 -0
- package/src/switch/Switch.css +22 -41
- package/src/switch/Switch.less +6 -12
- package/src/switch/Switch.spec.tsx +11 -9
- package/src/switch/Switch.story.tsx +158 -33
- package/src/switch/Switch.tsx +6 -15
- package/src/switchOption/SwitchOption.css +4 -0
- package/src/switchOption/SwitchOption.less +8 -0
- package/src/switchOption/SwitchOption.spec.tsx +4 -5
- package/src/switchOption/SwitchOption.story.tsx +42 -38
- package/src/switchOption/SwitchOption.tsx +1 -0
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +1 -0
- package/src/tile/Tile.story.tsx +1 -0
- package/src/title/Title.story.tsx +1 -0
- package/src/typeahead/Typeahead.story.tsx +1 -0
- package/src/switch/__snapshots__/Switch.spec.tsx.snap +0 -44
package/src/info/Info.story.tsx
CHANGED
package/src/link/Link.story.tsx
CHANGED
package/src/main.css
CHANGED
|
@@ -5149,6 +5149,8 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5149
5149
|
margin-top: var(--size-24);
|
|
5150
5150
|
}
|
|
5151
5151
|
.np-switch {
|
|
5152
|
+
all: unset;
|
|
5153
|
+
box-sizing: border-box;
|
|
5152
5154
|
display: inline-flex;
|
|
5153
5155
|
overflow: hidden;
|
|
5154
5156
|
width: 50px;
|
|
@@ -5157,6 +5159,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5157
5159
|
-webkit-user-select: none;
|
|
5158
5160
|
-moz-user-select: none;
|
|
5159
5161
|
user-select: none;
|
|
5162
|
+
cursor: pointer;
|
|
5160
5163
|
}
|
|
5161
5164
|
.np-switch:focus {
|
|
5162
5165
|
outline: none;
|
|
@@ -5189,21 +5192,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5189
5192
|
[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
5190
5193
|
transform: translateX(-20px) ;
|
|
5191
5194
|
}
|
|
5192
|
-
.np-switch
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
width: 0;
|
|
5197
|
-
height: 0;
|
|
5198
|
-
opacity: 0;
|
|
5199
|
-
}
|
|
5200
|
-
[dir="rtl"] .np-switch input {
|
|
5201
|
-
right: -100%;
|
|
5202
|
-
left: auto;
|
|
5203
|
-
left: initial;
|
|
5204
|
-
}
|
|
5205
|
-
.np-switch:not([aria-disabled]) {
|
|
5206
|
-
cursor: pointer;
|
|
5195
|
+
.np-switch.disabled {
|
|
5196
|
+
filter: grayscale(1);
|
|
5197
|
+
opacity: 0.45;
|
|
5198
|
+
cursor: not-allowed !important;
|
|
5207
5199
|
}
|
|
5208
5200
|
.np-theme-personal .np-switch {
|
|
5209
5201
|
padding: 1px 2px;
|
|
@@ -5219,6 +5211,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5219
5211
|
background-color: #ffffff;
|
|
5220
5212
|
background-color: var(--color-background-screen);
|
|
5221
5213
|
}
|
|
5214
|
+
.np-switch-option.disabled .np-switch {
|
|
5215
|
+
filter: none;
|
|
5216
|
+
opacity: 1;
|
|
5217
|
+
}
|
|
5222
5218
|
.tabs {
|
|
5223
5219
|
position: relative;
|
|
5224
5220
|
}
|
package/src/main.less
CHANGED
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
@import "./segmentedControl/SegmentedControl.less";
|
|
66
66
|
@import "./summary/Summary.less";
|
|
67
67
|
@import "./switch/Switch.less";
|
|
68
|
+
@import "./switchOption/SwitchOption.less";
|
|
68
69
|
@import "./tabs/Tabs.less";
|
|
69
70
|
@import "./table/Table.less";
|
|
70
71
|
@import "./tile/Tile.less";
|
|
@@ -10,10 +10,11 @@ import { lorem10, lorem100, lorem1000, storyConfig } from '../test-utils';
|
|
|
10
10
|
export default {
|
|
11
11
|
component: Modal,
|
|
12
12
|
title: 'Dialogs/Modal',
|
|
13
|
+
tags: ['autodocs'],
|
|
13
14
|
args: {
|
|
14
15
|
size: 'md',
|
|
15
16
|
position: 'center',
|
|
16
|
-
open:
|
|
17
|
+
open: false,
|
|
17
18
|
},
|
|
18
19
|
parameters: {
|
|
19
20
|
chromatic: {
|
|
@@ -27,10 +28,11 @@ type Story = StoryObj<typeof Modal>;
|
|
|
27
28
|
export interface StoryContentProps {
|
|
28
29
|
args: CommonProps & ModalProps;
|
|
29
30
|
screenMode?: ScreenMode;
|
|
31
|
+
viewMode?: string;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
const StoryContent = ({ args, screenMode }: StoryContentProps) => {
|
|
33
|
-
const [open, setOpen] = useState(
|
|
34
|
+
const StoryContent = ({ args, screenMode, viewMode }: StoryContentProps) => {
|
|
35
|
+
const [open, setOpen] = useState(viewMode !== 'docs');
|
|
34
36
|
|
|
35
37
|
return (
|
|
36
38
|
<>
|
|
@@ -70,7 +72,7 @@ export const Basic: Story = {
|
|
|
70
72
|
</Button>
|
|
71
73
|
),
|
|
72
74
|
},
|
|
73
|
-
render: (args) => <StoryContent args={args} />,
|
|
75
|
+
render: (args, context) => <StoryContent args={args} viewMode={context.viewMode} />,
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
export const BasicMobile: Story = storyConfig(Basic, { variants: ['mobile'] });
|
|
@@ -81,6 +83,7 @@ export const ContentScroll: Story = {
|
|
|
81
83
|
body: lorem1000,
|
|
82
84
|
scroll: Scroll.CONTENT,
|
|
83
85
|
},
|
|
86
|
+
render: (args, context) => <StoryContent args={args} viewMode={context.viewMode} />,
|
|
84
87
|
};
|
|
85
88
|
|
|
86
89
|
export const ContentScrollMobile: Story = storyConfig(ContentScroll, { variants: ['mobile'] });
|
|
@@ -91,6 +94,7 @@ export const ViewportScroll: Story = {
|
|
|
91
94
|
body: lorem1000,
|
|
92
95
|
scroll: Scroll.VIEWPORT,
|
|
93
96
|
},
|
|
97
|
+
render: (args, context) => <StoryContent args={args} viewMode={context.viewMode} />,
|
|
94
98
|
};
|
|
95
99
|
|
|
96
100
|
export const ViewportScrollMobile: Story = storyConfig(ViewportScroll, { variants: ['mobile'] });
|
|
@@ -100,6 +104,7 @@ export const WithoutTitle: Story = {
|
|
|
100
104
|
body: lorem1000,
|
|
101
105
|
scroll: Scroll.CONTENT,
|
|
102
106
|
},
|
|
107
|
+
render: (args, context) => <StoryContent args={args} viewMode={context.viewMode} />,
|
|
103
108
|
};
|
|
104
109
|
|
|
105
110
|
export const WithoutTitleMobile: Story = storyConfig(WithoutTitle, { variants: ['mobile'] });
|
|
@@ -115,9 +120,9 @@ export const WithThemeProviderInContent: Story = {
|
|
|
115
120
|
</Button>
|
|
116
121
|
),
|
|
117
122
|
},
|
|
118
|
-
render: (args, { globals: { screenMode } }) => (
|
|
123
|
+
render: (args, { globals: { screenMode }, viewMode }) => (
|
|
119
124
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
120
|
-
<StoryContent args={args} screenMode={screenMode} />
|
|
125
|
+
<StoryContent args={args} screenMode={screenMode} viewMode={viewMode} />
|
|
121
126
|
),
|
|
122
127
|
};
|
|
123
128
|
|
package/src/switch/Switch.css
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
@media (min-width: 768px) {
|
|
2
|
+
}@media (min-width: 768px) {
|
|
3
|
+
}.np-switch {
|
|
4
|
+
all: unset;
|
|
5
|
+
box-sizing: border-box;
|
|
2
6
|
display: inline-flex;
|
|
3
7
|
overflow: hidden;
|
|
4
8
|
width: 50px;
|
|
@@ -7,61 +11,38 @@
|
|
|
7
11
|
-webkit-user-select: none;
|
|
8
12
|
-moz-user-select: none;
|
|
9
13
|
user-select: none;
|
|
10
|
-
|
|
11
|
-
.np-switch:focus {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
}.np-switch:focus {
|
|
12
16
|
outline: none;
|
|
13
|
-
}
|
|
14
|
-
.np-switch:focus-visible {
|
|
17
|
+
}.np-switch:focus-visible {
|
|
15
18
|
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
16
19
|
outline-offset: var(--ring-outline-offset);
|
|
17
|
-
}
|
|
18
|
-
.np-switch--thumb {
|
|
20
|
+
}.np-switch--thumb {
|
|
19
21
|
display: flex;
|
|
20
22
|
transition: transform cubic-bezier(0, 0.94, 0.62, 1) 350ms;
|
|
21
|
-
}
|
|
22
|
-
.np-switch--thumb .tw-icon {
|
|
23
|
+
}.np-switch--thumb .tw-icon {
|
|
23
24
|
color: #fff;
|
|
24
|
-
}
|
|
25
|
-
.np-switch--unchecked {
|
|
25
|
+
}.np-switch--unchecked {
|
|
26
26
|
background: #c9cbce;
|
|
27
27
|
background: var(--color-interactive-secondary);
|
|
28
|
-
}
|
|
29
|
-
.np-switch--unchecked .switch--thumb {
|
|
28
|
+
}.np-switch--unchecked .switch--thumb {
|
|
30
29
|
transform: translateX(0);
|
|
31
|
-
}
|
|
32
|
-
.np-switch--checked {
|
|
30
|
+
}.np-switch--checked {
|
|
33
31
|
background: #00a2dd;
|
|
34
32
|
background: var(--color-interactive-accent);
|
|
35
|
-
}
|
|
36
|
-
.np-switch--checked .np-switch--thumb {
|
|
33
|
+
}.np-switch--checked .np-switch--thumb {
|
|
37
34
|
transform: translateX(20px) ;
|
|
38
|
-
}
|
|
39
|
-
[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
35
|
+
}[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
40
36
|
transform: translateX(-20px) ;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
width: 0;
|
|
47
|
-
height: 0;
|
|
48
|
-
opacity: 0;
|
|
49
|
-
}
|
|
50
|
-
[dir="rtl"] .np-switch input {
|
|
51
|
-
right: -100%;
|
|
52
|
-
left: auto;
|
|
53
|
-
left: initial;
|
|
54
|
-
}
|
|
55
|
-
.np-switch:not([aria-disabled]) {
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
}
|
|
58
|
-
.np-theme-personal .np-switch {
|
|
37
|
+
}.np-switch.disabled {
|
|
38
|
+
filter: grayscale(1);
|
|
39
|
+
opacity: 0.45;
|
|
40
|
+
cursor: not-allowed !important;
|
|
41
|
+
}.np-theme-personal .np-switch {
|
|
59
42
|
padding: 1px 2px;
|
|
60
|
-
}
|
|
61
|
-
.np-theme-personal .np-switch--checked {
|
|
43
|
+
}.np-theme-personal .np-switch--checked {
|
|
62
44
|
background: var(--color-interactive-primary);
|
|
63
|
-
}
|
|
64
|
-
.np-theme-personal .np-switch--thumb {
|
|
45
|
+
}.np-theme-personal .np-switch--thumb {
|
|
65
46
|
width: 20px;
|
|
66
47
|
height: 20px;
|
|
67
48
|
margin: 3px;
|
package/src/switch/Switch.less
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
@import (reference) "../../node_modules/@transferwise/neptune-css/src/variables/neptune-tokens.less";
|
|
2
2
|
@import (reference) "../../node_modules/@transferwise/neptune-css/src/less/mixins/_logical-properties.less";
|
|
3
3
|
@import (reference) "../../node_modules/@transferwise/neptune-css/src/less/ring.less";
|
|
4
|
+
@import (reference) "../../node_modules/@transferwise/neptune-css/src/less/core/_scaffolding.less";
|
|
4
5
|
|
|
5
6
|
.np-switch {
|
|
7
|
+
all: unset;
|
|
8
|
+
box-sizing: border-box;
|
|
6
9
|
display: inline-flex;
|
|
7
10
|
overflow: hidden;
|
|
8
11
|
width: 50px;
|
|
9
12
|
padding: 2px;
|
|
10
13
|
border-radius: 16px;
|
|
11
14
|
user-select: none;
|
|
15
|
+
cursor: pointer;
|
|
12
16
|
|
|
13
17
|
.focus-ring();
|
|
14
18
|
|
|
@@ -37,18 +41,8 @@
|
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.left(-100%);
|
|
43
|
-
|
|
44
|
-
display: none;
|
|
45
|
-
width: 0;
|
|
46
|
-
height: 0;
|
|
47
|
-
opacity: 0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&:not([aria-disabled]) {
|
|
51
|
-
cursor: pointer;
|
|
44
|
+
&.disabled{
|
|
45
|
+
.disabled();
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Field } from '../field/Field';
|
|
2
|
-
import { render, fireEvent, screen } from '../test-utils';
|
|
2
|
+
import { render, userEvent, fireEvent, screen } from '../test-utils';
|
|
3
3
|
|
|
4
4
|
import Switch from './Switch';
|
|
5
5
|
|
|
@@ -22,7 +22,7 @@ describe('Switch', () => {
|
|
|
22
22
|
onClick={props.onClick}
|
|
23
23
|
/>,
|
|
24
24
|
);
|
|
25
|
-
expect(
|
|
25
|
+
expect(screen.getByRole('switch')).toBeChecked();
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it('renders component associated with label', () => {
|
|
@@ -54,25 +54,27 @@ describe('Switch', () => {
|
|
|
54
54
|
onClick={props.onClick}
|
|
55
55
|
/>,
|
|
56
56
|
);
|
|
57
|
-
expect(
|
|
57
|
+
expect(screen.getByLabelText(props['aria-label'])).not.toBeChecked();
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
it('calls onClick when user press space key', () => {
|
|
60
|
+
it('calls onClick when user press space or enter key', async () => {
|
|
61
61
|
render(
|
|
62
62
|
<Switch
|
|
63
|
-
checked={props.checked}
|
|
64
63
|
className={props.className}
|
|
65
|
-
id={props.id}
|
|
66
64
|
aria-label={props['aria-label']}
|
|
67
65
|
onClick={props.onClick}
|
|
68
66
|
/>,
|
|
69
67
|
);
|
|
70
68
|
|
|
71
|
-
const input = screen.getAllByRole('checkbox')[0];
|
|
72
|
-
fireEvent.keyDown(input, { key: 'Enter' });
|
|
73
69
|
expect(props.onClick).not.toHaveBeenCalled();
|
|
74
|
-
|
|
70
|
+
|
|
71
|
+
await userEvent.tab();
|
|
72
|
+
|
|
73
|
+
await userEvent.keyboard(' ');
|
|
75
74
|
expect(props.onClick).toHaveBeenCalledTimes(1);
|
|
75
|
+
|
|
76
|
+
await userEvent.keyboard('{Enter}');
|
|
77
|
+
expect(props.onClick).toHaveBeenCalledTimes(2);
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
it('should not call onClick if disabled', () => {
|