@skyscanner/backpack-web 42.8.0 → 42.9.0-dev-v24441922940.1
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-calendar/src/BpkCalendarNav.d.ts +1 -1
- package/bpk-component-calendar/src/BpkCalendarNav.js +0 -1
- package/bpk-component-comparison-table/index.d.ts +3 -0
- package/bpk-component-comparison-table/index.js +20 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTray.d.ts +18 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTray.js +42 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTray.module.css +18 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItem.d.ts +3 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItem.js +48 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItemPlaceholder.d.ts +2 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItemPlaceholder.js +29 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayRoot.d.ts +3 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayRoot.js +75 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/common-types.d.ts +48 -0
- package/bpk-component-comparison-table/src/BpkComparisonTray/common-types.js +1 -0
- package/bpk-component-layout/src/theme.js +134 -119
- package/bpk-component-select/index.d.ts +5 -0
- package/bpk-component-select/index.js +3 -1
- package/bpk-component-select/src/BpkSelect.d.ts +18 -0
- package/bpk-component-select/src/BpkSelect.js +3 -28
- package/bpk-component-select/src/themeAttributes.d.ts +2 -0
- package/bpk-component-theme-toggle/src/BpkThemeToggle.js +0 -1
- package/bpk-component-thumb-button/index.d.ts +1 -1
- package/bpk-component-thumb-button/src/BpkThumbButton.d.ts +12 -1
- package/bpk-component-thumb-button/src/BpkThumbButton.js +18 -4
- package/bpk-component-thumb-button/src/BpkThumbButton.module.css +1 -1
- package/package.json +1 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChangeEvent, MouseEvent } from 'react';
|
|
2
|
-
type MonthChangeEvent = ChangeEvent<
|
|
2
|
+
type MonthChangeEvent = ChangeEvent<HTMLSelectElement> | MouseEvent<HTMLButtonElement>;
|
|
3
3
|
type Props = {
|
|
4
4
|
changeMonthLabel: string;
|
|
5
5
|
/**
|
|
@@ -20,7 +20,6 @@ import { textColors } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
|
20
20
|
import BpkAriaLive from "../../bpk-component-aria-live";
|
|
21
21
|
import ArrowLeftIcon from "../../bpk-component-icon/lg/arrow-left";
|
|
22
22
|
import ArrowRightIcon from "../../bpk-component-icon/lg/arrow-right";
|
|
23
|
-
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
24
23
|
import BpkSelect from "../../bpk-component-select";
|
|
25
24
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
26
25
|
import { addMonths, formatIsoMonth, getMonthRange, getMonthsInRange, isWithinRange, parseIsoDate, startOfMonth } from "./date-utils";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import BpkComparisonTray from './src/BpkComparisonTray/BpkComparisonTray';
|
|
2
|
+
export type { BpkComparisonItem, BpkComparisonTrayRootProps, BpkComparisonTrayItemProps, BpkComparisonTrayNamespace, } from './src/BpkComparisonTray/common-types';
|
|
3
|
+
export default BpkComparisonTray;
|
|
@@ -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 BpkComparisonTray from "./src/BpkComparisonTray/BpkComparisonTray";
|
|
20
|
+
export default BpkComparisonTray;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BpkComparisonTrayNamespace } from './common-types';
|
|
2
|
+
/**
|
|
3
|
+
* BpkComparisonTray is a data-driven tray component for comparing up to 3 items.
|
|
4
|
+
*
|
|
5
|
+
* Consumer usage — only `Root` is the public API:
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <BpkComparisonTray.Root
|
|
9
|
+
* items={items}
|
|
10
|
+
* onRemove={(id) => setItems(items.filter(item => item.id !== id))}
|
|
11
|
+
* onCompare={() => navigate('/compare')}
|
|
12
|
+
* />
|
|
13
|
+
*
|
|
14
|
+
* `Item` and `ItemPlaceholder` are internal rendering primitives exported for
|
|
15
|
+
* testing and extension purposes only.
|
|
16
|
+
*/
|
|
17
|
+
declare const BpkComparisonTray: BpkComparisonTrayNamespace;
|
|
18
|
+
export default BpkComparisonTray;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 BpkComparisonTrayItem from "./BpkComparisonTrayItem";
|
|
20
|
+
import BpkComparisonTrayItemPlaceholder from "./BpkComparisonTrayItemPlaceholder";
|
|
21
|
+
import BpkComparisonTrayRoot from "./BpkComparisonTrayRoot";
|
|
22
|
+
/**
|
|
23
|
+
* BpkComparisonTray is a data-driven tray component for comparing up to 3 items.
|
|
24
|
+
*
|
|
25
|
+
* Consumer usage — only `Root` is the public API:
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* <BpkComparisonTray.Root
|
|
29
|
+
* items={items}
|
|
30
|
+
* onRemove={(id) => setItems(items.filter(item => item.id !== id))}
|
|
31
|
+
* onCompare={() => navigate('/compare')}
|
|
32
|
+
* />
|
|
33
|
+
*
|
|
34
|
+
* `Item` and `ItemPlaceholder` are internal rendering primitives exported for
|
|
35
|
+
* testing and extension purposes only.
|
|
36
|
+
*/
|
|
37
|
+
const BpkComparisonTray = {
|
|
38
|
+
Root: BpkComparisonTrayRoot,
|
|
39
|
+
Item: BpkComparisonTrayItem,
|
|
40
|
+
ItemPlaceholder: BpkComparisonTrayItemPlaceholder
|
|
41
|
+
};
|
|
42
|
+
export default BpkComparisonTray;
|
|
@@ -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-comparison-tray{width:22.1875rem;max-width:100%}.bpk-comparison-tray__item{position:relative;width:3.875rem;height:1.75rem;flex-shrink:0}@media(max-width: 32rem){.bpk-comparison-tray__item{width:auto;min-width:0;flex:1}}.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{object-fit:cover}.bpk-comparison-tray__item-close{position:absolute;top:0;right:0;display:flex;width:1rem;height:1rem;justify-content:center;align-items:center;transform:translate(50%, -50%);border:.125rem solid #fff;border-radius:50%;background-color:#161616;color:#fff;cursor:pointer;position:relative;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;height:1.75rem;flex-shrink:0;border:.0625rem dashed #c1c7cf;border-radius:.25rem}@media(max-width: 32rem){.bpk-comparison-tray__item-placeholder{width:auto;min-width:0;flex:1}}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 CloseIcon from "../../../bpk-component-icon/sm/close";
|
|
20
|
+
import BpkImage from "../../../bpk-component-image";
|
|
21
|
+
import { cssModules } from "../../../bpk-react-utils";
|
|
22
|
+
import STYLES from "./BpkComparisonTray.module.css";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
const getClassName = cssModules(STYLES);
|
|
25
|
+
function BpkComparisonTrayItem({
|
|
26
|
+
item,
|
|
27
|
+
onRemove,
|
|
28
|
+
removeLabel
|
|
29
|
+
}) {
|
|
30
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
31
|
+
className: getClassName('bpk-comparison-tray__item'),
|
|
32
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
33
|
+
className: getClassName('bpk-comparison-tray__item-image-container'),
|
|
34
|
+
children: /*#__PURE__*/_jsx(BpkImage, {
|
|
35
|
+
src: item.image,
|
|
36
|
+
altText: item.imageAlt ?? item.label,
|
|
37
|
+
aspectRatio: 62 / 28
|
|
38
|
+
})
|
|
39
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
40
|
+
type: "button",
|
|
41
|
+
className: getClassName('bpk-comparison-tray__item-close'),
|
|
42
|
+
"aria-label": removeLabel,
|
|
43
|
+
onClick: () => onRemove(item.id),
|
|
44
|
+
children: /*#__PURE__*/_jsx(CloseIcon, {})
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export default BpkComparisonTrayItem;
|
package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTrayItemPlaceholder.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 { cssModules } from "../../../bpk-react-utils";
|
|
20
|
+
import STYLES from "./BpkComparisonTray.module.css";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
const getClassName = cssModules(STYLES);
|
|
23
|
+
function BpkComparisonTrayItemPlaceholder() {
|
|
24
|
+
return /*#__PURE__*/_jsx("div", {
|
|
25
|
+
className: getClassName('bpk-comparison-tray__item-placeholder'),
|
|
26
|
+
"aria-hidden": "true"
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export default BpkComparisonTrayItemPlaceholder;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BpkComparisonTrayRootProps } from './common-types';
|
|
2
|
+
declare function BpkComparisonTrayRoot({ ariaLabel, compareLabel, items, onCompare, onRemove, removeLabel, }: BpkComparisonTrayRootProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default BpkComparisonTrayRoot;
|
|
@@ -0,0 +1,75 @@
|
|
|
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 BpkButton, { BUTTON_TYPES } from "../../../bpk-component-button";
|
|
20
|
+
import { BpkCardV2, CARD_V2_SURFACE_COLORS } from "../../../bpk-component-card";
|
|
21
|
+
import { BpkSpacing } from "../../../bpk-component-layout";
|
|
22
|
+
import { cssModules, getDataComponentAttribute } from "../../../bpk-react-utils";
|
|
23
|
+
import BpkComparisonTrayItem from "./BpkComparisonTrayItem";
|
|
24
|
+
import BpkComparisonTrayItemPlaceholder from "./BpkComparisonTrayItemPlaceholder";
|
|
25
|
+
import STYLES from "./BpkComparisonTray.module.css";
|
|
26
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
+
const getClassName = cssModules(STYLES);
|
|
28
|
+
const MAX_ITEMS = 3;
|
|
29
|
+
function BpkComparisonTrayRoot({
|
|
30
|
+
ariaLabel,
|
|
31
|
+
compareLabel,
|
|
32
|
+
items,
|
|
33
|
+
onCompare,
|
|
34
|
+
onRemove,
|
|
35
|
+
removeLabel
|
|
36
|
+
}) {
|
|
37
|
+
const displayItems = Array.from({
|
|
38
|
+
length: MAX_ITEMS
|
|
39
|
+
}, (_value, index) => items[index] ?? null);
|
|
40
|
+
return /*#__PURE__*/_jsx("div", {
|
|
41
|
+
...getDataComponentAttribute('ComparisonTray'),
|
|
42
|
+
className: getClassName('bpk-comparison-tray'),
|
|
43
|
+
children: /*#__PURE__*/_jsx(BpkCardV2.Root, {
|
|
44
|
+
bgColor: CARD_V2_SURFACE_COLORS.surfaceContrast,
|
|
45
|
+
role: "region",
|
|
46
|
+
"aria-label": ariaLabel,
|
|
47
|
+
children: /*#__PURE__*/_jsxs(BpkCardV2.Body, {
|
|
48
|
+
templateColumns: "1fr auto",
|
|
49
|
+
align: "center",
|
|
50
|
+
gap: BpkSpacing.Base,
|
|
51
|
+
children: [/*#__PURE__*/_jsx(BpkCardV2.Section, {
|
|
52
|
+
flexDirection: "row",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
padding: BpkSpacing.None,
|
|
55
|
+
gap: BpkSpacing.MD,
|
|
56
|
+
children: displayItems.map((item, index) => item ? /*#__PURE__*/_jsx(BpkComparisonTrayItem, {
|
|
57
|
+
item: item,
|
|
58
|
+
onRemove: onRemove,
|
|
59
|
+
removeLabel: `${removeLabel} ${item.label}`
|
|
60
|
+
}, item.id) :
|
|
61
|
+
/*#__PURE__*/
|
|
62
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
63
|
+
_jsx(BpkComparisonTrayItemPlaceholder, {}, `placeholder-${index}`))
|
|
64
|
+
}), /*#__PURE__*/_jsx(BpkButton, {
|
|
65
|
+
type: BUTTON_TYPES.linkOnDark,
|
|
66
|
+
implicit: true,
|
|
67
|
+
disabled: items.length <= 1,
|
|
68
|
+
onClick: onCompare,
|
|
69
|
+
children: compareLabel
|
|
70
|
+
})]
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export default BpkComparisonTrayRoot;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** A single item to be displayed in the ComparisonTray. */
|
|
3
|
+
export type BpkComparisonItem = {
|
|
4
|
+
/** Stable unique identifier used for removal. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Accessible label for the item (used as image alt if imageAlt is not provided). */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Image src URL. */
|
|
9
|
+
image: string;
|
|
10
|
+
/** Alt text for the image. Defaults to `label` if not provided. */
|
|
11
|
+
imageAlt?: string;
|
|
12
|
+
};
|
|
13
|
+
/** Props for BpkComparisonTray.Root — the only consumer-facing API. */
|
|
14
|
+
export type BpkComparisonTrayRootProps = {
|
|
15
|
+
/** Up to 3 items to display. Consumer owns and manages this state. */
|
|
16
|
+
items: BpkComparisonItem[];
|
|
17
|
+
/** Called when the ✕ button on an item is clicked, with the item's id. */
|
|
18
|
+
onRemove: (id: string) => void;
|
|
19
|
+
/** Called when the Compare button is clicked. */
|
|
20
|
+
onCompare: () => void;
|
|
21
|
+
/** Label for the Compare button. */
|
|
22
|
+
compareLabel: string;
|
|
23
|
+
/** Accessible label for the tray region. */
|
|
24
|
+
ariaLabel: string;
|
|
25
|
+
/** Accessible label for the remove button (e.g. "Remove"). Composed with the item label internally. */
|
|
26
|
+
removeLabel: string;
|
|
27
|
+
};
|
|
28
|
+
/** Props for BpkComparisonTray.Item — internal use only. */
|
|
29
|
+
export type BpkComparisonTrayItemProps = {
|
|
30
|
+
item: BpkComparisonItem;
|
|
31
|
+
onRemove: (id: string) => void;
|
|
32
|
+
removeLabel: string;
|
|
33
|
+
};
|
|
34
|
+
/** Namespace type covering all BpkComparisonTray subcomponents. */
|
|
35
|
+
export type BpkComparisonTrayNamespace = {
|
|
36
|
+
Root: {
|
|
37
|
+
(props: BpkComparisonTrayRootProps): ReactNode;
|
|
38
|
+
displayName?: string;
|
|
39
|
+
};
|
|
40
|
+
Item: {
|
|
41
|
+
(props: BpkComparisonTrayItemProps): ReactNode;
|
|
42
|
+
displayName?: string;
|
|
43
|
+
};
|
|
44
|
+
ItemPlaceholder: {
|
|
45
|
+
(): ReactNode;
|
|
46
|
+
displayName?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,9 +18,24 @@
|
|
|
18
18
|
|
|
19
19
|
import { defineConfig } from '@chakra-ui/react';
|
|
20
20
|
|
|
21
|
-
// Import tokens from Backpack foundations
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// Import only the tokens we actually use from Backpack foundations
|
|
22
|
+
import {
|
|
23
|
+
// Border sizes
|
|
24
|
+
borderSizeSm, borderSizeLg, borderSizeXl,
|
|
25
|
+
// Border radii
|
|
26
|
+
borderRadiusXs, borderRadiusSm, borderRadiusMd, borderRadiusLg, borderRadiusXl, borderRadiusFull,
|
|
27
|
+
// Box shadows
|
|
28
|
+
boxShadowSm, boxShadowLg, boxShadowXl,
|
|
29
|
+
// Font sizes
|
|
30
|
+
fontSizeXs, fontSizeSm, fontSizeBase, fontSizeLg, fontSizeXl, fontSizeXxl, fontSizeXxxl, fontSizeXxxxl, fontSizeXxxxxl, fontSize6Xl, fontSize7Xl, fontSize8Xl,
|
|
31
|
+
// Line heights
|
|
32
|
+
lineHeightXs, lineHeightSm, lineHeightBase, lineHeightBaseTight, lineHeightLg, lineHeightLgTight, lineHeightXl, lineHeightXlTight, lineHeightXxl, lineHeightXxxl, lineHeightXxxxl, lineHeightXxxxxl, lineHeight6Xl, lineHeight7Xl, lineHeight8Xl,
|
|
33
|
+
// Font weights
|
|
34
|
+
fontWeightLight, fontWeightBook, fontWeightBold, fontWeightBlack,
|
|
35
|
+
// Letter spacing
|
|
36
|
+
letterSpacingTight, letterSpacingHero,
|
|
37
|
+
// Font family
|
|
38
|
+
fontFamilyLarken } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
24
39
|
// NOTE:
|
|
25
40
|
// We intentionally do not use the raw breakpoint *values* from foundations here.
|
|
26
41
|
// Foundations exports breakpoint values such as `breakpointMobile = "32rem"` which
|
|
@@ -100,9 +115,9 @@ const spacingMap = {
|
|
|
100
115
|
* These come directly from @skyscanner/bpk-foundations-web
|
|
101
116
|
*/
|
|
102
117
|
const borderSizeMap = {
|
|
103
|
-
'bpk-border-size-sm':
|
|
104
|
-
'bpk-border-size-lg':
|
|
105
|
-
'bpk-border-size-xl':
|
|
118
|
+
'bpk-border-size-sm': borderSizeSm,
|
|
119
|
+
'bpk-border-size-lg': borderSizeLg,
|
|
120
|
+
'bpk-border-size-xl': borderSizeXl
|
|
106
121
|
};
|
|
107
122
|
|
|
108
123
|
/**
|
|
@@ -111,12 +126,12 @@ const borderSizeMap = {
|
|
|
111
126
|
*/
|
|
112
127
|
const borderRadiusMap = {
|
|
113
128
|
'bpk-border-radius-none': '0',
|
|
114
|
-
'bpk-border-radius-xs':
|
|
115
|
-
'bpk-border-radius-sm':
|
|
116
|
-
'bpk-border-radius-md':
|
|
117
|
-
'bpk-border-radius-lg':
|
|
118
|
-
'bpk-border-radius-xl':
|
|
119
|
-
'bpk-border-radius-full':
|
|
129
|
+
'bpk-border-radius-xs': borderRadiusXs,
|
|
130
|
+
'bpk-border-radius-sm': borderRadiusSm,
|
|
131
|
+
'bpk-border-radius-md': borderRadiusMd,
|
|
132
|
+
'bpk-border-radius-lg': borderRadiusLg,
|
|
133
|
+
'bpk-border-radius-xl': borderRadiusXl,
|
|
134
|
+
'bpk-border-radius-full': borderRadiusFull
|
|
120
135
|
};
|
|
121
136
|
|
|
122
137
|
/**
|
|
@@ -124,9 +139,9 @@ const borderRadiusMap = {
|
|
|
124
139
|
* These come directly from @skyscanner/bpk-foundations-web
|
|
125
140
|
*/
|
|
126
141
|
const shadowMap = {
|
|
127
|
-
'bpk-shadow-sm':
|
|
128
|
-
'bpk-shadow-lg':
|
|
129
|
-
'bpk-shadow-xl':
|
|
142
|
+
'bpk-shadow-sm': boxShadowSm,
|
|
143
|
+
'bpk-shadow-lg': boxShadowLg,
|
|
144
|
+
'bpk-shadow-xl': boxShadowXl
|
|
130
145
|
};
|
|
131
146
|
|
|
132
147
|
/**
|
|
@@ -218,230 +233,230 @@ export function getShadowValue(token) {
|
|
|
218
233
|
const textStylesMap = {
|
|
219
234
|
xs: {
|
|
220
235
|
value: {
|
|
221
|
-
fontSize:
|
|
222
|
-
lineHeight:
|
|
223
|
-
fontWeight:
|
|
236
|
+
fontSize: fontSizeXs,
|
|
237
|
+
lineHeight: lineHeightXs,
|
|
238
|
+
fontWeight: fontWeightBook
|
|
224
239
|
}
|
|
225
240
|
},
|
|
226
241
|
sm: {
|
|
227
242
|
value: {
|
|
228
|
-
fontSize:
|
|
229
|
-
lineHeight:
|
|
230
|
-
fontWeight:
|
|
243
|
+
fontSize: fontSizeSm,
|
|
244
|
+
lineHeight: lineHeightSm,
|
|
245
|
+
fontWeight: fontWeightBook
|
|
231
246
|
}
|
|
232
247
|
},
|
|
233
248
|
base: {
|
|
234
249
|
value: {
|
|
235
|
-
fontSize:
|
|
236
|
-
lineHeight:
|
|
237
|
-
fontWeight:
|
|
250
|
+
fontSize: fontSizeBase,
|
|
251
|
+
lineHeight: lineHeightBase,
|
|
252
|
+
fontWeight: fontWeightBook
|
|
238
253
|
}
|
|
239
254
|
},
|
|
240
255
|
lg: {
|
|
241
256
|
value: {
|
|
242
|
-
fontSize:
|
|
243
|
-
lineHeight:
|
|
244
|
-
fontWeight:
|
|
257
|
+
fontSize: fontSizeLg,
|
|
258
|
+
lineHeight: lineHeightLg,
|
|
259
|
+
fontWeight: fontWeightBook
|
|
245
260
|
}
|
|
246
261
|
},
|
|
247
262
|
xl: {
|
|
248
263
|
value: {
|
|
249
|
-
fontSize:
|
|
250
|
-
lineHeight:
|
|
251
|
-
fontWeight:
|
|
264
|
+
fontSize: fontSizeXl,
|
|
265
|
+
lineHeight: lineHeightXl,
|
|
266
|
+
fontWeight: fontWeightBook
|
|
252
267
|
}
|
|
253
268
|
},
|
|
254
269
|
xxl: {
|
|
255
270
|
value: {
|
|
256
|
-
fontSize:
|
|
257
|
-
lineHeight:
|
|
258
|
-
fontWeight:
|
|
271
|
+
fontSize: fontSizeXxl,
|
|
272
|
+
lineHeight: lineHeightXxl,
|
|
273
|
+
fontWeight: fontWeightBold
|
|
259
274
|
}
|
|
260
275
|
},
|
|
261
276
|
xxxl: {
|
|
262
277
|
value: {
|
|
263
|
-
fontSize:
|
|
264
|
-
lineHeight:
|
|
265
|
-
fontWeight:
|
|
278
|
+
fontSize: fontSizeXxxl,
|
|
279
|
+
lineHeight: lineHeightXxxl,
|
|
280
|
+
fontWeight: fontWeightBold
|
|
266
281
|
}
|
|
267
282
|
},
|
|
268
283
|
xxxxl: {
|
|
269
284
|
value: {
|
|
270
|
-
fontSize:
|
|
271
|
-
lineHeight:
|
|
272
|
-
fontWeight:
|
|
273
|
-
letterSpacing:
|
|
285
|
+
fontSize: fontSizeXxxxl,
|
|
286
|
+
lineHeight: lineHeightXxxxl,
|
|
287
|
+
fontWeight: fontWeightBold,
|
|
288
|
+
letterSpacing: letterSpacingTight
|
|
274
289
|
}
|
|
275
290
|
},
|
|
276
291
|
xxxxxl: {
|
|
277
292
|
value: {
|
|
278
|
-
fontSize:
|
|
279
|
-
lineHeight:
|
|
280
|
-
fontWeight:
|
|
281
|
-
letterSpacing:
|
|
293
|
+
fontSize: fontSizeXxxxxl,
|
|
294
|
+
lineHeight: lineHeightXxxxxl,
|
|
295
|
+
fontWeight: fontWeightBold,
|
|
296
|
+
letterSpacing: letterSpacingTight
|
|
282
297
|
}
|
|
283
298
|
},
|
|
284
299
|
caption: {
|
|
285
300
|
value: {
|
|
286
|
-
fontSize:
|
|
287
|
-
lineHeight:
|
|
288
|
-
fontWeight:
|
|
301
|
+
fontSize: fontSizeXs,
|
|
302
|
+
lineHeight: lineHeightXs,
|
|
303
|
+
fontWeight: fontWeightBook
|
|
289
304
|
}
|
|
290
305
|
},
|
|
291
306
|
footnote: {
|
|
292
307
|
value: {
|
|
293
|
-
fontSize:
|
|
294
|
-
lineHeight:
|
|
295
|
-
fontWeight:
|
|
308
|
+
fontSize: fontSizeSm,
|
|
309
|
+
lineHeight: lineHeightSm,
|
|
310
|
+
fontWeight: fontWeightBook
|
|
296
311
|
}
|
|
297
312
|
},
|
|
298
313
|
'label-1': {
|
|
299
314
|
value: {
|
|
300
|
-
fontSize:
|
|
301
|
-
lineHeight:
|
|
302
|
-
fontWeight:
|
|
315
|
+
fontSize: fontSizeBase,
|
|
316
|
+
lineHeight: lineHeightBase,
|
|
317
|
+
fontWeight: fontWeightBold
|
|
303
318
|
}
|
|
304
319
|
},
|
|
305
320
|
'label-2': {
|
|
306
321
|
value: {
|
|
307
|
-
fontSize:
|
|
308
|
-
lineHeight:
|
|
309
|
-
fontWeight:
|
|
322
|
+
fontSize: fontSizeSm,
|
|
323
|
+
lineHeight: lineHeightSm,
|
|
324
|
+
fontWeight: fontWeightBold
|
|
310
325
|
}
|
|
311
326
|
},
|
|
312
327
|
'label-3': {
|
|
313
328
|
value: {
|
|
314
|
-
fontSize:
|
|
315
|
-
lineHeight:
|
|
316
|
-
fontWeight:
|
|
329
|
+
fontSize: fontSizeXs,
|
|
330
|
+
lineHeight: lineHeightXs,
|
|
331
|
+
fontWeight: fontWeightBold
|
|
317
332
|
}
|
|
318
333
|
},
|
|
319
334
|
'body-default': {
|
|
320
335
|
value: {
|
|
321
|
-
fontSize:
|
|
322
|
-
lineHeight:
|
|
323
|
-
fontWeight:
|
|
336
|
+
fontSize: fontSizeBase,
|
|
337
|
+
lineHeight: lineHeightBase,
|
|
338
|
+
fontWeight: fontWeightBook
|
|
324
339
|
}
|
|
325
340
|
},
|
|
326
341
|
'body-longform': {
|
|
327
342
|
value: {
|
|
328
|
-
fontSize:
|
|
329
|
-
lineHeight:
|
|
330
|
-
fontWeight:
|
|
343
|
+
fontSize: fontSizeLg,
|
|
344
|
+
lineHeight: lineHeightLg,
|
|
345
|
+
fontWeight: fontWeightBook
|
|
331
346
|
}
|
|
332
347
|
},
|
|
333
348
|
subheading: {
|
|
334
349
|
value: {
|
|
335
|
-
fontSize:
|
|
336
|
-
lineHeight:
|
|
337
|
-
fontWeight:
|
|
350
|
+
fontSize: fontSizeXl,
|
|
351
|
+
lineHeight: lineHeightXl,
|
|
352
|
+
fontWeight: fontWeightBook
|
|
338
353
|
}
|
|
339
354
|
},
|
|
340
355
|
'heading-1': {
|
|
341
356
|
value: {
|
|
342
|
-
fontSize:
|
|
343
|
-
lineHeight:
|
|
344
|
-
fontWeight:
|
|
357
|
+
fontSize: fontSizeXxxl,
|
|
358
|
+
lineHeight: lineHeightXxxl,
|
|
359
|
+
fontWeight: fontWeightBold
|
|
345
360
|
}
|
|
346
361
|
},
|
|
347
362
|
'heading-2': {
|
|
348
363
|
value: {
|
|
349
|
-
fontSize:
|
|
350
|
-
lineHeight:
|
|
351
|
-
fontWeight:
|
|
364
|
+
fontSize: fontSizeXxl,
|
|
365
|
+
lineHeight: lineHeightXxl,
|
|
366
|
+
fontWeight: fontWeightBold
|
|
352
367
|
}
|
|
353
368
|
},
|
|
354
369
|
'heading-3': {
|
|
355
370
|
value: {
|
|
356
|
-
fontSize:
|
|
357
|
-
lineHeight:
|
|
358
|
-
fontWeight:
|
|
371
|
+
fontSize: fontSizeXl,
|
|
372
|
+
lineHeight: lineHeightXlTight,
|
|
373
|
+
fontWeight: fontWeightBold
|
|
359
374
|
}
|
|
360
375
|
},
|
|
361
376
|
'heading-4': {
|
|
362
377
|
value: {
|
|
363
|
-
fontSize:
|
|
364
|
-
lineHeight:
|
|
365
|
-
fontWeight:
|
|
378
|
+
fontSize: fontSizeLg,
|
|
379
|
+
lineHeight: lineHeightLgTight,
|
|
380
|
+
fontWeight: fontWeightBold
|
|
366
381
|
}
|
|
367
382
|
},
|
|
368
383
|
'heading-5': {
|
|
369
384
|
value: {
|
|
370
|
-
fontSize:
|
|
371
|
-
lineHeight:
|
|
372
|
-
fontWeight:
|
|
385
|
+
fontSize: fontSizeBase,
|
|
386
|
+
lineHeight: lineHeightBaseTight,
|
|
387
|
+
fontWeight: fontWeightBold
|
|
373
388
|
}
|
|
374
389
|
},
|
|
375
390
|
'hero-1': {
|
|
376
391
|
value: {
|
|
377
|
-
fontSize:
|
|
378
|
-
lineHeight:
|
|
379
|
-
fontWeight:
|
|
380
|
-
letterSpacing:
|
|
392
|
+
fontSize: fontSize8Xl,
|
|
393
|
+
lineHeight: lineHeight8Xl,
|
|
394
|
+
fontWeight: fontWeightBlack,
|
|
395
|
+
letterSpacing: letterSpacingHero
|
|
381
396
|
}
|
|
382
397
|
},
|
|
383
398
|
'hero-2': {
|
|
384
399
|
value: {
|
|
385
|
-
fontSize:
|
|
386
|
-
lineHeight:
|
|
387
|
-
fontWeight:
|
|
388
|
-
letterSpacing:
|
|
400
|
+
fontSize: fontSize7Xl,
|
|
401
|
+
lineHeight: lineHeight7Xl,
|
|
402
|
+
fontWeight: fontWeightBlack,
|
|
403
|
+
letterSpacing: letterSpacingHero
|
|
389
404
|
}
|
|
390
405
|
},
|
|
391
406
|
'hero-3': {
|
|
392
407
|
value: {
|
|
393
|
-
fontSize:
|
|
394
|
-
lineHeight:
|
|
395
|
-
fontWeight:
|
|
396
|
-
letterSpacing:
|
|
408
|
+
fontSize: fontSize6Xl,
|
|
409
|
+
lineHeight: lineHeight6Xl,
|
|
410
|
+
fontWeight: fontWeightBlack,
|
|
411
|
+
letterSpacing: letterSpacingHero
|
|
397
412
|
}
|
|
398
413
|
},
|
|
399
414
|
'hero-4': {
|
|
400
415
|
value: {
|
|
401
|
-
fontSize:
|
|
402
|
-
lineHeight:
|
|
403
|
-
fontWeight:
|
|
404
|
-
letterSpacing:
|
|
416
|
+
fontSize: fontSizeXxxxxl,
|
|
417
|
+
lineHeight: lineHeightXxxxxl,
|
|
418
|
+
fontWeight: fontWeightBlack,
|
|
419
|
+
letterSpacing: letterSpacingHero
|
|
405
420
|
}
|
|
406
421
|
},
|
|
407
422
|
'hero-5': {
|
|
408
423
|
value: {
|
|
409
|
-
fontSize:
|
|
410
|
-
lineHeight:
|
|
411
|
-
fontWeight:
|
|
412
|
-
letterSpacing:
|
|
424
|
+
fontSize: fontSizeXxxxl,
|
|
425
|
+
lineHeight: lineHeightXxxl,
|
|
426
|
+
fontWeight: fontWeightBlack,
|
|
427
|
+
letterSpacing: letterSpacingHero
|
|
413
428
|
}
|
|
414
429
|
},
|
|
415
430
|
'hero-6': {
|
|
416
431
|
value: {
|
|
417
|
-
fontSize:
|
|
418
|
-
lineHeight:
|
|
419
|
-
fontWeight:
|
|
420
|
-
letterSpacing:
|
|
432
|
+
fontSize: fontSizeXxxl,
|
|
433
|
+
lineHeight: lineHeightXxl,
|
|
434
|
+
fontWeight: fontWeightBlack,
|
|
435
|
+
letterSpacing: letterSpacingHero
|
|
421
436
|
}
|
|
422
437
|
},
|
|
423
438
|
'editorial-1': {
|
|
424
439
|
value: {
|
|
425
|
-
fontFamily: `var(--bpk-larken-font-stack, ${
|
|
426
|
-
fontSize:
|
|
427
|
-
lineHeight:
|
|
428
|
-
fontWeight:
|
|
440
|
+
fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
|
|
441
|
+
fontSize: fontSizeXxxxl,
|
|
442
|
+
lineHeight: lineHeightXxxxl,
|
|
443
|
+
fontWeight: fontWeightLight
|
|
429
444
|
}
|
|
430
445
|
},
|
|
431
446
|
'editorial-2': {
|
|
432
447
|
value: {
|
|
433
|
-
fontFamily: `var(--bpk-larken-font-stack, ${
|
|
434
|
-
fontSize:
|
|
435
|
-
lineHeight:
|
|
436
|
-
fontWeight:
|
|
448
|
+
fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
|
|
449
|
+
fontSize: fontSizeXxl,
|
|
450
|
+
lineHeight: lineHeightXxl,
|
|
451
|
+
fontWeight: fontWeightLight
|
|
437
452
|
}
|
|
438
453
|
},
|
|
439
454
|
'editorial-3': {
|
|
440
455
|
value: {
|
|
441
|
-
fontFamily: `var(--bpk-larken-font-stack, ${
|
|
442
|
-
fontSize:
|
|
443
|
-
lineHeight:
|
|
444
|
-
fontWeight:
|
|
456
|
+
fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
|
|
457
|
+
fontSize: fontSizeLg,
|
|
458
|
+
lineHeight: lineHeightLg,
|
|
459
|
+
fontWeight: fontWeightBook
|
|
445
460
|
}
|
|
446
461
|
}
|
|
447
462
|
};
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkSelect from "./src/BpkSelect";
|
|
18
20
|
import themeAttributes from "./src/themeAttributes";
|
|
19
21
|
export default BpkSelect;
|
|
20
22
|
export { themeAttributes };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactElement, SelectHTMLAttributes } from 'react';
|
|
2
|
+
export type Props = Omit<SelectHTMLAttributes<HTMLSelectElement>, 'className' | 'disabled' | 'value'> & {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
className?: string | null;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
docked?: boolean;
|
|
9
|
+
dockedFirst?: boolean;
|
|
10
|
+
dockedLast?: boolean;
|
|
11
|
+
dockedMiddle?: boolean;
|
|
12
|
+
image?: ReactElement | null;
|
|
13
|
+
large?: boolean;
|
|
14
|
+
valid?: boolean | null;
|
|
15
|
+
wrapperClassName?: string | null;
|
|
16
|
+
};
|
|
17
|
+
declare const BpkSelect: ({ className, disabled, docked, dockedFirst, dockedLast, dockedMiddle, image, large, valid, wrapperClassName, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default BpkSelect;
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
18
19
|
import { cloneElement } from 'react';
|
|
19
20
|
import { cssModules } from "../../bpk-react-utils";
|
|
20
21
|
import STYLES from "./BpkSelect.module.css";
|
|
@@ -36,10 +37,7 @@ const BpkSelect = ({
|
|
|
36
37
|
// Explicit check for false primitive value as undefined is
|
|
37
38
|
// treated as neither valid nor invalid
|
|
38
39
|
const isInvalid = valid === false;
|
|
39
|
-
const select =
|
|
40
|
-
/*#__PURE__*/
|
|
41
|
-
// $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
|
|
42
|
-
_jsx("select", {
|
|
40
|
+
const select = /*#__PURE__*/_jsx("select", {
|
|
43
41
|
className: getClassName('bpk-select', large && 'bpk-select--large', docked && 'bpk-select--docked', dockedFirst && 'bpk-select--docked-first', dockedMiddle && 'bpk-select--docked-middle', dockedLast && 'bpk-select--docked-last', isInvalid && 'bpk-select--invalid', image && 'bpk-select--with-image', image && large && 'bpk-select--with-image-large', className),
|
|
44
42
|
disabled: disabled,
|
|
45
43
|
"aria-invalid": isInvalid,
|
|
@@ -56,27 +54,4 @@ const BpkSelect = ({
|
|
|
56
54
|
}
|
|
57
55
|
return select;
|
|
58
56
|
};
|
|
59
|
-
BpkSelect.propTypes = {
|
|
60
|
-
id: PropTypes.string.isRequired,
|
|
61
|
-
name: PropTypes.string.isRequired,
|
|
62
|
-
/**
|
|
63
|
-
* The "value" prop is only relevant if the user is wanting a controlled component
|
|
64
|
-
* In some cases, users may want to create an uncontrolled select as described here: https://beta.reactjs.org/reference/react-dom/components/select
|
|
65
|
-
* In this case value is not required and nor should it be given a default value (as the linter thinks)
|
|
66
|
-
* Prop types are not expressive enough (without a drastic increase in complexity of writing a custom validator) to encode this relationship. Equally, this wouldn't actually solve the linting issue (AFAIK).
|
|
67
|
-
* As a solution, the require-default-props has been disabled for this line.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
value: PropTypes.string,
|
|
71
|
-
className: PropTypes.string,
|
|
72
|
-
disabled: PropTypes.bool,
|
|
73
|
-
docked: PropTypes.bool,
|
|
74
|
-
dockedFirst: PropTypes.bool,
|
|
75
|
-
dockedLast: PropTypes.bool,
|
|
76
|
-
dockedMiddle: PropTypes.bool,
|
|
77
|
-
image: PropTypes.node,
|
|
78
|
-
large: PropTypes.bool,
|
|
79
|
-
valid: PropTypes.bool,
|
|
80
|
-
wrapperClassName: PropTypes.string
|
|
81
|
-
};
|
|
82
57
|
export default BpkSelect;
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
|
|
19
19
|
import { Component } from 'react';
|
|
20
20
|
import BpkLabel from "../../bpk-component-label";
|
|
21
|
-
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
22
21
|
import BpkSelect from "../../bpk-component-select";
|
|
23
22
|
import BpkVisuallyHidden from "../../bpk-component-visually-hidden";
|
|
24
23
|
import { getDataComponentAttribute } from "../../bpk-react-utils";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import BpkThumbButton from './src/BpkThumbButton';
|
|
2
|
-
export type { BpkThumbButtonProps, ThumbsButtonType } from './src/BpkThumbButton';
|
|
2
|
+
export type { BpkThumbButtonProps, ThumbsButtonType, ThumbsButtonSize, ThumbsButtonColor } from './src/BpkThumbButton';
|
|
3
3
|
export default BpkThumbButton;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export type ThumbsButtonType = 'up' | 'down';
|
|
2
|
+
export type ThumbsButtonSize = 'default' | 'small';
|
|
3
|
+
export type ThumbsButtonColor = 'default' | 'primary';
|
|
2
4
|
export type BpkThumbButtonProps = {
|
|
3
5
|
/**
|
|
4
6
|
* Accessibility label for screen readers (REQUIRED).
|
|
5
7
|
*/
|
|
6
8
|
accessibilityLabel: string;
|
|
9
|
+
/**
|
|
10
|
+
* Icon color variant. 'primary' uses the primary text color, 'default' uses the disabled text color (grayish).
|
|
11
|
+
*/
|
|
12
|
+
iconColor?: ThumbsButtonColor;
|
|
7
13
|
/**
|
|
8
14
|
* Click handler callback.
|
|
9
15
|
*/
|
|
@@ -12,10 +18,15 @@ export type BpkThumbButtonProps = {
|
|
|
12
18
|
* Whether the thumb is in selected state.
|
|
13
19
|
*/
|
|
14
20
|
selected?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Size variant. 'small' uses sm icons with no fixed dimensions, matching inline text use cases.
|
|
23
|
+
* Note: 'small' disables the 48px touch target pseudo-element — do not use on touch-primary surfaces.
|
|
24
|
+
*/
|
|
25
|
+
size?: ThumbsButtonSize;
|
|
15
26
|
/**
|
|
16
27
|
* Type of thumb icon to display.
|
|
17
28
|
*/
|
|
18
29
|
type: ThumbsButtonType;
|
|
19
30
|
};
|
|
20
|
-
declare const BpkThumbButton: ({ accessibilityLabel, onClick, selected, type, }: BpkThumbButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
declare const BpkThumbButton: ({ accessibilityLabel, iconColor, onClick, selected, size, type, }: BpkThumbButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
32
|
export default BpkThumbButton;
|
|
@@ -16,20 +16,34 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import
|
|
20
|
-
import
|
|
19
|
+
import ThumbsDownIconLg from "../../bpk-component-icon/lg/thumbs-down";
|
|
20
|
+
import ThumbsUpIconLg from "../../bpk-component-icon/lg/thumbs-up";
|
|
21
|
+
import ThumbsDownIconSm from "../../bpk-component-icon/sm/thumbs-down";
|
|
22
|
+
import ThumbsUpIconSm from "../../bpk-component-icon/sm/thumbs-up";
|
|
21
23
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
22
24
|
import STYLES from "./BpkThumbButton.module.css";
|
|
23
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
26
|
const getClassName = cssModules(STYLES);
|
|
25
27
|
const BpkThumbButton = ({
|
|
26
28
|
accessibilityLabel,
|
|
29
|
+
iconColor = 'default',
|
|
27
30
|
onClick,
|
|
28
31
|
selected = false,
|
|
32
|
+
size = 'default',
|
|
29
33
|
type
|
|
30
34
|
}) => {
|
|
31
|
-
const
|
|
32
|
-
|
|
35
|
+
const icons = {
|
|
36
|
+
small: {
|
|
37
|
+
up: ThumbsUpIconSm,
|
|
38
|
+
down: ThumbsDownIconSm
|
|
39
|
+
},
|
|
40
|
+
default: {
|
|
41
|
+
up: ThumbsUpIconLg,
|
|
42
|
+
down: ThumbsDownIconLg
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const Icon = icons[size][type];
|
|
46
|
+
const classNames = getClassName('bpk-thumb-button', selected && 'bpk-thumb-button--selected', size === 'small' && 'bpk-thumb-button--small', iconColor === 'primary' && 'bpk-thumb-button--color-primary');
|
|
33
47
|
const handleClick = event => {
|
|
34
48
|
event.stopPropagation();
|
|
35
49
|
onClick(type);
|
|
@@ -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-thumb-button{display:flex;width:1.5rem;height:1.5rem;padding:0;justify-content:center;align-items:center;transition:all 200ms ease-in-out;border:none;background:rgba(0,0,0,0);color:rgba(0,0,0,.2);cursor:pointer;appearance:none;position:relative}.bpk-thumb-button::before{position:absolute;top:calc(-2.75rem/2 + 50%);left:calc(-2.75rem/2 + 50%);content:"";width:2.75rem;height:2.75rem}.bpk-no-touch-support .bpk-thumb-button:hover:not(:active):not(:disabled){color:#626971}:global(.bpk-no-touch-support) .bpk-thumb-button:hover:not(:active):not(:disabled){color:#626971}@media(prefers-reduced-motion: reduce){.bpk-thumb-button{transition:none}}.bpk-thumb-button--selected{color:#0062e3}.bpk-no-touch-support .bpk-thumb-button--selected:hover:not(:active):not(:disabled){color:#0062e3}:global(.bpk-no-touch-support) .bpk-thumb-button--selected:hover:not(:active):not(:disabled){color:#0062e3}.bpk-thumb-button__icon{display:flex;fill:currentcolor}
|
|
18
|
+
.bpk-thumb-button{display:flex;width:1.5rem;height:1.5rem;padding:0;justify-content:center;align-items:center;transition:all 200ms ease-in-out;border:none;background:rgba(0,0,0,0);color:rgba(0,0,0,.2);cursor:pointer;appearance:none;position:relative}.bpk-thumb-button::before{position:absolute;top:calc(-2.75rem/2 + 50%);left:calc(-2.75rem/2 + 50%);content:"";width:2.75rem;height:2.75rem}.bpk-no-touch-support .bpk-thumb-button:hover:not(:active):not(:disabled){color:#626971}:global(.bpk-no-touch-support) .bpk-thumb-button:hover:not(:active):not(:disabled){color:#626971}@media(prefers-reduced-motion: reduce){.bpk-thumb-button{transition:none}}.bpk-thumb-button:active{color:#626971}.bpk-thumb-button--selected{color:#0062e3}.bpk-no-touch-support .bpk-thumb-button--selected:hover:not(:active):not(:disabled){color:#0062e3}:global(.bpk-no-touch-support) .bpk-thumb-button--selected:hover:not(:active):not(:disabled){color:#0062e3}.bpk-thumb-button--selected:active{color:#0062e3}.bpk-thumb-button__icon{display:flex;fill:currentcolor}.bpk-thumb-button--color-primary{color:#161616}.bpk-no-touch-support .bpk-thumb-button--color-primary:hover:not(:active):not(:disabled){color:#626971}:global(.bpk-no-touch-support) .bpk-thumb-button--color-primary:hover:not(:active):not(:disabled){color:#626971}.bpk-thumb-button--color-primary.bpk-thumb-button--selected{color:#0062e3}.bpk-no-touch-support .bpk-thumb-button--color-primary.bpk-thumb-button--selected:hover:not(:active):not(:disabled){color:#0062e3}:global(.bpk-no-touch-support) .bpk-thumb-button--color-primary.bpk-thumb-button--selected:hover:not(:active):not(:disabled){color:#0062e3}.bpk-thumb-button--small{width:auto;height:auto;font-size:.75rem;line-height:1rem;font-weight:400}.bpk-thumb-button--small::before{content:none}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "42.
|
|
3
|
+
"version": "42.9.0-dev-v24441922940.1",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@ark-ui/react": "^5.34.1",
|
|
26
26
|
"@chakra-ui/react": "^3.33.0",
|
|
27
27
|
"@floating-ui/react": "^0.26.12",
|
|
28
|
-
"@popperjs/core": "^2.11.8",
|
|
29
28
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
|
30
29
|
"@radix-ui/react-slider": "1.3.5",
|
|
31
30
|
"@react-google-maps/api": "^2.19.3",
|