@skyscanner/backpack-web 31.8.0 → 31.9.0
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/bpk-component-boilerplate/src/BpkBoilerplate.d.ts +1 -5
- package/bpk-component-boilerplate/src/BpkBoilerplate.js +3 -3
- package/bpk-component-swap-button/index.d.ts +24 -0
- package/bpk-component-swap-button/index.js +20 -0
- package/bpk-component-swap-button/src/BpkSwapButton.d.ts +29 -0
- package/bpk-component-swap-button/src/BpkSwapButton.js +69 -0
- package/bpk-component-swap-button/src/BpkSwapButton.module.css +18 -0
- package/package.json +1 -1
|
@@ -17,13 +17,9 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
export type Props = {
|
|
20
|
-
className?: string | null;
|
|
21
20
|
[rest: string]: any;
|
|
22
21
|
};
|
|
23
22
|
declare const BpkBoilerplate: {
|
|
24
|
-
({
|
|
25
|
-
defaultProps: {
|
|
26
|
-
className: null;
|
|
27
|
-
};
|
|
23
|
+
({ ...rest }: Props): JSX.Element;
|
|
28
24
|
};
|
|
29
25
|
export default BpkBoilerplate;
|
|
@@ -21,12 +21,12 @@ import STYLES from "./BpkBoilerplate.module.css";
|
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
22
|
const getClassName = cssModules(STYLES);
|
|
23
23
|
const BpkBoilerplate = ({
|
|
24
|
-
className = null,
|
|
25
24
|
...rest
|
|
26
25
|
}) => {
|
|
27
|
-
|
|
26
|
+
// eslint-disable-next-line no-param-reassign
|
|
27
|
+
delete rest.className;
|
|
28
28
|
return /*#__PURE__*/_jsx("div", {
|
|
29
|
-
className:
|
|
29
|
+
className: getClassName('bpk-boilerplate'),
|
|
30
30
|
...rest,
|
|
31
31
|
children: "I am an example component."
|
|
32
32
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkSwapButton, {
|
|
20
|
+
type Props as BpkSwapButtonProps,
|
|
21
|
+
} from './src/BpkSwapButton.tsx';
|
|
22
|
+
|
|
23
|
+
export type { BpkSwapButtonProps };
|
|
24
|
+
export default BpkSwapButton;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkSwapButton from "./src/BpkSwapButton";
|
|
20
|
+
export default BpkSwapButton;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type Props = {
|
|
20
|
+
ariaLabel: string;
|
|
21
|
+
ariaLiveTextProps: string;
|
|
22
|
+
onClick: () => void;
|
|
23
|
+
};
|
|
24
|
+
declare const BpkSwapButton: ({
|
|
25
|
+
ariaLabel,
|
|
26
|
+
ariaLiveTextProps,
|
|
27
|
+
onClick,
|
|
28
|
+
} : Props) => JSX.Element;
|
|
29
|
+
export default BpkSwapButton;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { useState } from 'react';
|
|
20
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
21
|
+
import BpkAriaLive from "../../bpk-component-aria-live";
|
|
22
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
23
|
+
import SwapVertical from "../../bpk-component-icon/sm/swap--vertical";
|
|
24
|
+
import STYLES from "./BpkSwapButton.module.css";
|
|
25
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
+
const getClassName = cssModules(STYLES);
|
|
28
|
+
const BpkSwapButton = props => {
|
|
29
|
+
const {
|
|
30
|
+
ariaLabel,
|
|
31
|
+
ariaLiveTextProp,
|
|
32
|
+
onClick
|
|
33
|
+
} = props;
|
|
34
|
+
const [rotationDegree, setRotationDegree] = useState(0);
|
|
35
|
+
const [ariaLiveText, setAriaLiveText] = useState('');
|
|
36
|
+
const handleRotation = () => {
|
|
37
|
+
if (rotationDegree === 0) {
|
|
38
|
+
setRotationDegree(-180);
|
|
39
|
+
} else {
|
|
40
|
+
setRotationDegree(0);
|
|
41
|
+
}
|
|
42
|
+
setAriaLiveText(ariaLiveTextProp);
|
|
43
|
+
// without set timeout, the aria-live text would not change and screenreader would read out 'swapped' for the first time only.
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
setAriaLiveText('');
|
|
46
|
+
}, 250);
|
|
47
|
+
};
|
|
48
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
49
|
+
className: getClassName('bpk-swap-button'),
|
|
50
|
+
children: [/*#__PURE__*/_jsx("button", {
|
|
51
|
+
type: "button",
|
|
52
|
+
className: getClassName('bpk-swap-button__button'),
|
|
53
|
+
style: {
|
|
54
|
+
transform: `rotate(${rotationDegree}deg)`
|
|
55
|
+
},
|
|
56
|
+
"aria-label": ariaLabel,
|
|
57
|
+
onClick: () => {
|
|
58
|
+
onClick();
|
|
59
|
+
handleRotation();
|
|
60
|
+
},
|
|
61
|
+
children: /*#__PURE__*/_jsx(SwapVertical, {
|
|
62
|
+
className: getClassName('bpk-swap-button__icon')
|
|
63
|
+
})
|
|
64
|
+
}), /*#__PURE__*/_jsx(BpkAriaLive, {
|
|
65
|
+
children: ariaLiveText
|
|
66
|
+
})]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
export default BpkSwapButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
@keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}@layer bpk-component{.bpk-swap-button{width:2.5rem;height:2.5rem;transform:translateY(-50%) rotate(90deg)}@media (max-width: 48rem){.bpk-swap-button{transform:rotate(0deg)}}.bpk-swap-button :focus-visible{box-shadow:0 0 0 0.125rem #fff,0 0 0 0.25rem #0062e3}.bpk-swap-button__button{display:flex;width:100%;height:100%;justify-content:center;align-items:center;transition:transform 400ms;border:3px solid #05203c;border-radius:50%;background-color:#fff}@media (max-width: 48rem){.bpk-swap-button__button{border:2px solid #05203c}}.bpk-no-touch-support .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e3e5}:global(.bpk-no-touch-support) .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e3e5}.bpk-swap-button__icon{max-width:1rem;max-height:1rem}}
|