@skyscanner/backpack-web 37.3.1 → 37.4.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-image/src/BpkBackgroundImage.d.ts +4 -0
- package/bpk-component-image/src/BpkBackgroundImage.js +12 -0
- package/bpk-component-link/src/BpkLink.module.css +1 -1
- package/bpk-component-tooltip/src/BpkTooltip.js +7 -6
- package/bpk-mixins/_typography.scss +1 -1
- package/package.json +1 -1
- package/unstable__bpk-mixins/_typography.scss +1 -1
|
@@ -7,6 +7,7 @@ export type BpkBackgroundImageProps = {
|
|
|
7
7
|
loading?: boolean;
|
|
8
8
|
src: string;
|
|
9
9
|
className?: string;
|
|
10
|
+
onError?: (() => void) | null;
|
|
10
11
|
onLoad?: (() => void) | null;
|
|
11
12
|
style?: {};
|
|
12
13
|
imageStyle?: CSSProperties;
|
|
@@ -18,12 +19,15 @@ declare class BpkBackgroundImage extends Component<BpkBackgroundImageProps> {
|
|
|
18
19
|
inView: boolean;
|
|
19
20
|
loading: boolean;
|
|
20
21
|
onLoad: null;
|
|
22
|
+
onError: null;
|
|
21
23
|
style: {};
|
|
22
24
|
imageStyle: {};
|
|
23
25
|
};
|
|
24
26
|
constructor(props: BpkBackgroundImageProps);
|
|
25
27
|
componentDidMount(): void;
|
|
26
28
|
UNSAFE_componentWillReceiveProps(newProps: BpkBackgroundImageProps): void;
|
|
29
|
+
componentDidUpdate(prevProps: BpkBackgroundImageProps): void;
|
|
30
|
+
onBackgroundImageError: () => void;
|
|
27
31
|
onBackgroundImageLoad: () => void;
|
|
28
32
|
getAspectRatio: () => number;
|
|
29
33
|
startImageLoad: () => void;
|
|
@@ -30,6 +30,7 @@ class BpkBackgroundImage extends Component {
|
|
|
30
30
|
inView: true,
|
|
31
31
|
loading: false,
|
|
32
32
|
onLoad: null,
|
|
33
|
+
onError: null,
|
|
33
34
|
style: {},
|
|
34
35
|
imageStyle: {}
|
|
35
36
|
};
|
|
@@ -47,6 +48,16 @@ class BpkBackgroundImage extends Component {
|
|
|
47
48
|
this.startImageLoad();
|
|
48
49
|
}
|
|
49
50
|
}
|
|
51
|
+
componentDidUpdate(prevProps) {
|
|
52
|
+
if (prevProps.src !== this.props.src) {
|
|
53
|
+
this.startImageLoad();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
onBackgroundImageError = () => {
|
|
57
|
+
if (this.props.onError) {
|
|
58
|
+
this.props.onError();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
50
61
|
onBackgroundImageLoad = () => {
|
|
51
62
|
if (this.props.onLoad) {
|
|
52
63
|
this.props.onLoad();
|
|
@@ -62,6 +73,7 @@ class BpkBackgroundImage extends Component {
|
|
|
62
73
|
startImageLoad = () => {
|
|
63
74
|
this.trackImg = new Image();
|
|
64
75
|
this.trackImg.src = this.props.src;
|
|
76
|
+
this.trackImg.onerror = this.onBackgroundImageError;
|
|
65
77
|
this.trackImg.onload = this.onBackgroundImageLoad;
|
|
66
78
|
};
|
|
67
79
|
render() {
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-link{position:relative;display:inline;padding:0;border:0;background-color:rgba(0,0,0,0);text-decoration:none;cursor:pointer;appearance:none;color:#161616;color:var(--bpk-link-color, rgb(22, 22, 22))}.bpk-no-touch-support .bpk-link:hover:not(:active):not(:disabled){text-decoration:none;color:#161616;color:var(--bpk-link-hover-color, rgb(22, 22, 22))}:global(.bpk-no-touch-support) .bpk-link:hover:not(:active):not(:disabled){text-decoration:none;color:#161616;color:var(--bpk-link-hover-color, rgb(22, 22, 22))}.bpk-link:visited{color:#161616;color:var(--bpk-link-visited-color, rgb(22, 22, 22))}.bpk-link:active{color:#161616;color:var(--bpk-link-active-color, rgb(22, 22, 22))}.bpk-link--active{color:#161616}.bpk-link--active:visited{color:#161616}.bpk-link--active:active{color:#161616}.bpk-link--implicit{color:#161616;color:var(--bpk-link-color, rgb(22, 22, 22))}.bpk-no-touch-support .bpk-link--implicit:hover:not(:active):not(:disabled){color:#161616;color:var(--bpk-link-hover-color, rgb(22, 22, 22))}:global(.bpk-no-touch-support) .bpk-link--implicit:hover:not(:active):not(:disabled){color:#161616;color:var(--bpk-link-hover-color, rgb(22, 22, 22))}.bpk-link--implicit:active{text-decoration:none;color:#161616;color:var(--bpk-link-active-color, rgb(22, 22, 22))}.bpk-link--alternate{color:#fff;color:var(--bpk-link-alternate-color, rgb(255, 255, 255))}.bpk-no-touch-support .bpk-link--alternate:hover:not(:active):not(:disabled){color:#fff;color:var(--bpk-link-alternate-hover-color, rgb(255, 255, 255))}:global(.bpk-no-touch-support) .bpk-link--alternate:hover:not(:active):not(:disabled){color:#fff;color:var(--bpk-link-alternate-hover-color, rgb(255, 255, 255))}.bpk-link--alternate:visited{color:#fff;color:var(--bpk-link-alternate-visited-color, rgb(255, 255, 255))}.bpk-link--alternate:active{color:#fff;color:var(--bpk-link-alternate-active-color, rgb(255, 255, 255))}.bpk-link-underlined{padding-bottom:.
|
|
18
|
+
.bpk-link{position:relative;display:inline;padding:0;border:0;background-color:rgba(0,0,0,0);text-decoration:none;cursor:pointer;appearance:none;color:#161616;color:var(--bpk-link-color, rgb(22, 22, 22))}.bpk-no-touch-support .bpk-link:hover:not(:active):not(:disabled){text-decoration:none;color:#161616;color:var(--bpk-link-hover-color, rgb(22, 22, 22))}:global(.bpk-no-touch-support) .bpk-link:hover:not(:active):not(:disabled){text-decoration:none;color:#161616;color:var(--bpk-link-hover-color, rgb(22, 22, 22))}.bpk-link:visited{color:#161616;color:var(--bpk-link-visited-color, rgb(22, 22, 22))}.bpk-link:active{color:#161616;color:var(--bpk-link-active-color, rgb(22, 22, 22))}.bpk-link--active{color:#161616}.bpk-link--active:visited{color:#161616}.bpk-link--active:active{color:#161616}.bpk-link--implicit{color:#161616;color:var(--bpk-link-color, rgb(22, 22, 22))}.bpk-no-touch-support .bpk-link--implicit:hover:not(:active):not(:disabled){color:#161616;color:var(--bpk-link-hover-color, rgb(22, 22, 22))}:global(.bpk-no-touch-support) .bpk-link--implicit:hover:not(:active):not(:disabled){color:#161616;color:var(--bpk-link-hover-color, rgb(22, 22, 22))}.bpk-link--implicit:active{text-decoration:none;color:#161616;color:var(--bpk-link-active-color, rgb(22, 22, 22))}.bpk-link--alternate{color:#fff;color:var(--bpk-link-alternate-color, rgb(255, 255, 255))}.bpk-no-touch-support .bpk-link--alternate:hover:not(:active):not(:disabled){color:#fff;color:var(--bpk-link-alternate-hover-color, rgb(255, 255, 255))}:global(.bpk-no-touch-support) .bpk-link--alternate:hover:not(:active):not(:disabled){color:#fff;color:var(--bpk-link-alternate-hover-color, rgb(255, 255, 255))}.bpk-link--alternate:visited{color:#fff;color:var(--bpk-link-alternate-visited-color, rgb(255, 255, 255))}.bpk-link--alternate:active{color:#fff;color:var(--bpk-link-alternate-active-color, rgb(255, 255, 255))}.bpk-link-underlined{padding-bottom:.0625rem;transition:background-size 200ms ease;background:linear-gradient(rgb(22, 22, 22), rgb(22, 22, 22));background-repeat:no-repeat;background-position:0 100%;background-size:100% 1px}.bpk-no-touch-support .bpk-link-underlined:hover:not(:active):not(:disabled){background-size:0 1px}:global(.bpk-no-touch-support) .bpk-link-underlined:hover:not(:active):not(:disabled){background-size:0 1px}.bpk-link-underlined--implicit{background-size:0 1px}.bpk-no-touch-support .bpk-link-underlined--implicit:hover:not(:active):not(:disabled){background-size:100% 1px}:global(.bpk-no-touch-support) .bpk-link-underlined--implicit:hover:not(:active):not(:disabled){background-size:100% 1px}.bpk-link-underlined--alternate{background:linear-gradient(rgb(255, 255, 255), rgb(255, 255, 255));background-repeat:no-repeat;background-position:0 100%;background-size:100% 1px}.bpk-no-touch-support .bpk-link-underlined--alternate:hover:not(:active):not(:disabled){background-size:0 1px}:global(.bpk-no-touch-support) .bpk-link-underlined--alternate:hover:not(:active):not(:disabled){background-size:0 1px}.bpk-link-underlined-implicit--alternate{background:linear-gradient(rgb(255, 255, 255), rgb(255, 255, 255));background-repeat:no-repeat;background-position:0 100%;background-size:0 1px}.bpk-no-touch-support .bpk-link-underlined-implicit--alternate:hover:not(:active):not(:disabled){background-size:100% 1px}:global(.bpk-no-touch-support) .bpk-link-underlined-implicit--alternate:hover:not(:active):not(:disabled){background-size:100% 1px}
|
|
@@ -23,8 +23,8 @@ The actual component that developers create (i.e. the default export from this p
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { cloneElement, useRef, useState, useEffect } from 'react';
|
|
26
|
-
import { arrow, FloatingArrow, FloatingPortal, offset, shift, useFloating, useHover, useInteractions, useRole } from '@floating-ui/react';
|
|
27
|
-
import { surfaceHighlightDay } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
26
|
+
import { arrow, FloatingArrow, FloatingPortal, offset, safePolygon, shift, useFloating, useFocus, useHover, useInteractions, useRole } from '@floating-ui/react';
|
|
27
|
+
import { surfaceHighlightDay, onePixelRem } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
28
28
|
import { TransitionInitialMount, cssModules } from "../../bpk-react-utils";
|
|
29
29
|
import { ARROW_ID, TOOLTIP_TYPES } from "./constants";
|
|
30
30
|
import STYLES from "./BpkTooltip.module.css";
|
|
@@ -39,12 +39,12 @@ const strokeWidth = 1;
|
|
|
39
39
|
const getArrowAlignment = placement => {
|
|
40
40
|
if (placement.includes('bottom')) {
|
|
41
41
|
return {
|
|
42
|
-
bottom:
|
|
42
|
+
bottom: `calc(100% - ${onePixelRem})`
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
if (placement.includes('top')) {
|
|
46
46
|
return {
|
|
47
|
-
top:
|
|
47
|
+
top: `calc(100% - ${onePixelRem})`
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
return undefined;
|
|
@@ -82,7 +82,8 @@ const BpkTooltip = ({
|
|
|
82
82
|
})]
|
|
83
83
|
});
|
|
84
84
|
const hover = useHover(context, {
|
|
85
|
-
mouseOnly: !hasTouchSupport() || !hideOnTouchDevices
|
|
85
|
+
mouseOnly: !hasTouchSupport() || !hideOnTouchDevices,
|
|
86
|
+
handleClose: safePolygon()
|
|
86
87
|
});
|
|
87
88
|
const role = useRole(context, {
|
|
88
89
|
role: 'tooltip'
|
|
@@ -90,7 +91,7 @@ const BpkTooltip = ({
|
|
|
90
91
|
const {
|
|
91
92
|
getFloatingProps,
|
|
92
93
|
getReferenceProps
|
|
93
|
-
} = useInteractions([hover, role]);
|
|
94
|
+
} = useInteractions([hover, role, useFocus(context)]);
|
|
94
95
|
const targetWithAccessibilityProps = /*#__PURE__*/cloneElement(target, {
|
|
95
96
|
tabIndex: '0',
|
|
96
97
|
'aria-label': ariaLabel,
|
|
@@ -782,7 +782,7 @@
|
|
|
782
782
|
/// }
|
|
783
783
|
|
|
784
784
|
@mixin bpk-link-underlined {
|
|
785
|
-
padding-bottom:
|
|
785
|
+
padding-bottom: $bpk-one-pixel-rem;
|
|
786
786
|
transition: background-size 200ms ease;
|
|
787
787
|
background: linear-gradient($bpk-text-primary-day, $bpk-text-primary-day);
|
|
788
788
|
background-repeat: no-repeat;
|
package/package.json
CHANGED
|
@@ -782,7 +782,7 @@
|
|
|
782
782
|
/// }
|
|
783
783
|
|
|
784
784
|
@mixin bpk-link-underlined {
|
|
785
|
-
padding-bottom:
|
|
785
|
+
padding-bottom: tokens.$bpk-one-pixel-rem;
|
|
786
786
|
transition: background-size 200ms ease;
|
|
787
787
|
background: linear-gradient(tokens.$bpk-text-primary-day, tokens.$bpk-text-primary-day);
|
|
788
788
|
background-repeat: no-repeat;
|