@transferwise/components 0.0.0-experimental-805500d → 0.0.0-experimental-2b2d326
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/common/bottomSheet/BottomSheet.js +8 -2
- package/build/common/bottomSheet/BottomSheet.js.map +1 -1
- package/build/common/bottomSheet/BottomSheet.mjs +8 -2
- package/build/common/bottomSheet/BottomSheet.mjs.map +1 -1
- package/build/drawer/Drawer.js +5 -3
- package/build/drawer/Drawer.js.map +1 -1
- package/build/drawer/Drawer.mjs +5 -3
- package/build/drawer/Drawer.mjs.map +1 -1
- package/build/flowNavigation/FlowNavigation.js +1 -1
- package/build/flowNavigation/FlowNavigation.js.map +1 -1
- package/build/flowNavigation/FlowNavigation.mjs +1 -1
- package/build/flowNavigation/FlowNavigation.mjs.map +1 -1
- package/build/flowNavigation/animatedLabel/AnimatedLabel.js +89 -15
- package/build/flowNavigation/animatedLabel/AnimatedLabel.js.map +1 -1
- package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs +90 -16
- package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs.map +1 -1
- package/build/main.css +9 -0
- package/build/styles/flowNavigation/animatedLabel/AnimatedLabel.css +9 -0
- package/build/styles/main.css +9 -0
- package/build/types/common/bottomSheet/BottomSheet.d.ts +3 -3
- package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
- package/build/types/drawer/Drawer.d.ts +4 -3
- package/build/types/drawer/Drawer.d.ts.map +1 -1
- package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts +3 -3
- package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common/bottomSheet/BottomSheet.tsx +13 -4
- package/src/drawer/Drawer.tsx +7 -5
- package/src/flowNavigation/FlowNavigation.story.js +69 -17
- package/src/flowNavigation/FlowNavigation.tsx +1 -5
- package/src/flowNavigation/animatedLabel/AnimatedLabel.css +9 -0
- package/src/flowNavigation/animatedLabel/AnimatedLabel.less +9 -0
- package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +19 -21
- package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +102 -20
- package/src/main.css +9 -0
- package/src/flowNavigation/animatedLabel/__snapshots__/AnimatedLabel.spec.js.snap +0 -25
|
@@ -1,32 +1,114 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
|
-
import
|
|
2
|
+
import { useId, useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import type { Step } from '../../stepper/Stepper';
|
|
5
|
+
import BottomSheet from '../../common/bottomSheet';
|
|
6
|
+
import Option from '../../common/Option';
|
|
7
|
+
import { Check, ChevronDown } from '@transferwise/icons';
|
|
8
|
+
import { OverlayIdContext, OverlayIdProvider } from '../../provider/overlay/OverlayIdProvider';
|
|
9
|
+
import { List } from '../../listItem';
|
|
6
10
|
|
|
7
11
|
export interface AnimatedLabelProps {
|
|
8
12
|
activeLabel: number;
|
|
9
13
|
className?: string;
|
|
10
|
-
|
|
14
|
+
steps: readonly Step[];
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
const AnimatedLabel = ({ activeLabel, className,
|
|
17
|
+
const AnimatedLabel = ({ activeLabel, className, steps }: AnimatedLabelProps) => {
|
|
18
|
+
const labelId = useId();
|
|
19
|
+
const [showSteps, setShowSteps] = useState(false);
|
|
20
|
+
|
|
21
|
+
function handleStepAction(onClick: Step['onClick']) {
|
|
22
|
+
return () => {
|
|
23
|
+
setShowSteps(false);
|
|
24
|
+
onClick?.();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
return (
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
<OverlayIdProvider open={showSteps}>
|
|
30
|
+
<OverlayIdContext.Consumer>
|
|
31
|
+
{(overlayId) => {
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
id={labelId}
|
|
37
|
+
aria-haspopup="menu"
|
|
38
|
+
aria-controls={overlayId}
|
|
39
|
+
aria-expanded={showSteps}
|
|
40
|
+
className={clsx(
|
|
41
|
+
'np-animated-label',
|
|
42
|
+
'btn-unstyled',
|
|
43
|
+
'np-text-body-large-bold',
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
onClick={() => setShowSteps(true)}
|
|
47
|
+
>
|
|
48
|
+
{steps.map(({ label }, index) => {
|
|
49
|
+
const isCurrentStep = activeLabel === index;
|
|
50
|
+
const nextLabel = index - 1;
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
key={nextLabel}
|
|
54
|
+
aria-hidden={!isCurrentStep}
|
|
55
|
+
className={clsx('text-xs-center', 'd-inline-flex', {
|
|
56
|
+
'np-animated-label--in text-ellipsis': isCurrentStep,
|
|
57
|
+
})}
|
|
58
|
+
>
|
|
59
|
+
{label} <ChevronDown className="m-l-1" size={24} />
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
})}
|
|
63
|
+
</button>
|
|
64
|
+
<BottomSheet
|
|
65
|
+
role="menu"
|
|
66
|
+
aria-labelledby={labelId}
|
|
67
|
+
open={showSteps}
|
|
68
|
+
onClose={() => setShowSteps(false)}
|
|
69
|
+
>
|
|
70
|
+
<List className="p-a-1">
|
|
71
|
+
{steps.map((step, index) => {
|
|
72
|
+
const isCurrentStep = activeLabel === index;
|
|
73
|
+
const isDisabled = activeLabel < index;
|
|
74
|
+
const itemId = `step-${index}`;
|
|
75
|
+
return (
|
|
76
|
+
<Option
|
|
77
|
+
key={itemId}
|
|
78
|
+
id={itemId}
|
|
79
|
+
as="li"
|
|
80
|
+
role="menuitem"
|
|
81
|
+
decision={false}
|
|
82
|
+
className={clsx('np-animated-label-option', 'p-x-3', 'p-y-1', 'm-y-1', {
|
|
83
|
+
clickable: !isDisabled,
|
|
84
|
+
})}
|
|
85
|
+
title={step.label}
|
|
86
|
+
content={step.hoverLabel}
|
|
87
|
+
button={isCurrentStep ? <Check size={24} /> : null}
|
|
88
|
+
aria-current={isCurrentStep ? 'step' : false}
|
|
89
|
+
aria-disabled={isDisabled}
|
|
90
|
+
disabled={isDisabled}
|
|
91
|
+
isContainerAligned
|
|
92
|
+
{...(!isDisabled && {
|
|
93
|
+
tabIndex: 0,
|
|
94
|
+
onClick: handleStepAction(step.onClick),
|
|
95
|
+
onKeyDown: (event) => {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
if (event.code === 'Enter' || event.code === 'Space') {
|
|
98
|
+
handleStepAction(step.onClick)();
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
})}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
})}
|
|
105
|
+
</List>
|
|
106
|
+
</BottomSheet>
|
|
107
|
+
</>
|
|
108
|
+
);
|
|
109
|
+
}}
|
|
110
|
+
</OverlayIdContext.Consumer>
|
|
111
|
+
</OverlayIdProvider>
|
|
30
112
|
);
|
|
31
113
|
};
|
|
32
114
|
|
package/src/main.css
CHANGED
|
@@ -2106,6 +2106,15 @@ button.np-option {
|
|
|
2106
2106
|
transform: translateX(0);
|
|
2107
2107
|
transition: all 0.15s ease-in 0.15s;
|
|
2108
2108
|
}
|
|
2109
|
+
.np-animated-label-option {
|
|
2110
|
+
border-radius: 10px;
|
|
2111
|
+
border-radius: var(--radius-small);
|
|
2112
|
+
}
|
|
2113
|
+
.np-animated-label-option:not(.disabled):hover,
|
|
2114
|
+
.np-animated-label-option:not(.disabled):focus-visible {
|
|
2115
|
+
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
2116
|
+
outline-offset: var(--ring-outline-offset);
|
|
2117
|
+
}
|
|
2109
2118
|
.np-back-button {
|
|
2110
2119
|
color: #00a2dd;
|
|
2111
2120
|
color: var(--color-interactive-accent);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`AnimatedLabel renders all labels 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="np-text-body-large-bold np-animated-label"
|
|
7
|
-
>
|
|
8
|
-
<div
|
|
9
|
-
class="text-xs-center np-animated-label--in text-ellipsis"
|
|
10
|
-
>
|
|
11
|
-
label1
|
|
12
|
-
</div>
|
|
13
|
-
<div
|
|
14
|
-
class="text-xs-center"
|
|
15
|
-
>
|
|
16
|
-
label2
|
|
17
|
-
</div>
|
|
18
|
-
<div
|
|
19
|
-
class="text-xs-center"
|
|
20
|
-
>
|
|
21
|
-
label3
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
`;
|