@skyscanner/backpack-web 37.7.1 → 37.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-card-list/index.d.ts +1 -1
- package/bpk-component-card-list/src/BpkCardList.js +77 -15
- package/bpk-component-card-list/src/BpkCardListGridStack/BpkCardListGridStack.d.ts +3 -0
- package/bpk-component-card-list/src/BpkCardListGridStack/BpkCardListGridStack.js +89 -0
- package/bpk-component-card-list/src/BpkCardListGridStack/BpkCardListGridStack.module.css +18 -0
- package/bpk-component-card-list/src/BpkCardListGridStack/index.d.ts +2 -0
- package/bpk-component-card-list/src/BpkCardListGridStack/index.js +20 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.d.ts +3 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.js +103 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.module.css +18 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListRowRailContainer.d.ts +3 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListRowRailContainer.js +67 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListRowRailContainer.module.css +18 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/constants.d.ts +2 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/constants.js +20 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/index.d.ts +2 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/index.js +20 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/utils.d.ts +5 -0
- package/bpk-component-card-list/src/BpkCardListRowRail/utils.js +112 -0
- package/bpk-component-card-list/src/BpkExpand/ExpandAccessoryContent.d.ts +3 -0
- package/bpk-component-card-list/src/BpkExpand/ExpandAccessoryContent.js +37 -0
- package/bpk-component-card-list/src/BpkExpand/index.d.ts +2 -0
- package/bpk-component-card-list/src/BpkExpand/index.js +20 -0
- package/bpk-component-card-list/src/common-types.d.ts +64 -2
- package/bpk-component-card-list/src/common-types.js +34 -1
- package/bpk-component-card-list/testMocks.js +27 -0
- package/bpk-component-drawer/src/BpkDrawer.d.ts +2 -1
- package/bpk-component-drawer/src/BpkDrawer.js +2 -0
- package/bpk-component-icon/lg/flame.js +14 -0
- package/bpk-component-icon/lg/incompatible.js +14 -0
- package/bpk-component-icon/sm/flame.js +14 -0
- package/bpk-component-icon/sm/incompatible.js +14 -0
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BpkCardList from
|
|
1
|
+
import BpkCardList from './src/BpkCardList';
|
|
2
2
|
export default BpkCardList;
|
|
@@ -15,37 +15,99 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
import BpkBreakpoint, { BREAKPOINTS } from "../../bpk-component-breakpoint";
|
|
19
19
|
import { BpkButtonV2 } from "../../bpk-component-button";
|
|
20
20
|
import BpkSectionHeader from "../../bpk-component-section-header";
|
|
21
21
|
import { cssModules } from "../../bpk-react-utils";
|
|
22
|
+
import BpkCardListGridStack from "./BpkCardListGridStack";
|
|
23
|
+
import BpkCardListRowRailContainer from "./BpkCardListRowRail";
|
|
24
|
+
import { ACCESSORY_DESKTOP_TYPES, ACCESSORY_MOBILE_TYPES, LAYOUTS } from "./common-types";
|
|
22
25
|
import STYLES from "./BpkCardList.module.css";
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
27
|
const getClassName = cssModules(STYLES);
|
|
28
|
+
const DEFAULT_ITEMS = 3;
|
|
25
29
|
const BpkCardList = props => {
|
|
26
30
|
const {
|
|
31
|
+
accessoryDesktop,
|
|
32
|
+
accessoryMobile,
|
|
33
|
+
buttonContent,
|
|
27
34
|
buttonHref,
|
|
28
|
-
|
|
35
|
+
cardList,
|
|
36
|
+
chipGroup,
|
|
29
37
|
description,
|
|
38
|
+
expandText,
|
|
39
|
+
initiallyShownCardsDesktop = DEFAULT_ITEMS,
|
|
40
|
+
initiallyShownCardsMobile = DEFAULT_ITEMS,
|
|
41
|
+
layoutDesktop,
|
|
42
|
+
layoutMobile,
|
|
30
43
|
onButtonClick,
|
|
44
|
+
onExpandClick,
|
|
31
45
|
title
|
|
32
46
|
} = props;
|
|
33
|
-
const
|
|
47
|
+
const shouldShowHeaderButton = isMobile => {
|
|
48
|
+
if (!buttonContent) return false;
|
|
49
|
+
if (isMobile) {
|
|
50
|
+
return accessoryMobile !== ACCESSORY_MOBILE_TYPES.button;
|
|
51
|
+
}
|
|
52
|
+
return accessoryDesktop !== ACCESSORY_DESKTOP_TYPES.button;
|
|
53
|
+
};
|
|
54
|
+
const headerButton = buttonContent && /*#__PURE__*/_jsx(BpkButtonV2, {
|
|
34
55
|
onClick: onButtonClick,
|
|
35
56
|
href: buttonHref,
|
|
36
|
-
|
|
57
|
+
"data-testid": "bpk-card-list-header-button",
|
|
58
|
+
children: buttonContent
|
|
37
59
|
});
|
|
38
|
-
return /*#__PURE__*/
|
|
60
|
+
return /*#__PURE__*/_jsx("div", {
|
|
39
61
|
className: getClassName('bpk-card-list'),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
"data-testid": "bpk-card-list",
|
|
63
|
+
children: /*#__PURE__*/_jsx(BpkBreakpoint, {
|
|
64
|
+
query: BREAKPOINTS.MOBILE,
|
|
65
|
+
children: isMobile => /*#__PURE__*/_jsxs(_Fragment, {
|
|
66
|
+
children: [/*#__PURE__*/_jsx(BpkSectionHeader, {
|
|
67
|
+
title: title,
|
|
68
|
+
description: description,
|
|
69
|
+
button: shouldShowHeaderButton(isMobile) ? headerButton : null
|
|
70
|
+
}), chipGroup, /*#__PURE__*/_jsx("div", {
|
|
71
|
+
className: getClassName('bpk-card-list--card-list'),
|
|
72
|
+
"data-testid": "bpk-card-list--card-list",
|
|
73
|
+
children: isMobile ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
74
|
+
children: [layoutMobile === LAYOUTS.rail && /*#__PURE__*/_jsx(BpkCardListRowRailContainer, {
|
|
75
|
+
initiallyShownCards: initiallyShownCardsMobile,
|
|
76
|
+
layout: layoutMobile,
|
|
77
|
+
isMobile: true,
|
|
78
|
+
children: cardList
|
|
79
|
+
}), layoutMobile === LAYOUTS.stack && /*#__PURE__*/_jsx(BpkCardListGridStack, {
|
|
80
|
+
accessory: accessoryMobile,
|
|
81
|
+
initiallyShownCards: initiallyShownCardsMobile,
|
|
82
|
+
buttonContent: buttonContent,
|
|
83
|
+
expandText: expandText,
|
|
84
|
+
onButtonClick: onButtonClick,
|
|
85
|
+
onExpandClick: onExpandClick,
|
|
86
|
+
layout: layoutMobile,
|
|
87
|
+
buttonHref: buttonHref,
|
|
88
|
+
children: cardList
|
|
89
|
+
})]
|
|
90
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
91
|
+
children: [layoutDesktop === LAYOUTS.row && accessoryDesktop !== ACCESSORY_DESKTOP_TYPES.expand && accessoryDesktop !== ACCESSORY_DESKTOP_TYPES.button && /*#__PURE__*/_jsx(BpkCardListRowRailContainer, {
|
|
92
|
+
accessory: accessoryDesktop,
|
|
93
|
+
initiallyShownCards: initiallyShownCardsDesktop,
|
|
94
|
+
layout: layoutDesktop,
|
|
95
|
+
children: cardList
|
|
96
|
+
}), layoutDesktop === LAYOUTS.grid && accessoryDesktop !== ACCESSORY_DESKTOP_TYPES.pagination && /*#__PURE__*/_jsx(BpkCardListGridStack, {
|
|
97
|
+
accessory: accessoryDesktop,
|
|
98
|
+
initiallyShownCards: initiallyShownCardsDesktop,
|
|
99
|
+
buttonContent: buttonContent,
|
|
100
|
+
expandText: expandText,
|
|
101
|
+
onButtonClick: onButtonClick,
|
|
102
|
+
onExpandClick: onExpandClick,
|
|
103
|
+
layout: layoutDesktop,
|
|
104
|
+
buttonHref: buttonHref,
|
|
105
|
+
children: cardList
|
|
106
|
+
})]
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
})
|
|
110
|
+
})
|
|
49
111
|
});
|
|
50
112
|
};
|
|
51
113
|
export default BpkCardList;
|
|
@@ -0,0 +1,89 @@
|
|
|
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 { Children, useState } from 'react';
|
|
20
|
+
import { BpkButtonV2 } from "../../../bpk-component-button";
|
|
21
|
+
import { cssModules } from "../../../bpk-react-utils";
|
|
22
|
+
import ExpandAccessoryContent from "../BpkExpand/ExpandAccessoryContent";
|
|
23
|
+
import { ACCESSORY_DESKTOP_TYPES } from "../common-types";
|
|
24
|
+
import STYLES from "./BpkCardListGridStack.module.css";
|
|
25
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
+
const getClassName = cssModules(STYLES);
|
|
27
|
+
const BpkCardListGridStack = props => {
|
|
28
|
+
const {
|
|
29
|
+
accessory,
|
|
30
|
+
buttonContent,
|
|
31
|
+
buttonHref,
|
|
32
|
+
children,
|
|
33
|
+
expandText,
|
|
34
|
+
initiallyShownCards,
|
|
35
|
+
layout,
|
|
36
|
+
onButtonClick,
|
|
37
|
+
onExpandClick
|
|
38
|
+
} = props;
|
|
39
|
+
const gridStyle = {
|
|
40
|
+
'--initially-shown-cards': initiallyShownCards
|
|
41
|
+
};
|
|
42
|
+
const isExpandType = accessory === ACCESSORY_DESKTOP_TYPES.expand; // or ACCESSORY_MOBILE_TYPES.expand
|
|
43
|
+
const defaultInitiallyShownCards = isExpandType ? initiallyShownCards : children.length;
|
|
44
|
+
const showExpand = isExpandType ? children.length > defaultInitiallyShownCards : false;
|
|
45
|
+
const [collapsed, setCollapsed] = useState(true);
|
|
46
|
+
const showButton = accessory === ACCESSORY_DESKTOP_TYPES.button;
|
|
47
|
+
const childrenArray = Children.toArray(children);
|
|
48
|
+
const initialCards = childrenArray.slice(0, defaultInitiallyShownCards);
|
|
49
|
+
const restCards = childrenArray.slice(defaultInitiallyShownCards, childrenArray.length);
|
|
50
|
+
const onExpandToggle = () => {
|
|
51
|
+
setCollapsed(prev => !prev);
|
|
52
|
+
onExpandClick?.();
|
|
53
|
+
};
|
|
54
|
+
const expandAccessoryContent = /*#__PURE__*/_jsx(ExpandAccessoryContent, {
|
|
55
|
+
collapsed: collapsed,
|
|
56
|
+
onExpandToggle: onExpandToggle,
|
|
57
|
+
children: expandText || ''
|
|
58
|
+
});
|
|
59
|
+
const buttonAccessoryContent = /*#__PURE__*/_jsx("div", {
|
|
60
|
+
className: getClassName('bpk-card-list-grid-stack__accessory__button'),
|
|
61
|
+
children: /*#__PURE__*/_jsx(BpkButtonV2, {
|
|
62
|
+
"data-testid": "bpk-card-list__accessory-button",
|
|
63
|
+
onClick: onButtonClick,
|
|
64
|
+
href: buttonHref,
|
|
65
|
+
children: buttonContent
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
69
|
+
className: getClassName('bpk-card-list-grid-stack'),
|
|
70
|
+
"data-testid": "bpk-card-list-grid-stack",
|
|
71
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
72
|
+
className: getClassName(`bpk-card-list-grid-stack__${layout}`),
|
|
73
|
+
"data-testid": "bpk-card-list-grid-stack__initial-content",
|
|
74
|
+
style: gridStyle,
|
|
75
|
+
children: initialCards
|
|
76
|
+
}), showButton && buttonAccessoryContent, showExpand &&
|
|
77
|
+
/*#__PURE__*/
|
|
78
|
+
// This is for A11y considerations
|
|
79
|
+
_jsxs(_Fragment, {
|
|
80
|
+
children: [collapsed === true && expandAccessoryContent, /*#__PURE__*/_jsx("div", {
|
|
81
|
+
className: getClassName(`bpk-card-list-grid-stack__${layout}`),
|
|
82
|
+
"data-testid": "bpk-card-list-grid-stack__expanded-content",
|
|
83
|
+
style: gridStyle,
|
|
84
|
+
children: collapsed === false && restCards
|
|
85
|
+
}), collapsed === false && expandAccessoryContent]
|
|
86
|
+
})]
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
export default BpkCardListGridStack;
|
|
@@ -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
|
+
.bpk-card-list-grid-stack{display:grid;gap:1.5rem}.bpk-card-list-grid-stack__grid{display:grid;grid-template-columns:repeat(var(--initially-shown-cards, 3), auto);gap:1.5rem}.bpk-card-list-grid-stack__stack{display:grid;grid-template-columns:1;gap:1.5rem}.bpk-card-list-grid-stack__accessory__button{width:auto}
|
|
@@ -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 BpkCardListGridStack from "./BpkCardListGridStack";
|
|
20
|
+
export default BpkCardListGridStack;
|
|
@@ -0,0 +1,103 @@
|
|
|
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 { useRef, useState, useEffect, isValidElement, Children } from 'react';
|
|
20
|
+
import { cssModules } from "../../../bpk-react-utils";
|
|
21
|
+
import { RENDER_BUFFER_SIZE } from "./constants";
|
|
22
|
+
import { lockScroll, setA11yTabIndex, useUpdateCurrentIndexByVisibility, useScrollToCard, useIntersectionObserver } from "./utils";
|
|
23
|
+
import STYLES from "./BpkCardListCarousel.module.css";
|
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
+
const getClassName = cssModules(STYLES);
|
|
26
|
+
const BpkCardListCarousel = props => {
|
|
27
|
+
const {
|
|
28
|
+
children,
|
|
29
|
+
currentIndex,
|
|
30
|
+
initiallyShownCards,
|
|
31
|
+
isMobile = false,
|
|
32
|
+
layout,
|
|
33
|
+
setCurrentIndex
|
|
34
|
+
} = props;
|
|
35
|
+
const shownNumberStyle = {
|
|
36
|
+
'--initially-shown-cards': initiallyShownCards
|
|
37
|
+
};
|
|
38
|
+
const childrenLength = Children.count(children);
|
|
39
|
+
const [root, setRoot] = useState(null);
|
|
40
|
+
const cardRefs = useRef([]);
|
|
41
|
+
const [visibilityList, setVisibilityList] = useState(Array(childrenLength).fill(0));
|
|
42
|
+
const stateScrollingLockRef = useRef(false);
|
|
43
|
+
const openSetStateLockTimeoutRef = useRef(null);
|
|
44
|
+
const observerVisibility = useIntersectionObserver({
|
|
45
|
+
root,
|
|
46
|
+
threshold: 0.5
|
|
47
|
+
}, setVisibilityList);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const container = root;
|
|
50
|
+
if (isMobile || !container) return undefined;
|
|
51
|
+
const lockScrollDuringInteraction = () => {
|
|
52
|
+
lockScroll(stateScrollingLockRef, openSetStateLockTimeoutRef);
|
|
53
|
+
};
|
|
54
|
+
container.addEventListener('wheel', lockScrollDuringInteraction);
|
|
55
|
+
container.addEventListener('touchmove', lockScrollDuringInteraction);
|
|
56
|
+
return () => {
|
|
57
|
+
container.removeEventListener('touchmove', lockScrollDuringInteraction);
|
|
58
|
+
container.removeEventListener('wheel', lockScrollDuringInteraction);
|
|
59
|
+
if (openSetStateLockTimeoutRef.current) {
|
|
60
|
+
clearTimeout(openSetStateLockTimeoutRef.current);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}, [root]);
|
|
64
|
+
useUpdateCurrentIndexByVisibility(isMobile, visibilityList, setCurrentIndex, stateScrollingLockRef, openSetStateLockTimeoutRef);
|
|
65
|
+
useScrollToCard(currentIndex, root, cardRefs, stateScrollingLockRef);
|
|
66
|
+
const firstVisibleIndex = Math.max(0, visibilityList.indexOf(1));
|
|
67
|
+
const lastVisibleIndex = firstVisibleIndex + initiallyShownCards - 1;
|
|
68
|
+
const renderList = visibilityList.map((_, index) => index >= firstVisibleIndex - RENDER_BUFFER_SIZE && index <= lastVisibleIndex + RENDER_BUFFER_SIZE ? 1 : 0);
|
|
69
|
+
const carouselAriaLabel = `Entering Carousel with ${initiallyShownCards} slides shown at a time, ${childrenLength} slides in total. Please use Pagination below with the Previous and Next buttons to navigate, or the slide dot buttons at the end to jump to slides.`;
|
|
70
|
+
return /*#__PURE__*/_jsx("div", {
|
|
71
|
+
className: getClassName(`bpk-card-list-row-rail__${layout}`),
|
|
72
|
+
"data-testid": "bpk-card-list-row-rail__carousel",
|
|
73
|
+
"aria-label": carouselAriaLabel
|
|
74
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
75
|
+
,
|
|
76
|
+
tabIndex: 0,
|
|
77
|
+
role: "region",
|
|
78
|
+
ref: setRoot,
|
|
79
|
+
children: children.map((card, index) => {
|
|
80
|
+
if (! /*#__PURE__*/isValidElement(card)) return null;
|
|
81
|
+
const cardRefCallback = el => {
|
|
82
|
+
cardRefs.current[index] = el;
|
|
83
|
+
observerVisibility(el, index);
|
|
84
|
+
setA11yTabIndex(el, index, visibilityList);
|
|
85
|
+
};
|
|
86
|
+
const slideAriaLabel = `slide ${index + 1} of ${childrenLength}`;
|
|
87
|
+
const cardStyle = isMobile ? {
|
|
88
|
+
...shownNumberStyle,
|
|
89
|
+
visibility: renderList[index] === 1 ? 'visible' : 'hidden'
|
|
90
|
+
} : shownNumberStyle;
|
|
91
|
+
return /*#__PURE__*/_jsx("div", {
|
|
92
|
+
className: getClassName(`bpk-card-list-row-rail__${layout}__card`),
|
|
93
|
+
ref: cardRefCallback,
|
|
94
|
+
style: cardStyle,
|
|
95
|
+
role: "group",
|
|
96
|
+
"aria-label": slideAriaLabel,
|
|
97
|
+
"aria-current": index === currentIndex ? 'true' : 'false',
|
|
98
|
+
children: isMobile ? card : renderList[index] === 1 && card
|
|
99
|
+
}, `carousel-card-${index.toString()}`);
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
export default BpkCardListCarousel;
|
|
@@ -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
|
+
.bpk-card-list-row-rail__row,.bpk-card-list-row-rail__rail{display:flex;padding-top:.25rem;padding-bottom:.25rem;overflow-x:scroll;box-sizing:border-box;gap:.25rem;scroll-snap-stop:always;scroll-snap-type:x mandatory;scrollbar-width:none}.bpk-card-list-row-rail__row::-webkit-scrollbar,.bpk-card-list-row-rail__rail::-webkit-scrollbar{display:none}.bpk-card-list-row-rail__row__card,.bpk-card-list-row-rail__rail__card{position:relative;padding:.5rem;flex:0 0 calc((100% - .5rem*(var(--initially-shown-cards, 3) - 1))/var(--initially-shown-cards, 3));overflow:visible;box-sizing:border-box;scroll-snap-align:start}.bpk-card-list-row-rail__rail{-webkit-overflow-scrolling:touch}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
import { useState, Children } from 'react';
|
|
19
|
+
import BpkPageIndicator from "../../../bpk-component-page-indicator";
|
|
20
|
+
import { cssModules } from "../../../bpk-react-utils";
|
|
21
|
+
import { ACCESSORY_DESKTOP_TYPES, LAYOUTS } from "../common-types";
|
|
22
|
+
import BpkCardListCarousel from "./BpkCardListCarousel";
|
|
23
|
+
import STYLES from "./BpkCardListRowRailContainer.module.css";
|
|
24
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
const getClassName = cssModules(STYLES);
|
|
26
|
+
const BpkCardListRowRailContainer = props => {
|
|
27
|
+
const {
|
|
28
|
+
accessory,
|
|
29
|
+
children,
|
|
30
|
+
initiallyShownCards,
|
|
31
|
+
isMobile = false,
|
|
32
|
+
layout
|
|
33
|
+
} = props;
|
|
34
|
+
const totalIndicators = Children.count(children);
|
|
35
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
36
|
+
const showAccessory = totalIndicators > initiallyShownCards;
|
|
37
|
+
const accessoryContent = layout === LAYOUTS.row && accessory === ACCESSORY_DESKTOP_TYPES.pagination ? /*#__PURE__*/_jsx(BpkPageIndicator, {
|
|
38
|
+
currentIndex: currentIndex,
|
|
39
|
+
totalIndicators: totalIndicators,
|
|
40
|
+
onClick: (_e, index) => {
|
|
41
|
+
setCurrentIndex(index);
|
|
42
|
+
},
|
|
43
|
+
showNav: true,
|
|
44
|
+
indicatorLabel: "Go to slide",
|
|
45
|
+
prevNavLabel: "Previous slide",
|
|
46
|
+
nextNavLabel: "Next slide"
|
|
47
|
+
}) : null;
|
|
48
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
49
|
+
className: getClassName('bpk-card-list-row-rail'),
|
|
50
|
+
"data-testid": "bpk-card-list-row-rail",
|
|
51
|
+
children: [/*#__PURE__*/_jsx(BpkCardListCarousel, {
|
|
52
|
+
initiallyShownCards: initiallyShownCards,
|
|
53
|
+
layout: layout,
|
|
54
|
+
currentIndex: currentIndex,
|
|
55
|
+
setCurrentIndex: setCurrentIndex,
|
|
56
|
+
isMobile: isMobile,
|
|
57
|
+
children: children
|
|
58
|
+
}), accessoryContent && showAccessory && /*#__PURE__*/_jsx("div", {
|
|
59
|
+
role: "region",
|
|
60
|
+
"aria-label": "pagination",
|
|
61
|
+
className: getClassName(`bpk-card-list-row-rail__accessory`),
|
|
62
|
+
"data-testid": "bpk-card-list-row-rail__accessory",
|
|
63
|
+
children: accessoryContent
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
export default BpkCardListRowRailContainer;
|
|
@@ -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
|
+
.bpk-card-list-row-rail{display:flex;flex-direction:column}.bpk-card-list-row-rail__accessory{width:100%}
|
|
@@ -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
|
+
export const RELEASE_LOCK_DELAY = 20;
|
|
20
|
+
export const RENDER_BUFFER_SIZE = 3;
|
|
@@ -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 BpkCardListRowRailContainer from "./BpkCardListRowRailContainer";
|
|
20
|
+
export default BpkCardListRowRailContainer;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const lockScroll: (stateScrollingLockRef: React.MutableRefObject<boolean>, openSetStateLockTimeoutRef: React.MutableRefObject<NodeJS.Timeout | null>) => void;
|
|
2
|
+
export declare const setA11yTabIndex: (el: HTMLDivElement | null, index: number, visibilityList: number[]) => void;
|
|
3
|
+
export declare const useUpdateCurrentIndexByVisibility: (isMobile: boolean, visibilityList: number[], setCurrentIndex: (index: number) => void, stateScrollingLockRef: React.MutableRefObject<boolean>, openSetStateLockTimeoutRef: React.MutableRefObject<NodeJS.Timeout | null>) => void;
|
|
4
|
+
export declare const useScrollToCard: (currentIndex: number, container: HTMLElement | null, cardRefs: React.MutableRefObject<Array<HTMLDivElement | null>>, stateScrollingLockRef: React.MutableRefObject<boolean>) => void;
|
|
5
|
+
export declare const useIntersectionObserver: ({ root, threshold }: IntersectionObserverInit, setVisibilityList: React.Dispatch<React.SetStateAction<number[]>>) => (element: HTMLElement | null, index: number) => void;
|
|
@@ -0,0 +1,112 @@
|
|
|
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 { useEffect, useRef, useMemo } from 'react';
|
|
20
|
+
import { RELEASE_LOCK_DELAY } from "./constants";
|
|
21
|
+
export const lockScroll = (stateScrollingLockRef, openSetStateLockTimeoutRef) => {
|
|
22
|
+
// eslint-disable-next-line no-param-reassign
|
|
23
|
+
stateScrollingLockRef.current = true;
|
|
24
|
+
if (openSetStateLockTimeoutRef.current) {
|
|
25
|
+
clearTimeout(openSetStateLockTimeoutRef.current);
|
|
26
|
+
}
|
|
27
|
+
// eslint-disable-next-line no-param-reassign
|
|
28
|
+
openSetStateLockTimeoutRef.current = setTimeout(() => {
|
|
29
|
+
// eslint-disable-next-line no-param-reassign
|
|
30
|
+
stateScrollingLockRef.current = false;
|
|
31
|
+
}, RELEASE_LOCK_DELAY);
|
|
32
|
+
};
|
|
33
|
+
export const setA11yTabIndex = (el, index, visibilityList) => {
|
|
34
|
+
if (!el) return;
|
|
35
|
+
const focusableElements = el.querySelectorAll('a, button, input, textarea, select, [tabindex]:not([tabindex="-1"])');
|
|
36
|
+
focusableElements.forEach(element => {
|
|
37
|
+
const targetElement = element;
|
|
38
|
+
targetElement.tabIndex = visibilityList[index] === 1 ? 0 : -1;
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export const useUpdateCurrentIndexByVisibility = (isMobile, visibilityList, setCurrentIndex, stateScrollingLockRef, openSetStateLockTimeoutRef) => {
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (isMobile) return;
|
|
44
|
+
if (!visibilityList || visibilityList.length === 0) return;
|
|
45
|
+
const firstVisibleIndex = visibilityList.findIndex(visibility => visibility === 1);
|
|
46
|
+
if (firstVisibleIndex !== -1) {
|
|
47
|
+
setCurrentIndex(firstVisibleIndex);
|
|
48
|
+
lockScroll(stateScrollingLockRef, openSetStateLockTimeoutRef);
|
|
49
|
+
}
|
|
50
|
+
}, [visibilityList]);
|
|
51
|
+
};
|
|
52
|
+
export const useScrollToCard = (currentIndex, container, cardRefs, stateScrollingLockRef) => {
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const isVisible = container && container.getBoundingClientRect().bottom > 0 && container.getBoundingClientRect().bottom <= window.innerHeight;
|
|
55
|
+
if (!isVisible) return; // Escape from scrollIntoView if the container is not visible
|
|
56
|
+
|
|
57
|
+
if (stateScrollingLockRef.current && stateScrollingLockRef.current === true) return;
|
|
58
|
+
const targetCard = cardRefs.current[currentIndex];
|
|
59
|
+
if (targetCard) {
|
|
60
|
+
targetCard.scrollIntoView({
|
|
61
|
+
behavior: 'smooth',
|
|
62
|
+
block: 'nearest',
|
|
63
|
+
inline: 'start'
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, [currentIndex]);
|
|
67
|
+
};
|
|
68
|
+
export const useIntersectionObserver = ({
|
|
69
|
+
root,
|
|
70
|
+
threshold
|
|
71
|
+
}, setVisibilityList) => {
|
|
72
|
+
const callbackRef = useRef(setVisibilityList);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
callbackRef.current = setVisibilityList;
|
|
75
|
+
});
|
|
76
|
+
const observeAll = useMemo(() => {
|
|
77
|
+
if (!root) return () => {};
|
|
78
|
+
const observer = new IntersectionObserver(entries => {
|
|
79
|
+
entries.forEach(entry => {
|
|
80
|
+
const {
|
|
81
|
+
index
|
|
82
|
+
} = entry.target.dataset;
|
|
83
|
+
if (!index) return;
|
|
84
|
+
const currentIndex = parseInt(index, 10);
|
|
85
|
+
if (entry.isIntersecting) {
|
|
86
|
+
setVisibilityList(prevList => {
|
|
87
|
+
const newList = [...prevList];
|
|
88
|
+
newList[currentIndex] = 1;
|
|
89
|
+
return newList;
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
setVisibilityList(prevList => {
|
|
93
|
+
const newList = [...prevList];
|
|
94
|
+
newList[currentIndex] = 0;
|
|
95
|
+
return newList;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}, {
|
|
100
|
+
root,
|
|
101
|
+
threshold
|
|
102
|
+
});
|
|
103
|
+
const observeElement = (element, index) => {
|
|
104
|
+
if (element && observer) {
|
|
105
|
+
element.setAttribute('data-index', index.toString());
|
|
106
|
+
observer.observe(element);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return observeElement;
|
|
110
|
+
}, [root, threshold]);
|
|
111
|
+
return observeAll;
|
|
112
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { BUTTON_TYPES, BpkButtonV2 } from "../../../bpk-component-button";
|
|
20
|
+
import { withButtonAlignment, withRtlSupport } from "../../../bpk-component-icon";
|
|
21
|
+
import ChevronDown from "../../../bpk-component-icon/sm/chevron-down";
|
|
22
|
+
import ChevronUp from "../../../bpk-component-icon/sm/chevron-up";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
const AlignedChevronDownIcon = withButtonAlignment(withRtlSupport(ChevronDown));
|
|
25
|
+
const AlignedChevronUpIcon = withButtonAlignment(withRtlSupport(ChevronUp));
|
|
26
|
+
const ExpandAccessoryContent = ({
|
|
27
|
+
children,
|
|
28
|
+
collapsed,
|
|
29
|
+
onExpandToggle
|
|
30
|
+
}) => /*#__PURE__*/_jsxs(BpkButtonV2, {
|
|
31
|
+
"data-testid": "bpk-card-list__accessory-expand-button",
|
|
32
|
+
type: BUTTON_TYPES.link,
|
|
33
|
+
onClick: onExpandToggle,
|
|
34
|
+
"aria-expanded": !collapsed,
|
|
35
|
+
children: [children, collapsed ? /*#__PURE__*/_jsx(AlignedChevronDownIcon, {}) : /*#__PURE__*/_jsx(AlignedChevronUpIcon, {})]
|
|
36
|
+
});
|
|
37
|
+
export default ExpandAccessoryContent;
|
|
@@ -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 ExpandAccessoryContent from "./ExpandAccessoryContent";
|
|
20
|
+
export default ExpandAccessoryContent;
|
|
@@ -1,8 +1,70 @@
|
|
|
1
|
-
type
|
|
1
|
+
import type { ReactElement, Dispatch, SetStateAction } from 'react';
|
|
2
|
+
declare const LAYOUTS: {
|
|
3
|
+
readonly grid: "grid";
|
|
4
|
+
readonly stack: "stack";
|
|
5
|
+
readonly row: "row";
|
|
6
|
+
readonly rail: "rail";
|
|
7
|
+
};
|
|
8
|
+
type LayoutDesktop = typeof LAYOUTS.row | typeof LAYOUTS.grid;
|
|
9
|
+
type LayoutMobile = typeof LAYOUTS.rail | typeof LAYOUTS.stack;
|
|
10
|
+
declare const ACCESSORY_DESKTOP_TYPES: {
|
|
11
|
+
readonly pagination: "pagination";
|
|
12
|
+
readonly expand: "expand";
|
|
13
|
+
readonly button: "button";
|
|
14
|
+
};
|
|
15
|
+
declare const ACCESSORY_MOBILE_TYPES: {
|
|
16
|
+
readonly expand: "expand";
|
|
17
|
+
readonly button: "button";
|
|
18
|
+
};
|
|
19
|
+
type ExpandProps = {
|
|
20
|
+
children: string | ReactElement;
|
|
21
|
+
collapsed: boolean;
|
|
22
|
+
onExpandToggle: () => void;
|
|
23
|
+
};
|
|
24
|
+
type CardListBaseProps = {
|
|
2
25
|
title: string;
|
|
3
26
|
description?: string;
|
|
4
|
-
|
|
27
|
+
cardList: ReactElement[];
|
|
28
|
+
layoutMobile: LayoutMobile;
|
|
29
|
+
layoutDesktop: LayoutDesktop;
|
|
30
|
+
accessoryDesktop?: (typeof ACCESSORY_DESKTOP_TYPES)[keyof typeof ACCESSORY_DESKTOP_TYPES];
|
|
31
|
+
accessoryMobile?: (typeof ACCESSORY_MOBILE_TYPES)[keyof typeof ACCESSORY_MOBILE_TYPES];
|
|
32
|
+
initiallyShownCardsDesktop?: number;
|
|
33
|
+
initiallyShownCardsMobile?: number;
|
|
34
|
+
chipGroup?: ReactElement;
|
|
35
|
+
buttonContent?: React.ReactNode;
|
|
5
36
|
onButtonClick?: () => void;
|
|
37
|
+
onExpandClick?: () => void;
|
|
6
38
|
buttonHref?: string;
|
|
39
|
+
expandText?: string;
|
|
40
|
+
};
|
|
41
|
+
type CardListGridStackProps = {
|
|
42
|
+
children: ReactElement[];
|
|
43
|
+
initiallyShownCards: number;
|
|
44
|
+
layout: typeof LAYOUTS.grid | typeof LAYOUTS.stack;
|
|
45
|
+
accessory?: typeof ACCESSORY_DESKTOP_TYPES.expand | typeof ACCESSORY_DESKTOP_TYPES.button | typeof ACCESSORY_MOBILE_TYPES.expand | typeof ACCESSORY_MOBILE_TYPES.button;
|
|
46
|
+
expandText?: string;
|
|
47
|
+
buttonContent?: React.ReactNode;
|
|
48
|
+
onButtonClick?: () => void;
|
|
49
|
+
onExpandClick?: () => void;
|
|
50
|
+
buttonHref?: string;
|
|
51
|
+
};
|
|
52
|
+
type CardListRowRailProps = {
|
|
53
|
+
children: Array<ReactElement<HTMLDivElement | HTMLAnchorElement>>;
|
|
54
|
+
initiallyShownCards: number;
|
|
55
|
+
layout: typeof LAYOUTS.row | typeof LAYOUTS.rail;
|
|
56
|
+
accessory?: typeof ACCESSORY_DESKTOP_TYPES.pagination;
|
|
57
|
+
isMobile?: boolean;
|
|
58
|
+
};
|
|
59
|
+
type CardListCarouselProps = {
|
|
60
|
+
children: Array<ReactElement<HTMLDivElement | HTMLAnchorElement>>;
|
|
61
|
+
initiallyShownCards: number;
|
|
62
|
+
layout: typeof LAYOUTS.row | typeof LAYOUTS.rail;
|
|
63
|
+
currentIndex: number;
|
|
64
|
+
setCurrentIndex: Dispatch<SetStateAction<number>>;
|
|
65
|
+
isMobile?: boolean;
|
|
7
66
|
};
|
|
67
|
+
type CardListProps = CardListBaseProps;
|
|
8
68
|
export default CardListProps;
|
|
69
|
+
export { LAYOUTS, ACCESSORY_DESKTOP_TYPES, ACCESSORY_MOBILE_TYPES };
|
|
70
|
+
export type { LayoutDesktop, LayoutMobile, CardListGridStackProps, CardListRowRailProps, CardListCarouselProps, ExpandProps, };
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
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
|
+
const LAYOUTS = {
|
|
20
|
+
grid: 'grid',
|
|
21
|
+
stack: 'stack',
|
|
22
|
+
row: 'row',
|
|
23
|
+
rail: 'rail'
|
|
24
|
+
};
|
|
25
|
+
const ACCESSORY_DESKTOP_TYPES = {
|
|
26
|
+
pagination: 'pagination',
|
|
27
|
+
expand: 'expand',
|
|
28
|
+
button: 'button'
|
|
29
|
+
};
|
|
30
|
+
const ACCESSORY_MOBILE_TYPES = {
|
|
31
|
+
expand: 'expand',
|
|
32
|
+
button: 'button'
|
|
33
|
+
};
|
|
34
|
+
export { LAYOUTS, ACCESSORY_DESKTOP_TYPES, ACCESSORY_MOBILE_TYPES };
|
|
@@ -0,0 +1,27 @@
|
|
|
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 BpkCard from "../bpk-component-card";
|
|
20
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
|
+
const mockCards = numberOfCards => Array.from({
|
|
22
|
+
length: numberOfCards
|
|
23
|
+
}, (_, i) => /*#__PURE__*/_jsx(BpkCard, {
|
|
24
|
+
"data-testid": `card-testId-${i}`,
|
|
25
|
+
children: `Card ${i}`
|
|
26
|
+
}, i));
|
|
27
|
+
export default mockCards;
|
|
@@ -20,6 +20,7 @@ export type Props = {
|
|
|
20
20
|
isIphone?: boolean;
|
|
21
21
|
padded?: boolean;
|
|
22
22
|
mobileModalDisplay?: boolean;
|
|
23
|
+
containerClassName?: string;
|
|
23
24
|
};
|
|
24
|
-
declare const BpkDrawer: ({ children, className, closeLabel, closeText, contentClassName, dialogRef, getApplicationElement, hideTitle, id, isIpad, isIphone, isOpen, mobileModalDisplay, onClose, padded, renderTarget, title, width, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare const BpkDrawer: ({ children, className, closeLabel, closeText, containerClassName, contentClassName, dialogRef, getApplicationElement, hideTitle, id, isIpad, isIphone, isOpen, mobileModalDisplay, onClose, padded, renderTarget, title, width, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
25
26
|
export default BpkDrawer;
|
|
@@ -25,6 +25,7 @@ const BpkDrawer = ({
|
|
|
25
25
|
className = undefined,
|
|
26
26
|
closeLabel = null,
|
|
27
27
|
closeText = undefined,
|
|
28
|
+
containerClassName = undefined,
|
|
28
29
|
contentClassName = undefined,
|
|
29
30
|
dialogRef,
|
|
30
31
|
getApplicationElement,
|
|
@@ -79,6 +80,7 @@ const BpkDrawer = ({
|
|
|
79
80
|
isIphone: isIphone,
|
|
80
81
|
padded: padded,
|
|
81
82
|
mobileModalDisplay: mobileModalDisplay,
|
|
83
|
+
containerClassName: containerClassName,
|
|
82
84
|
children: children
|
|
83
85
|
})
|
|
84
86
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const FlameIcon = props => /*#__PURE__*/_jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
viewBox: "0 0 24 24",
|
|
6
|
+
"aria-hidden": "true",
|
|
7
|
+
width: "1.5rem",
|
|
8
|
+
height: "1.5rem",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
11
|
+
d: "M13.473 6.517C11.313 4.604 12.485.5 12.485.5S6.315 4.357 7.44 12.827c-1.897-.756-1.897-3.07-1.126-4.613C4.771 9.757 4 12.41 4 14.478c0 4.427 3.487 8.022 7.791 8.022s7.776-3.595 7.776-8.022c0-4.428-3.456-5.616-6.094-7.946zm-1.682 13.5c-1.543 0-2.947-.695-3.919-1.76 0 0 3.75-.123 4.845-4.582.586.448.956 1.805.57 2.978.942.092 3.024-2.67 1.374-6.68 1.234.756 2.607 2.252 2.607 4.535 0 3.055-2.515 5.508-5.477 5.508"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
export default FlameIcon;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const IncompatibleIcon = props => /*#__PURE__*/_jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
viewBox: "0 0 24 24",
|
|
6
|
+
"aria-hidden": "true",
|
|
7
|
+
width: "1.5rem",
|
|
8
|
+
height: "1.5rem",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
11
|
+
d: "M21.364 10.293a1 1 0 1 1 1.414 1.414l-6.364 6.363h4.657a1 1 0 0 1 0 2h-7.07a1 1 0 0 1-1-1V12a1 1 0 1 1 2 0v4.656zM10.071 4a1 1 0 0 1 1 1v7.07a1 1 0 0 1-2 0V7.414l-6.364 6.363a1 1 0 1 1-1.414-1.414L7.657 6H3a1 1 0 0 1 0-2z"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
export default IncompatibleIcon;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const FlameIcon = props => /*#__PURE__*/_jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
viewBox: "0 0 24 24",
|
|
6
|
+
"aria-hidden": "true",
|
|
7
|
+
width: "1rem",
|
|
8
|
+
height: "1rem",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
11
|
+
d: "M13.71 6.6c-2.1-1.86-.96-5.85-.96-5.85s-6 3.75-4.905 11.985C6 12 6 9.75 6.75 8.25c-1.5 1.5-2.25 4.08-2.25 6.09 0 4.305 3.39 7.8 7.575 7.8s7.56-3.495 7.56-7.8-3.36-5.46-5.925-7.725zm-1.635 13.125c-1.5 0-2.865-.675-3.81-1.71 0 0 3.645-.12 4.71-4.455.57.435.93 1.755.555 2.895.915.09 2.94-2.595 1.335-6.495 1.2.735 2.535 2.19 2.535 4.41 0 2.97-2.445 5.355-5.325 5.355"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
export default FlameIcon;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const IncompatibleIcon = props => /*#__PURE__*/_jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
viewBox: "0 0 24 24",
|
|
6
|
+
"aria-hidden": "true",
|
|
7
|
+
width: "1rem",
|
|
8
|
+
height: "1rem",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
11
|
+
d: "M21.364 10.292a1.001 1.001 0 0 1 1.415 1.415l-6.365 6.363h4.657a1 1 0 0 1 0 2.001H14a1 1 0 0 1-1.001-1V12a1 1 0 0 1 2 0v4.657zM10.071 3.999a1 1 0 0 1 1 1v7.071a1.001 1.001 0 0 1-2 0V7.414l-6.363 6.364a1.001 1.001 0 0 1-1.415-1.415L7.657 6H3.001a1 1 0 0 1 0-2.001z"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
export default IncompatibleIcon;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.9.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@floating-ui/react": "^0.
|
|
25
|
+
"@floating-ui/react": "^0.27.8",
|
|
26
26
|
"@popperjs/core": "^2.11.8",
|
|
27
27
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
|
28
28
|
"@radix-ui/react-slider": "1.1.2",
|
|
29
29
|
"@react-google-maps/api": "^2.19.3",
|
|
30
30
|
"@skyscanner/bpk-foundations-web": "^19.5.0",
|
|
31
|
-
"@skyscanner/bpk-svgs": "^20.
|
|
31
|
+
"@skyscanner/bpk-svgs": "^20.6.0",
|
|
32
32
|
"a11y-focus-scope": "^1.1.3",
|
|
33
33
|
"a11y-focus-store": "^1.0.0",
|
|
34
34
|
"d3-path": "^2.0.0",
|