@skyscanner/backpack-web 29.1.0 → 29.2.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.
|
@@ -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 BpkSaveButton, { SIZE_TYPES, STYLE_TYPES } from "./src/BpkSaveButton";
|
|
20
|
+
export { BpkSaveButton, SIZE_TYPES, STYLE_TYPES };
|
|
@@ -0,0 +1,45 @@
|
|
|
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 type { ReactNode, MouseEvent } from 'react';
|
|
20
|
+
export declare const SIZE_TYPES: {
|
|
21
|
+
default: 'default';
|
|
22
|
+
small: 'small';
|
|
23
|
+
};
|
|
24
|
+
export type SizeType = (typeof SIZE_TYPES)[keyof typeof SIZE_TYPES];
|
|
25
|
+
export declare const STYLE_TYPES: {
|
|
26
|
+
default: 'default';
|
|
27
|
+
contained: 'contained';
|
|
28
|
+
onDark: 'onDark';
|
|
29
|
+
};
|
|
30
|
+
export type StyleType = (typeof STYLE_TYPES)[keyof typeof STYLE_TYPES];
|
|
31
|
+
type Props = {
|
|
32
|
+
checked: boolean;
|
|
33
|
+
accessibilityLabel: string;
|
|
34
|
+
onCheckedChange: (e: MouseEvent) => void;
|
|
35
|
+
size?: SizeType;
|
|
36
|
+
style?: StyleType;
|
|
37
|
+
};
|
|
38
|
+
declare const BpkSaveButton: ({
|
|
39
|
+
checked,
|
|
40
|
+
accessibilityLabel,
|
|
41
|
+
onCheckedChange,
|
|
42
|
+
size,
|
|
43
|
+
style,
|
|
44
|
+
}: Props) => JSX.Element;
|
|
45
|
+
export default BpkSaveButton;
|
|
@@ -0,0 +1,74 @@
|
|
|
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 BpkButtonV2 from "../../bpk-component-button/src/BpkButtonV2/BpkButton";
|
|
21
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
22
|
+
import BpkHeartIcon from "../../bpk-component-icon/lg/heart";
|
|
23
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
24
|
+
import BpkHeartOutlineIcon from "../../bpk-component-icon/lg/heart--outline";
|
|
25
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
26
|
+
import BpkHeartIconSm from "../../bpk-component-icon/sm/heart";
|
|
27
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
28
|
+
import BpkHeartOutlineIconSm from "../../bpk-component-icon/sm/heart--outline";
|
|
29
|
+
import { withLargeButtonAlignment } from "../../bpk-component-icon";
|
|
30
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
31
|
+
import STYLES from "./BpkSaveButton.module.css";
|
|
32
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
33
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
34
|
+
export const SIZE_TYPES = {
|
|
35
|
+
default: 'default',
|
|
36
|
+
small: 'small'
|
|
37
|
+
};
|
|
38
|
+
export const STYLE_TYPES = {
|
|
39
|
+
default: 'default',
|
|
40
|
+
contained: 'contained',
|
|
41
|
+
onDark: 'onDark'
|
|
42
|
+
};
|
|
43
|
+
const getClassName = cssModules(STYLES);
|
|
44
|
+
const AlignedHeartIcon = withLargeButtonAlignment(BpkHeartIcon);
|
|
45
|
+
const AlignedHeartOutlineIcon = withLargeButtonAlignment(BpkHeartOutlineIcon);
|
|
46
|
+
const AlignedHeartIconSm = withLargeButtonAlignment(BpkHeartIconSm);
|
|
47
|
+
const AlignedHeartOutlineIconSm = withLargeButtonAlignment(BpkHeartOutlineIconSm);
|
|
48
|
+
const BpkSaveButton = ({
|
|
49
|
+
accessibilityLabel,
|
|
50
|
+
checked,
|
|
51
|
+
onCheckedChange,
|
|
52
|
+
size = SIZE_TYPES.default,
|
|
53
|
+
style = STYLE_TYPES.default
|
|
54
|
+
}) => {
|
|
55
|
+
const [toggle, setToggle] = useState(false);
|
|
56
|
+
const smallSize = size === SIZE_TYPES.small;
|
|
57
|
+
const HeartIcon = smallSize ? AlignedHeartIconSm : AlignedHeartIcon;
|
|
58
|
+
const HeartOutLineIcon = smallSize ? AlignedHeartOutlineIconSm : AlignedHeartOutlineIcon;
|
|
59
|
+
return /*#__PURE__*/_jsxs(BpkButtonV2, {
|
|
60
|
+
"aria-label": accessibilityLabel,
|
|
61
|
+
className: getClassName('bpk-save-button', smallSize && 'bpk-save-button__small', `bpk-save-button__${style}`),
|
|
62
|
+
onClick: e => {
|
|
63
|
+
setToggle(true);
|
|
64
|
+
onCheckedChange(e);
|
|
65
|
+
},
|
|
66
|
+
iconOnly: true,
|
|
67
|
+
children: [/*#__PURE__*/_jsx(HeartIcon, {
|
|
68
|
+
className: getClassName('bpk-save-button__icon', 'bpk-save-button__heartIcon', toggle && checked && 'bpk-save-button__heartIcon--toggle', `bpk-save-button__heartIcon--${checked ? 'show' : 'hide'}`, `bpk-save-button__heartIcon--${style}`)
|
|
69
|
+
}), /*#__PURE__*/_jsx(HeartOutLineIcon, {
|
|
70
|
+
className: getClassName('bpk-save-button__icon', 'bpk-save-button__heartOutlineIcon', `bpk-save-button__heartOutlineIcon--${checked ? 'hide' : 'show'}`, `bpk-save-button__heartOutlineIcon--${style}`)
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export default BpkSaveButton;
|
|
@@ -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)}}@keyframes heart-beat{0%,100%{transform:translate(-50%, -50%) scale(1)}10%{transform:translate(-50%, -50%) scale(1.4)}20%{transform:translate(-50%, -50%) scale(1.2)}30%{transform:translate(-50%, -50%) scale(1.3)}50%{transform:translate(-50%, -50%) scale(1.25)}70%{transform:translate(-50%, -50%) scale(1.25)}}.bpk-save-button{position:relative;width:2.5rem;height:2.5rem;padding:0.5rem;border-radius:50%;background-color:transparent}.bpk-no-touch-support .bpk-save-button:hover:not(:active):not(:disabled){background-color:transparent}:global(.bpk-no-touch-support) .bpk-save-button:hover:not(:active):not(:disabled){background-color:transparent}.bpk-save-button:active{background-color:transparent}.bpk-save-button__icon{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);color:#161616}.bpk-save-button__icon:hover{color:#161616}.bpk-save-button__heartOutlineIcon{z-index:1;opacity:1}.bpk-save-button__heartOutlineIcon--show:hover{transition:opacity 200ms ease-in-out;opacity:0}.bpk-save-button__heartOutlineIcon--hide{opacity:0}.bpk-save-button__heartOutlineIcon--onDark{color:#fff}.bpk-save-button__heartIcon{z-index:2;color:#0062e3;opacity:0}.bpk-save-button__heartIcon--toggle{animation:heart-beat 1s 0s 1 ease-out;animation-fill-mode:forwards}.bpk-save-button__heartIcon--show{opacity:1}.bpk-save-button__heartIcon--show:hover{color:#0062e3}.bpk-save-button__heartIcon--hide:hover{transition:opacity 200ms ease-in-out;color:#161616;opacity:1}.bpk-save-button__heartIcon--onDark{color:#fff}.bpk-save-button__heartIcon--onDark:hover{color:#fff}.bpk-save-button__small{width:2rem;height:2rem;min-height:2rem}.bpk-save-button__contained{background-color:rgba(255,255,255,0.8)}.bpk-no-touch-support .bpk-save-button__contained:hover:not(:active):not(:disabled){background-color:rgba(255,255,255,0.8)}:global(.bpk-no-touch-support) .bpk-save-button__contained:hover:not(:active):not(:disabled){background-color:rgba(255,255,255,0.8)}.bpk-save-button__contained:active{background-color:rgba(255,255,255,0.8)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "29.
|
|
3
|
+
"version": "29.2.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@popperjs/core": "^2.11.5",
|
|
26
26
|
"@react-google-maps/api": "^2.12.0",
|
|
27
|
-
"@skyscanner/bpk-foundations-web": "^17.
|
|
28
|
-
"@skyscanner/bpk-svgs": "^18.1.
|
|
27
|
+
"@skyscanner/bpk-foundations-web": "^17.1.0",
|
|
28
|
+
"@skyscanner/bpk-svgs": "^18.1.1",
|
|
29
29
|
"a11y-focus-scope": "^1.1.3",
|
|
30
30
|
"a11y-focus-store": "^1.0.0",
|
|
31
31
|
"d3-path": "^2.0.0",
|