@transferwise/components 0.0.0-experimental-14afc1f → 0.0.0-experimental-ecf13ed
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/index.js +15 -15
- package/build/index.js.map +1 -1
- package/build/index.mjs +15 -15
- package/build/index.mjs.map +1 -1
- package/build/main.css +0 -16
- package/build/styles/logo/Logo.css +0 -16
- package/build/styles/main.css +0 -16
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts +2 -2
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/logo/Logo.css +0 -16
- package/src/logo/Logo.js +7 -2
- package/src/logo/Logo.less +0 -16
- package/src/logo/__snapshots__/Logo.spec.js.snap +8 -104
- package/src/main.css +0 -16
- package/src/segmentedControl/SegmentedControl.spec.tsx +39 -1
- package/src/segmentedControl/SegmentedControl.story.tsx +54 -16
- package/src/segmentedControl/SegmentedControl.tsx +11 -18
package/build/index.mjs
CHANGED
|
@@ -4551,14 +4551,15 @@ const Logo = ({
|
|
|
4551
4551
|
}) => {
|
|
4552
4552
|
const LogoSm = svgPaths[`WISE_FLAG${type === LogoType.WISE_PLATFORM ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`];
|
|
4553
4553
|
const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
4554
|
+
const screenMd = useScreenSize(Breakpoint.MEDIUM);
|
|
4554
4555
|
return /*#__PURE__*/jsxs("span", {
|
|
4555
4556
|
"aria-label": type === LogoType.WISE ? 'Wise' : 'Wise Business' | type === LogoType.WISE_PLATFORM ? 'Wise Platform' : 'Wise Business',
|
|
4556
4557
|
role: "img",
|
|
4557
4558
|
className: classNames(className, 'np-logo'),
|
|
4558
|
-
children: [/*#__PURE__*/jsx(LogoSm, {
|
|
4559
|
-
className: "np-logo-svg
|
|
4560
|
-
}), /*#__PURE__*/jsx(LogoMd, {
|
|
4561
|
-
className: "np-logo-svg
|
|
4559
|
+
children: [!screenMd && /*#__PURE__*/jsx(LogoSm, {
|
|
4560
|
+
className: "np-logo-svg"
|
|
4561
|
+
}), screenMd && /*#__PURE__*/jsx(LogoMd, {
|
|
4562
|
+
className: "np-logo-svg"
|
|
4562
4563
|
})]
|
|
4563
4564
|
});
|
|
4564
4565
|
};
|
|
@@ -9945,12 +9946,11 @@ Select.defaultProps = {
|
|
|
9945
9946
|
|
|
9946
9947
|
const SegmentedControl = ({
|
|
9947
9948
|
name,
|
|
9948
|
-
|
|
9949
|
+
value,
|
|
9949
9950
|
mode = 'input',
|
|
9950
9951
|
segments,
|
|
9951
9952
|
onChange
|
|
9952
9953
|
}) => {
|
|
9953
|
-
const [selectedValue, setSelectedValue] = useState(defaultValue || segments[0].value);
|
|
9954
9954
|
const [animate, setAnimate] = useState(false);
|
|
9955
9955
|
const segmentsRef = useRef(null);
|
|
9956
9956
|
if (segments.length > 3) {
|
|
@@ -9961,7 +9961,7 @@ const SegmentedControl = ({
|
|
|
9961
9961
|
ref: /*#__PURE__*/createRef()
|
|
9962
9962
|
}));
|
|
9963
9963
|
const updateSegmentPosition = () => {
|
|
9964
|
-
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value ===
|
|
9964
|
+
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value === value)?.ref;
|
|
9965
9965
|
// We grab the active segments style object from the ref
|
|
9966
9966
|
// and set the css variables to the selected segments width and x position.
|
|
9967
9967
|
// This is so we can animate the highlight to the selected segment
|
|
@@ -9974,6 +9974,7 @@ const SegmentedControl = ({
|
|
|
9974
9974
|
}
|
|
9975
9975
|
};
|
|
9976
9976
|
useEffect(() => {
|
|
9977
|
+
setAnimate(true);
|
|
9977
9978
|
updateSegmentPosition();
|
|
9978
9979
|
const handleWindowSizeChange = () => {
|
|
9979
9980
|
setAnimate(false);
|
|
@@ -9984,7 +9985,7 @@ const SegmentedControl = ({
|
|
|
9984
9985
|
window.removeEventListener('resize', handleWindowSizeChange);
|
|
9985
9986
|
};
|
|
9986
9987
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
9987
|
-
}, [segmentsWithRefs,
|
|
9988
|
+
}, [segmentsWithRefs, value]);
|
|
9988
9989
|
return /*#__PURE__*/jsx("div", {
|
|
9989
9990
|
ref: segmentsRef,
|
|
9990
9991
|
"data-testid": "segmented-control",
|
|
@@ -9999,14 +10000,13 @@ const SegmentedControl = ({
|
|
|
9999
10000
|
children: segmentsWithRefs.map(segment => {
|
|
10000
10001
|
const onSelect = () => {
|
|
10001
10002
|
setAnimate(true);
|
|
10002
|
-
setSelectedValue(segment.value);
|
|
10003
10003
|
onChange(segment.value);
|
|
10004
10004
|
};
|
|
10005
10005
|
return mode === 'input' ? /*#__PURE__*/jsxs("label", {
|
|
10006
10006
|
ref: segment.ref,
|
|
10007
10007
|
htmlFor: segment.id,
|
|
10008
10008
|
className: classNames('segmented-control__segment', {
|
|
10009
|
-
'segmented-control__selected-segment':
|
|
10009
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10010
10010
|
}),
|
|
10011
10011
|
children: [/*#__PURE__*/jsx("input", {
|
|
10012
10012
|
type: "radio",
|
|
@@ -10014,12 +10014,12 @@ const SegmentedControl = ({
|
|
|
10014
10014
|
id: segment.id,
|
|
10015
10015
|
name: name,
|
|
10016
10016
|
value: segment.value,
|
|
10017
|
-
checked:
|
|
10017
|
+
checked: value === segment.value,
|
|
10018
10018
|
onChange: onSelect
|
|
10019
10019
|
}), /*#__PURE__*/jsx(Body, {
|
|
10020
10020
|
className: "segmented-control__text",
|
|
10021
10021
|
as: "span",
|
|
10022
|
-
type:
|
|
10022
|
+
type: value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10023
10023
|
children: segment.label
|
|
10024
10024
|
})]
|
|
10025
10025
|
}, segment.id) : /*#__PURE__*/jsx("button", {
|
|
@@ -10028,15 +10028,15 @@ const SegmentedControl = ({
|
|
|
10028
10028
|
role: "tab",
|
|
10029
10029
|
id: segment.id,
|
|
10030
10030
|
"aria-controls": segment.controls,
|
|
10031
|
-
"aria-selected":
|
|
10031
|
+
"aria-selected": value === segment.value,
|
|
10032
10032
|
className: classNames('segmented-control__segment', 'segmented-control__button', {
|
|
10033
|
-
'segmented-control__selected-segment':
|
|
10033
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10034
10034
|
}),
|
|
10035
10035
|
onClick: onSelect,
|
|
10036
10036
|
children: /*#__PURE__*/jsx(Body, {
|
|
10037
10037
|
as: "span",
|
|
10038
10038
|
className: "segmented-control__text",
|
|
10039
|
-
type:
|
|
10039
|
+
type: value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10040
10040
|
children: segment.label
|
|
10041
10041
|
})
|
|
10042
10042
|
}, segment.id);
|