@skyscanner/backpack-web 42.8.0 → 42.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-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-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 -1
|
@@ -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 {};
|
|
@@ -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}
|