@skyscanner/backpack-web 37.9.1 → 37.10.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.
@@ -1,4 +1,8 @@
1
- import BpkInsetBanner, { type Props as BpkInsetBannerProps, VARIANT } from './src/BpkInsetBanner';
1
+ import BpkInsetBanner, { type Props as BpkInsetBannerProps } from './src/BpkInsetBanner';
2
+ import BpkInsetBannerSponsored from './src/BpkInsetBannerV2/BpkInsetBannerSponsored';
3
+ import { type CommonProps as BpkInsetBannerSponsoredProps } from './src/BpkInsetBannerV2/common-types';
4
+ import { VARIANT } from './src/BpkInsetBannerV2/common-types';
2
5
  export type { BpkInsetBannerProps };
6
+ export type { BpkInsetBannerSponsoredProps };
3
7
  export { VARIANT };
4
- export default BpkInsetBanner;
8
+ export { BpkInsetBannerSponsored, BpkInsetBanner };
@@ -16,6 +16,8 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import BpkInsetBanner, { VARIANT } from "./src/BpkInsetBanner";
19
+ import BpkInsetBanner from "./src/BpkInsetBanner";
20
+ import BpkInsetBannerSponsored from "./src/BpkInsetBannerV2/BpkInsetBannerSponsored";
21
+ import { VARIANT } from "./src/BpkInsetBannerV2/common-types";
20
22
  export { VARIANT };
21
- export default BpkInsetBanner;
23
+ export { BpkInsetBannerSponsored, BpkInsetBanner };
@@ -0,0 +1,3 @@
1
+ import { type CommonProps } from './common-types';
2
+ declare const BpkInsetBannerSponsored: ({ accessibilityLabel, backgroundColor, callToAction, image, logo, subheadline, title, variant, }: CommonProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default BpkInsetBannerSponsored;
@@ -0,0 +1,138 @@
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 } from 'react';
19
+ import { surfaceHighlightDay } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
20
+ import BpkBottomSheet from "../../../bpk-component-bottom-sheet";
21
+ import ViewIcon from "../../../bpk-component-icon/lg/view";
22
+ import InfoIcon from "../../../bpk-component-icon/sm/information-circle";
23
+ import BpkImage from "../../../bpk-component-image";
24
+ import BpkText, { TEXT_STYLES } from "../../../bpk-component-text/src/BpkText";
25
+ import { cssModules } from "../../../bpk-react-utils";
26
+ import { VARIANT } from "./common-types";
27
+ import STYLES from "./BpkInsetBannerSponsored.module.css";
28
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
29
+ const getClassName = cssModules(STYLES);
30
+ const BpkInsetBannerSponsored = ({
31
+ accessibilityLabel,
32
+ backgroundColor = surfaceHighlightDay,
33
+ callToAction,
34
+ image,
35
+ logo,
36
+ subheadline,
37
+ title,
38
+ variant = VARIANT.onLight
39
+ }) => {
40
+ const classNames = getClassName('bpk-inset-banner', `bpk-inset-banner--${variant}`, image && 'bpk-inset-banner--with-image');
41
+ const [sheetOpen, setSheetOpen] = useState(false);
42
+ return /*#__PURE__*/_jsxs("div", {
43
+ children: [/*#__PURE__*/_jsxs("div", {
44
+ "aria-label": accessibilityLabel,
45
+ className: classNames,
46
+ style: {
47
+ backgroundColor
48
+ },
49
+ children: [/*#__PURE__*/_jsx("div", {
50
+ className: getClassName('bpk-inset-banner--logo'),
51
+ children: logo && /*#__PURE__*/_jsx("img", {
52
+ className: getClassName('bpk-inset-banner--image'),
53
+ src: logo,
54
+ alt: "",
55
+ "aria-hidden": true
56
+ })
57
+ }), /*#__PURE__*/_jsxs("div", {
58
+ className: getClassName('bpk-inset-banner--text-container'),
59
+ children: [/*#__PURE__*/_jsx(BpkText, {
60
+ textStyle: TEXT_STYLES.label2,
61
+ children: title
62
+ }), /*#__PURE__*/_jsx(BpkText, {
63
+ textStyle: TEXT_STYLES.caption,
64
+ children: subheadline
65
+ })]
66
+ }), callToAction && callToAction.bottomSheetContent && /*#__PURE__*/_jsxs("div", {
67
+ role: "presentation",
68
+ className: getClassName('bpk-inset-banner--cta-container'),
69
+ onClick: e => {
70
+ // Do not propagate the click on the trigger OR bottomSheet content up the DOM tree.
71
+ e.stopPropagation();
72
+ e.preventDefault();
73
+ },
74
+ children: [/*#__PURE__*/_jsx("button", {
75
+ "aria-label": callToAction?.buttonA11yLabel,
76
+ className: getClassName('bpk-inset-banner--cta-button'),
77
+ "data-testid": "ctaBtn",
78
+ "aria-hidden": "false",
79
+ type: "button",
80
+ onClick: () => setSheetOpen(true),
81
+ children: /*#__PURE__*/_jsxs("div", {
82
+ className: getClassName('bpk-inset-banner--cta-content'),
83
+ children: [callToAction?.text && /*#__PURE__*/_jsx(BpkText, {
84
+ textStyle: TEXT_STYLES.caption,
85
+ children: callToAction.text
86
+ }), /*#__PURE__*/_jsx("div", {
87
+ className: getClassName('bpk-inset-banner--cta-info-icon'),
88
+ children: /*#__PURE__*/_jsx(InfoIcon, {})
89
+ })]
90
+ })
91
+ }), /*#__PURE__*/_jsx(BpkBottomSheet, {
92
+ id: "InsetBannerBottomSheet",
93
+ isOpen: sheetOpen,
94
+ onClose: () => setSheetOpen(false),
95
+ title: callToAction?.bottomSheetTitle || '',
96
+ closeLabel: "Close bottom sheet",
97
+ ariaLabel: callToAction?.bottomSheetA11yLabel || '',
98
+ children: callToAction.bottomSheetContent.map((item, index) => /*#__PURE__*/_jsxs("div", {
99
+ className: getClassName('bpk-inset-banner--bottom-sheet-content'),
100
+ children: [/*#__PURE__*/_jsx("div", {
101
+ className: getClassName('bpk-inset-banner--bottom-sheet-icon'),
102
+ children: index === 0 ? /*#__PURE__*/_jsx(ViewIcon, {
103
+ height: 24,
104
+ width: 24
105
+ }) : /*#__PURE__*/_jsx(InfoIcon, {
106
+ height: 24,
107
+ width: 24
108
+ })
109
+ }), /*#__PURE__*/_jsxs("div", {
110
+ className: getClassName('bpk-inset-banner--bottom-sheet-text'),
111
+ children: [/*#__PURE__*/_jsx("div", {
112
+ className: getClassName('bpk-inset-banner--bottom-sheet-title'),
113
+ children: /*#__PURE__*/_jsx(BpkText, {
114
+ textStyle: TEXT_STYLES.heading4,
115
+ children: item.title
116
+ })
117
+ }), /*#__PURE__*/_jsx("div", {
118
+ className: getClassName('bpk-inset-banner--bottom-sheet-description'),
119
+ children: /*#__PURE__*/_jsx(BpkText, {
120
+ textStyle: TEXT_STYLES.bodyDefault,
121
+ children: item.description
122
+ })
123
+ })]
124
+ })]
125
+ }, item.title))
126
+ })]
127
+ })]
128
+ }), image && /*#__PURE__*/_jsx("div", {
129
+ className: getClassName('bpk-inset-banner-image-container'),
130
+ children: /*#__PURE__*/_jsx(BpkImage, {
131
+ src: image.src,
132
+ altText: image.altText,
133
+ aspectRatio: image.aspectRatio
134
+ })
135
+ })]
136
+ });
137
+ };
138
+ export default BpkInsetBannerSponsored;
@@ -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-inset-banner{display:grid;padding:.5rem 1rem;grid-template-columns:auto 1fr auto;grid-template-areas:"logo content cta";align-items:center;border-radius:.5rem}@media(max-width: 32rem){.bpk-inset-banner{grid-template-columns:1fr auto;grid-template-areas:"logo cta" "content content"}}.bpk-inset-banner--logo{grid-area:logo}.bpk-inset-banner--with-image{border-radius:.5rem .5rem 0 0}.bpk-inset-banner--on-light{color:#161616;fill:#161616}.bpk-inset-banner--on-dark{color:#fff;fill:#fff}.bpk-inset-banner--image{max-height:2rem;object-fit:contain;padding-inline-end:1rem}.bpk-inset-banner--text-container{display:flex;grid-area:content;flex-direction:column;word-wrap:break-word}.bpk-inset-banner--cta-text{display:flex;align-items:center}.bpk-inset-banner--cta-button{all:unset}.bpk-inset-banner--cta-button:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-inset-banner--cta-container{display:flex;height:2rem;grid-area:cta;align-items:center;cursor:pointer}.bpk-inset-banner--cta-content{display:flex;align-items:center}.bpk-inset-banner--cta-info-icon{display:flex;align-items:center;margin-inline-start:.5rem}.bpk-inset-banner--bottom-sheet-content{display:flex;padding-bottom:2rem;flex-direction:row}.bpk-inset-banner--bottom-sheet-icon{display:flex;margin-right:1.5rem;fill:#161616}.bpk-inset-banner--bottom-sheet-text{display:flex;flex-direction:column}.bpk-inset-banner--bottom-sheet-title{margin-bottom:.5rem;color:#161616}.bpk-inset-banner--bottom-sheet-description{color:#161616}.bpk-inset-banner-image-container{min-height:7.5rem;border-radius:0 0 .5rem .5rem;overflow:hidden}
@@ -0,0 +1,40 @@
1
+ export declare const VARIANT: {
2
+ onLight: string;
3
+ onDark: string;
4
+ };
5
+ type callToActionType = {
6
+ text?: string;
7
+ bottomSheetContent: Array<{
8
+ title: string;
9
+ description: string;
10
+ }>;
11
+ bottomSheetTitle?: string;
12
+ buttonCloseLabel?: string;
13
+ buttonA11yLabel?: string;
14
+ bottomSheetLabel?: string;
15
+ bottomSheetId?: string;
16
+ bottomSheetWidth?: string;
17
+ bottomSheetMarginStart?: string;
18
+ bottomSheetMarginEnd?: string;
19
+ bottomSheetA11yLabel?: string;
20
+ labelTitle?: boolean;
21
+ closeBtnIcon?: boolean;
22
+ zIndexCustom?: number;
23
+ };
24
+ export type CommonProps = {
25
+ accessibilityLabel?: string;
26
+ backgroundColor?: string;
27
+ callToAction?: callToActionType & {
28
+ bottomSheetContent: callToActionType['bottomSheetContent'];
29
+ };
30
+ logo: string;
31
+ subheadline?: string;
32
+ title?: string;
33
+ variant?: (typeof VARIANT)[keyof typeof VARIANT];
34
+ image?: {
35
+ src: string;
36
+ altText: string;
37
+ aspectRatio: number;
38
+ };
39
+ };
40
+ export {};
@@ -0,0 +1,21 @@
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
+ export const VARIANT = {
19
+ onLight: 'on-light',
20
+ onDark: 'on-dark'
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "37.9.1",
3
+ "version": "37.10.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",