@skyscanner/backpack-web 42.13.3 → 42.15.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-ai-blurb/src/BpkAiBlurbSummary.js +3 -2
- package/bpk-component-ai-blurb/src/common-types.d.ts +5 -5
- package/bpk-component-carousel/src/BpkCarousel.d.ts +1 -1
- package/bpk-component-carousel/src/BpkCarousel.js +7 -4
- package/bpk-component-carousel/src/BpkCarousel.module.css +1 -1
- package/bpk-component-carousel/src/BpkCarouselImage.module.css +1 -1
- package/bpk-component-carousel/src/types.d.ts +8 -0
- package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableColumnHeaderPlaceholder.js +0 -3
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTray.module.css +1 -1
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItem.d.ts +1 -1
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItem.js +18 -20
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItemPlaceholder.d.ts +1 -1
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItemPlaceholder.js +4 -6
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayRoot.d.ts +1 -1
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayRoot.js +4 -4
- package/bpk-component-page-indicator/src/BpkPageIndicator.d.ts +4 -6
- package/bpk-component-page-indicator/src/BpkPageIndicator.js +9 -10
- package/bpk-component-page-indicator/src/BpkPageIndicator.module.css +1 -1
- package/bpk-component-page-indicator/src/NavButton.d.ts +3 -1
- package/bpk-component-page-indicator/src/NavButton.js +42 -20
- package/bpk-component-page-indicator/src/common-types.d.ts +7 -0
- package/bpk-component-page-indicator/src/common-types.js +24 -0
- package/package.json +2 -2
|
@@ -41,8 +41,9 @@ const BpkAiBlurbSummary = props => {
|
|
|
41
41
|
textStyle: TEXT_STYLES.caption,
|
|
42
42
|
children: props.errorText
|
|
43
43
|
}), /*#__PURE__*/_jsx(BpkLink, {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
as: "button",
|
|
45
|
+
onClick: props.onErrorClick,
|
|
46
|
+
children: props.errorActionText
|
|
46
47
|
})]
|
|
47
48
|
});
|
|
48
49
|
}
|
|
@@ -20,12 +20,12 @@ export type BpkAiBlurbSummaryProps = {
|
|
|
20
20
|
} | {
|
|
21
21
|
/** Controls which content is displayed. */
|
|
22
22
|
state: 'error';
|
|
23
|
-
/** Text displayed before the error
|
|
23
|
+
/** Text displayed before the error action. */
|
|
24
24
|
errorText: string;
|
|
25
|
-
/** Text for the inline error
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
25
|
+
/** Text for the inline error action. */
|
|
26
|
+
errorActionText: string;
|
|
27
|
+
/** Called when the inline error action is clicked (e.g. to retry). */
|
|
28
|
+
onErrorClick: () => void;
|
|
29
29
|
};
|
|
30
30
|
export type BpkAiBlurbFeedbackProps = {
|
|
31
31
|
/** Text displayed before a vote is cast. e.g. "Was this helpful?" — not translated by Backpack. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Props } from './types';
|
|
2
|
-
declare const BpkCarousel: ({ accessibilityLabels, bottom, images, initialImageIndex, onImageChanged, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const BpkCarousel: ({ accessibilityLabels, bottom, images, initialImageIndex, onImageChanged, pageIndicatorVariant, showPageIndicatorNav, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default BpkCarousel;
|
|
@@ -30,11 +30,14 @@ const BpkCarousel = ({
|
|
|
30
30
|
bottom,
|
|
31
31
|
images,
|
|
32
32
|
initialImageIndex = 0,
|
|
33
|
-
onImageChanged = null
|
|
33
|
+
onImageChanged = null,
|
|
34
|
+
pageIndicatorVariant = VARIANT.overImageSpaced,
|
|
35
|
+
showPageIndicatorNav
|
|
34
36
|
}) => {
|
|
35
37
|
const [shownImageIndex, updateShownImageIndex] = useState(initialImageIndex);
|
|
36
38
|
const imagesRef = useRef([]);
|
|
37
39
|
const isDesktop = useMediaQuery(BREAKPOINTS.ABOVE_TABLET);
|
|
40
|
+
const showNav = showPageIndicatorNav ?? isDesktop;
|
|
38
41
|
const handleIndicatorClick = (e, newIndex) => {
|
|
39
42
|
e.stopPropagation();
|
|
40
43
|
let target = newIndex;
|
|
@@ -59,12 +62,12 @@ const BpkCarousel = ({
|
|
|
59
62
|
children: /*#__PURE__*/_jsx(BpkPageIndicator, {
|
|
60
63
|
currentIndex: shownImageIndex,
|
|
61
64
|
totalIndicators: images.length,
|
|
62
|
-
variant:
|
|
65
|
+
variant: pageIndicatorVariant,
|
|
63
66
|
indicatorLabel: accessibilityLabels.indicatorLabel ?? "Go to slide",
|
|
64
67
|
prevNavLabel: accessibilityLabels.prevNavLabel ?? "Previous slide",
|
|
65
68
|
nextNavLabel: accessibilityLabels.nextNavLabel ?? "Next slide",
|
|
66
|
-
showNav:
|
|
67
|
-
onClick:
|
|
69
|
+
showNav: showNav,
|
|
70
|
+
onClick: showNav ? handleIndicatorClick : () => {}
|
|
68
71
|
})
|
|
69
72
|
})]
|
|
70
73
|
});
|
|
@@ -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-carousel{position:relative;width:100%;height:100%}.bpk-carousel__page-indicator-over-image{position:absolute;right:0;bottom:.25rem;left:0;display:flex;margin:auto 1rem;justify-content:center
|
|
18
|
+
.bpk-carousel{position:relative;width:100%;height:100%}.bpk-carousel__page-indicator-over-image{position:absolute;right:0;bottom:.25rem;left:0;display:flex;margin:auto 1rem;justify-content:center}
|
|
@@ -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-carousel-image{display:inline-flex;width:100%;min-width:0;height:100%;min-height:0;justify-content:center;scroll-snap-align:start;scroll-snap-stop:always;isolation:isolate}.bpk-carousel-image img{max-width:100%;max-height:100%;object-fit:initial}
|
|
18
|
+
.bpk-carousel-image{display:inline-flex;width:100%;min-width:0;height:100%;min-height:0;justify-content:center;scroll-snap-align:start;scroll-snap-stop:always;isolation:isolate}.bpk-carousel-image img{display:block;max-width:100%;max-height:100%;object-fit:initial}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { VARIANT } from '../../bpk-component-page-indicator';
|
|
2
3
|
export type OnImageChangedHandler = ((shownImageIndex: number) => void) | null | undefined;
|
|
3
4
|
export type AccessibilityLabels = {
|
|
4
5
|
indicatorLabel?: string;
|
|
5
6
|
prevNavLabel?: string;
|
|
6
7
|
nextNavLabel?: string;
|
|
7
8
|
};
|
|
9
|
+
export type PageIndicatorVariant = typeof VARIANT.overImageSpaced | typeof VARIANT.carousel;
|
|
8
10
|
export type Props = {
|
|
9
11
|
images: ReactNode[];
|
|
10
12
|
initialImageIndex?: number;
|
|
@@ -14,4 +16,10 @@ export type Props = {
|
|
|
14
16
|
*/
|
|
15
17
|
bottom?: number;
|
|
16
18
|
accessibilityLabels?: AccessibilityLabels;
|
|
19
|
+
pageIndicatorVariant?: PageIndicatorVariant;
|
|
20
|
+
/**
|
|
21
|
+
* Force the page indicator's nav buttons on or off.
|
|
22
|
+
* When omitted, the nav buttons are shown on desktop breakpoints only.
|
|
23
|
+
*/
|
|
24
|
+
showPageIndicatorNav?: boolean;
|
|
17
25
|
};
|
|
@@ -19,10 +19,7 @@
|
|
|
19
19
|
import BpkButton, { BUTTON_TYPES, SIZE_TYPES } from "../../../bpk-component-button";
|
|
20
20
|
import { BpkFlex, BpkSpacing } from "../../../bpk-component-layout";
|
|
21
21
|
import BpkText, { TEXT_COLORS, TEXT_STYLES } from "../../../bpk-component-text";
|
|
22
|
-
import { cssModules } from "../../../bpk-react-utils";
|
|
23
|
-
import STYLES from "./BpkComparisonTable.module.css";
|
|
24
22
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
-
const getClassName = cssModules(STYLES);
|
|
26
23
|
const BpkComparisonTableColumnHeaderPlaceholder = ({
|
|
27
24
|
addMoreDescription,
|
|
28
25
|
addMoreLinkText,
|
|
@@ -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-comparison-tray{width:22.1875rem;max-width:100%}@media(max-width: 32rem){.bpk-comparison-tray{width:auto;min-width:0;flex:1}}.bpk-comparison-tray__item{position:relative;width:3.875rem;
|
|
18
|
+
.bpk-comparison-tray{width:22.1875rem;max-width:100%}@media(max-width: 32rem){.bpk-comparison-tray{width:auto;min-width:0;flex:1}}.bpk-comparison-tray__item{position:relative;width:3.875rem;min-width:0;flex-shrink:1;aspect-ratio:62/28}.bpk-comparison-tray__item-image-container{width:100%;height:100%;background-color:#eff3f8;overflow:hidden;border-radius:.25rem}.bpk-comparison-tray__item-image-container img{height:100%;object-fit:contain}.bpk-comparison-tray__item-close{position:relative;position:absolute;top:0;inset-inline-end:calc(-8*0.0625rem);display:flex;width:1rem;height:1rem;justify-content:center;align-items:center;transform:translateY(-50%);border:.125rem solid #fff;border-radius:50%;background-color:#161616;color:#fff;cursor:pointer;box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}.bpk-comparison-tray__item-close::before{position:absolute;top:calc(-2.75rem/2 + 50%);left:calc(-2.75rem/2 + 50%);content:"";width:2.75rem;height:2.75rem}.bpk-comparison-tray__item-close svg{width:.5rem;height:.5rem;flex-shrink:0;fill:#fff}.bpk-comparison-tray__item-close:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-comparison-tray__item-placeholder{width:3.875rem;min-width:0;flex-shrink:1;border:.0625rem dashed #c1c7cf;aspect-ratio:62/28;border-radius:.25rem}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BpkComparisonTrayItemProps } from './common-types';
|
|
2
|
-
declare
|
|
2
|
+
declare const BpkComparisonTrayItem: ({ item, onRemove, removeLabel }: BpkComparisonTrayItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default BpkComparisonTrayItem;
|
|
@@ -22,27 +22,25 @@ import { cssModules } from "../../../bpk-react-utils";
|
|
|
22
22
|
import STYLES from "./BpkComparisonTray.module.css";
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
const getClassName = cssModules(STYLES);
|
|
25
|
-
|
|
25
|
+
const BpkComparisonTrayItem = ({
|
|
26
26
|
item,
|
|
27
27
|
onRemove,
|
|
28
28
|
removeLabel
|
|
29
|
-
}) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
}
|
|
29
|
+
}) => /*#__PURE__*/_jsxs("div", {
|
|
30
|
+
className: getClassName('bpk-comparison-tray__item'),
|
|
31
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
32
|
+
className: getClassName('bpk-comparison-tray__item-image-container'),
|
|
33
|
+
children: /*#__PURE__*/_jsx(BpkImage, {
|
|
34
|
+
src: item.image,
|
|
35
|
+
altText: item.imageAlt ?? item.label,
|
|
36
|
+
aspectRatio: 62 / 28
|
|
37
|
+
})
|
|
38
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
39
|
+
type: "button",
|
|
40
|
+
className: getClassName('bpk-comparison-tray__item-close'),
|
|
41
|
+
"aria-label": removeLabel,
|
|
42
|
+
onClick: () => onRemove(item.id),
|
|
43
|
+
children: /*#__PURE__*/_jsx(CloseIcon, {})
|
|
44
|
+
})]
|
|
45
|
+
});
|
|
48
46
|
export default BpkComparisonTrayItem;
|
package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItemPlaceholder.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare const BpkComparisonTrayItemPlaceholder: () => import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default BpkComparisonTrayItemPlaceholder;
|
package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItemPlaceholder.js
CHANGED
|
@@ -20,10 +20,8 @@ import { cssModules } from "../../../bpk-react-utils";
|
|
|
20
20
|
import STYLES from "./BpkComparisonTray.module.css";
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
22
|
const getClassName = cssModules(STYLES);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
}
|
|
23
|
+
const BpkComparisonTrayItemPlaceholder = () => /*#__PURE__*/_jsx("div", {
|
|
24
|
+
className: getClassName('bpk-comparison-tray__item-placeholder'),
|
|
25
|
+
"aria-hidden": "true"
|
|
26
|
+
});
|
|
29
27
|
export default BpkComparisonTrayItemPlaceholder;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BpkComparisonTrayRootProps } from './common-types';
|
|
2
|
-
declare
|
|
2
|
+
declare const BpkComparisonTrayRoot: ({ ariaLabel, compareLabel, items, onCompare, onRemove, removeLabel, }: BpkComparisonTrayRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default BpkComparisonTrayRoot;
|
|
@@ -26,14 +26,14 @@ import STYLES from "./BpkComparisonTray.module.css";
|
|
|
26
26
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
27
|
const getClassName = cssModules(STYLES);
|
|
28
28
|
const MAX_ITEMS = 3;
|
|
29
|
-
|
|
29
|
+
const BpkComparisonTrayRoot = ({
|
|
30
30
|
ariaLabel,
|
|
31
31
|
compareLabel,
|
|
32
32
|
items,
|
|
33
33
|
onCompare,
|
|
34
34
|
onRemove,
|
|
35
35
|
removeLabel
|
|
36
|
-
}) {
|
|
36
|
+
}) => {
|
|
37
37
|
const displayItems = Array.from({
|
|
38
38
|
length: MAX_ITEMS
|
|
39
39
|
}, (_value, index) => items[index] ?? null);
|
|
@@ -45,7 +45,7 @@ function BpkComparisonTrayRoot({
|
|
|
45
45
|
role: "region",
|
|
46
46
|
"aria-label": ariaLabel,
|
|
47
47
|
children: /*#__PURE__*/_jsxs(BpkCardV2.Body, {
|
|
48
|
-
templateColumns: "1fr auto",
|
|
48
|
+
templateColumns: "minmax(0, 1fr) auto",
|
|
49
49
|
align: "center",
|
|
50
50
|
gap: BpkSpacing.Base,
|
|
51
51
|
children: [/*#__PURE__*/_jsx(BpkCardV2.Section, {
|
|
@@ -71,5 +71,5 @@ function BpkComparisonTrayRoot({
|
|
|
71
71
|
})
|
|
72
72
|
})
|
|
73
73
|
});
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
75
|
export default BpkComparisonTrayRoot;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { MouseEvent } from 'react';
|
|
2
2
|
import { DIRECTIONS } from './NavButton';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
type Variant = (typeof VARIANT)[keyof typeof VARIANT];
|
|
3
|
+
import { VARIANT } from './common-types';
|
|
4
|
+
import type { Variant } from './common-types';
|
|
5
|
+
export { VARIANT };
|
|
6
|
+
export type { Variant };
|
|
9
7
|
type Direction = (typeof DIRECTIONS)[keyof typeof DIRECTIONS];
|
|
10
8
|
export type Props = {
|
|
11
9
|
indicatorLabel?: string;
|
|
@@ -19,16 +19,13 @@
|
|
|
19
19
|
import { BUTTON_TYPES } from "../../bpk-component-button";
|
|
20
20
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
21
|
import NavButton, { DIRECTIONS } from "./NavButton";
|
|
22
|
+
import { VARIANT } from "./common-types";
|
|
22
23
|
import STYLES from "./BpkPageIndicator.module.css";
|
|
23
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
25
|
const getClassName = cssModules(STYLES);
|
|
25
26
|
const DISPLAYED_TOTAL = 5;
|
|
26
27
|
const START_SCROLL_INDEX = Math.floor(DISPLAYED_TOTAL / 2);
|
|
27
|
-
export
|
|
28
|
-
default: 'default',
|
|
29
|
-
overImage: 'overImage',
|
|
30
|
-
overImageSpaced: 'overImageSpaced'
|
|
31
|
-
};
|
|
28
|
+
export { VARIANT };
|
|
32
29
|
const BpkPageIndicator = ({
|
|
33
30
|
className = undefined,
|
|
34
31
|
currentIndex,
|
|
@@ -50,7 +47,7 @@ const BpkPageIndicator = ({
|
|
|
50
47
|
'--scroll-index': totalIndicators > DISPLAYED_TOTAL ? Math.min(currentIndex - START_SCROLL_INDEX, totalIndicators - DISPLAYED_TOTAL) : 0
|
|
51
48
|
};
|
|
52
49
|
return /*#__PURE__*/_jsx("div", {
|
|
53
|
-
className: variant === VARIANT.overImageSpaced ? getClassName('bpk-page-indicator-fullWidth__container') : className,
|
|
50
|
+
className: variant === VARIANT.overImageSpaced || variant === VARIANT.carousel ? getClassName('bpk-page-indicator-fullWidth__container') : className,
|
|
54
51
|
"aria-hidden": isInteractive ? 'false' : 'true',
|
|
55
52
|
"data-testid": "indicator-container",
|
|
56
53
|
children: /*#__PURE__*/_jsxs("div", {
|
|
@@ -59,10 +56,11 @@ const BpkPageIndicator = ({
|
|
|
59
56
|
children: [showNav && /*#__PURE__*/_jsx(NavButton, {
|
|
60
57
|
currentIndex: currentIndex,
|
|
61
58
|
onClick: onClick,
|
|
62
|
-
disabled: variant === VARIANT.overImageSpaced ? totalIndicators <= 1 : currentIndex === 0 || totalIndicators <= 1,
|
|
59
|
+
disabled: variant === VARIANT.overImageSpaced || variant === VARIANT.carousel ? totalIndicators <= 1 : currentIndex === 0 || totalIndicators <= 1,
|
|
63
60
|
direction: DIRECTIONS.PREV,
|
|
64
61
|
ariaLabel: prevNavLabel,
|
|
65
|
-
|
|
62
|
+
variant: variant,
|
|
63
|
+
type: variant === VARIANT.overImageSpaced || variant === VARIANT.carousel ? BUTTON_TYPES.secondaryOnDark : BUTTON_TYPES.link
|
|
66
64
|
}), /*#__PURE__*/_jsx("div", {
|
|
67
65
|
className: getClassName('bpk-page-indicator__container'),
|
|
68
66
|
children: /*#__PURE__*/_jsx("div", {
|
|
@@ -85,10 +83,11 @@ const BpkPageIndicator = ({
|
|
|
85
83
|
}), showNav && /*#__PURE__*/_jsx(NavButton, {
|
|
86
84
|
currentIndex: currentIndex,
|
|
87
85
|
onClick: onClick,
|
|
88
|
-
disabled: variant === VARIANT.overImageSpaced ? totalIndicators <= 1 : currentIndex === totalIndicators - 1 || totalIndicators <= 1,
|
|
86
|
+
disabled: variant === VARIANT.overImageSpaced || variant === VARIANT.carousel ? totalIndicators <= 1 : currentIndex === totalIndicators - 1 || totalIndicators <= 1,
|
|
89
87
|
ariaLabel: nextNavLabel,
|
|
90
88
|
direction: DIRECTIONS.NEXT,
|
|
91
|
-
|
|
89
|
+
variant: variant,
|
|
90
|
+
type: variant === VARIANT.overImageSpaced || variant === VARIANT.carousel ? BUTTON_TYPES.secondaryOnDark : BUTTON_TYPES.link
|
|
92
91
|
})]
|
|
93
92
|
})
|
|
94
93
|
});
|
|
@@ -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-page-indicator-fullWidth__container{width:100%}.bpk-page-indicator{display:flex;width:100%;justify-content:center;align-items:center}.bpk-page-indicator__showNav{justify-content:space-between}.bpk-page-indicator__container{max-width:5rem;min-height:.5rem;overflow:hidden}.bpk-page-indicator__indicators-container{--direction: -1;transform:translateX(calc(var(--direction) * var(--scroll-index, 0) * 1rem));transition:transform 200ms ease-in-out;white-space:nowrap}html[dir=rtl] .bpk-page-indicator__indicators-container{--direction: 1}.bpk-page-indicator__indicator{display:inline-block;width:.5rem;height:.5rem;padding:0;border:none;border-radius:50%;margin-inline:.25rem}.bpk-page-indicator__indicator:hover{cursor:pointer}.bpk-page-indicator__indicator--default{background-color:#c1c7cf}.bpk-page-indicator__indicator--overImage,.bpk-page-indicator__indicator--overImageSpaced{background-color:hsla(0,0%,100%,.5)}.bpk-page-indicator__indicator--active-default{background-color:#626971;pointer-events:none}.bpk-page-indicator__indicator--active-overImage,.bpk-page-indicator__indicator--active-overImageSpaced{background-color:#fff;pointer-events:none}
|
|
18
|
+
.bpk-page-indicator-fullWidth__container{width:100%}.bpk-page-indicator{display:flex;width:100%;justify-content:center;align-items:center}.bpk-page-indicator__showNav{justify-content:space-between}.bpk-page-indicator__container{max-width:5rem;min-height:.5rem;overflow:hidden}.bpk-page-indicator__indicators-container{--direction: -1;transform:translateX(calc(var(--direction) * var(--scroll-index, 0) * 1rem));transition:transform 200ms ease-in-out;white-space:nowrap}html[dir=rtl] .bpk-page-indicator__indicators-container{--direction: 1}.bpk-page-indicator__indicator{display:inline-block;width:.5rem;height:.5rem;padding:0;border:none;border-radius:50%;margin-inline:.25rem}.bpk-page-indicator__indicator:hover{cursor:pointer}.bpk-page-indicator__indicator--default{background-color:#c1c7cf}.bpk-page-indicator__indicator--overImage,.bpk-page-indicator__indicator--overImageSpaced,.bpk-page-indicator__indicator--carousel{background-color:hsla(0,0%,100%,.5)}.bpk-page-indicator__indicator--active-default{background-color:#626971;pointer-events:none}.bpk-page-indicator__indicator--active-overImage,.bpk-page-indicator__indicator--active-overImageSpaced,.bpk-page-indicator__indicator--active-carousel{background-color:#fff;pointer-events:none}.bpk-page-indicator__nav-carousel{--bpk-button-border-radius: 50%;--bpk-button-secondary-on-dark-background-color: rgba(255, 255, 255, 0.5);--bpk-button-secondary-on-dark-hover-background-color: rgba(255, 255, 255, 0.8);--bpk-button-secondary-on-dark-active-background-color: rgba(255, 255, 255, 0.8);--bpk-button-secondary-on-dark-text-color: rgb(22, 22, 22);--bpk-button-secondary-on-dark-hover-text-color: rgb(22, 22, 22);--bpk-button-secondary-on-dark-active-text-color: rgb(22, 22, 22)}.bpk-page-indicator__nav-carousel-button{display:inline-flex;width:2rem;height:2rem;min-height:2rem;padding:0;justify-content:center;align-items:center}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MouseEvent } from 'react';
|
|
2
2
|
import { BUTTON_TYPES } from '../../bpk-component-button';
|
|
3
|
+
import type { Variant } from './common-types';
|
|
3
4
|
export declare const DIRECTIONS: {
|
|
4
5
|
readonly PREV: "PREV";
|
|
5
6
|
readonly INDICATORS: "INDICATORS";
|
|
@@ -14,6 +15,7 @@ type Props = {
|
|
|
14
15
|
disabled?: boolean;
|
|
15
16
|
onClick?: (event: MouseEvent<HTMLButtonElement>, newIndex: number, direction: Direction) => void;
|
|
16
17
|
type?: ButtonType;
|
|
18
|
+
variant?: Variant;
|
|
17
19
|
};
|
|
18
|
-
declare const NavButton: ({ ariaLabel, currentIndex, direction, disabled, onClick, type, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare const NavButton: ({ ariaLabel, currentIndex, direction, disabled, onClick, type, variant, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
19
21
|
export default NavButton;
|
|
@@ -17,36 +17,58 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import
|
|
20
|
+
import { withButtonAlignment, withRtlSupport } from "../../bpk-component-icon";
|
|
21
|
+
import SmallLeftArrowIcon from "../../bpk-component-icon/sm/chevron-left";
|
|
22
|
+
import SmallRightArrowIcon from "../../bpk-component-icon/sm/chevron-right";
|
|
23
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
24
|
+
import { VARIANT } from "./common-types";
|
|
25
|
+
import STYLES from "./BpkPageIndicator.module.css";
|
|
23
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
|
+
const getClassName = cssModules(STYLES);
|
|
24
28
|
export const DIRECTIONS = {
|
|
25
29
|
PREV: 'PREV',
|
|
26
30
|
INDICATORS: 'INDICATORS',
|
|
27
31
|
NEXT: 'NEXT'
|
|
28
32
|
};
|
|
29
|
-
const AlignedLeftArrowIcon =
|
|
30
|
-
const AlignedRightArrowIcon =
|
|
33
|
+
const AlignedLeftArrowIcon = withButtonAlignment(withRtlSupport(SmallLeftArrowIcon));
|
|
34
|
+
const AlignedRightArrowIcon = withButtonAlignment(withRtlSupport(SmallRightArrowIcon));
|
|
35
|
+
const RtlSmallLeftArrowIcon = withRtlSupport(SmallLeftArrowIcon);
|
|
36
|
+
const RtlSmallRightArrowIcon = withRtlSupport(SmallRightArrowIcon);
|
|
31
37
|
const NavButton = ({
|
|
32
38
|
ariaLabel,
|
|
33
39
|
currentIndex,
|
|
34
40
|
direction,
|
|
35
41
|
disabled = false,
|
|
36
42
|
onClick = () => {},
|
|
37
|
-
type = BUTTON_TYPES.link
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
type = BUTTON_TYPES.link,
|
|
44
|
+
variant
|
|
45
|
+
}) => {
|
|
46
|
+
const isCarousel = variant === VARIANT.carousel;
|
|
47
|
+
const PrevIcon = isCarousel ? RtlSmallLeftArrowIcon : AlignedLeftArrowIcon;
|
|
48
|
+
const NextIcon = isCarousel ? RtlSmallRightArrowIcon : AlignedRightArrowIcon;
|
|
49
|
+
const button = /*#__PURE__*/_jsx(BpkButton, {
|
|
50
|
+
iconOnly: true,
|
|
51
|
+
type: type
|
|
52
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
53
|
+
,
|
|
54
|
+
className: isCarousel ? getClassName('bpk-page-indicator__nav-carousel-button') : undefined,
|
|
55
|
+
onClick: e => {
|
|
56
|
+
if (direction === DIRECTIONS.PREV) {
|
|
57
|
+
onClick(e, currentIndex - 1, direction);
|
|
58
|
+
} else {
|
|
59
|
+
onClick(e, currentIndex + 1, direction);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"aria-label": ariaLabel,
|
|
63
|
+
disabled: disabled,
|
|
64
|
+
children: direction === DIRECTIONS.PREV ? /*#__PURE__*/_jsx(PrevIcon, {}) : /*#__PURE__*/_jsx(NextIcon, {})
|
|
65
|
+
});
|
|
66
|
+
if (isCarousel) {
|
|
67
|
+
return /*#__PURE__*/_jsx("span", {
|
|
68
|
+
className: getClassName('bpk-page-indicator__nav-carousel'),
|
|
69
|
+
children: button
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return button;
|
|
73
|
+
};
|
|
52
74
|
export default NavButton;
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
export const VARIANT = {
|
|
20
|
+
default: 'default',
|
|
21
|
+
overImage: 'overImage',
|
|
22
|
+
overImageSpaced: 'overImageSpaced',
|
|
23
|
+
carousel: 'carousel'
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "42.
|
|
3
|
+
"version": "42.15.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
|
29
29
|
"@radix-ui/react-slider": "1.3.5",
|
|
30
30
|
"@react-google-maps/api": "^2.19.3",
|
|
31
|
-
"@skyscanner/bpk-foundations-web": "^24.
|
|
31
|
+
"@skyscanner/bpk-foundations-web": "^24.5.0",
|
|
32
32
|
"@skyscanner/bpk-svgs": "^20.11.0",
|
|
33
33
|
"tabbable": "^6.4.0",
|
|
34
34
|
"d3-path": "^3.1.0",
|