@skyscanner/backpack-web 37.10.0 → 37.11.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.
@@ -0,0 +1,2 @@
1
+ import BpkPanel from './src/BpkPanel';
2
+ export default BpkPanel;
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ export type Props = {
3
+ children: ReactNode;
4
+ padded?: boolean;
5
+ fullWidth?: boolean;
6
+ className?: string | null;
7
+ keyline?: boolean;
8
+ [rest: string]: any;
9
+ };
10
+ declare const BpkPanel: ({ children, className, fullWidth, keyline, padded, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export default BpkPanel;
@@ -16,26 +16,32 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import PropTypes from 'prop-types';
20
19
  import { cssModules } from "../../bpk-react-utils";
21
20
  import STYLES from "./BpkPanel.module.css";
22
21
  import { jsx as _jsx } from "react/jsx-runtime";
23
22
  const getClassName = cssModules(STYLES);
24
- const BpkPanel = props => {
23
+ const BpkPanel = ({
24
+ children,
25
+ className = null,
26
+ fullWidth = false,
27
+ keyline = true,
28
+ padded = true,
29
+ ...rest
30
+ }) => {
25
31
  const classNames = [getClassName('bpk-panel')];
26
- const {
27
- children,
28
- className,
29
- fullWidth,
30
- padded,
31
- ...rest
32
- } = props;
33
32
  if (padded) {
34
33
  classNames.push(getClassName('bpk-panel--padded'));
35
34
  }
36
35
  if (fullWidth) {
37
36
  classNames.push(getClassName('bpk-panel--full-width'));
38
37
  }
38
+ if (keyline) {
39
+ if (fullWidth) {
40
+ classNames.push(getClassName('bpk-panel--full-width-keyline'));
41
+ } else {
42
+ classNames.push(getClassName('bpk-panel--keyline'));
43
+ }
44
+ }
39
45
  if (className) {
40
46
  classNames.push(className);
41
47
  }
@@ -45,15 +51,4 @@ const BpkPanel = props => {
45
51
  children: children
46
52
  });
47
53
  };
48
- BpkPanel.propTypes = {
49
- children: PropTypes.node.isRequired,
50
- padded: PropTypes.bool,
51
- fullWidth: PropTypes.bool,
52
- className: PropTypes.string
53
- };
54
- BpkPanel.defaultProps = {
55
- padded: true,
56
- fullWidth: false,
57
- className: null
58
- };
59
54
  export default BpkPanel;
@@ -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-panel{display:block;background-color:#fff;box-shadow:0 0 0 1px #c1c7cf inset;border-radius:.75rem}.bpk-panel--padded{padding:1rem}.bpk-panel--full-width{border-radius:0;box-shadow:#c1c7cf 0 -0.0625rem 0 0 inset,#c1c7cf 0 .0625rem 0 0 inset}
18
+ .bpk-panel{display:block;background-color:#fff;border-radius:.75rem}.bpk-panel--padded{padding:1rem}.bpk-panel--full-width{border-radius:0}.bpk-panel--keyline{box-shadow:0 0 0 1px #c1c7cf inset}.bpk-panel--full-width-keyline{box-shadow:#c1c7cf 0 -0.0625rem 0 0 inset,#c1c7cf 0 .0625rem 0 0 inset}
@@ -1,4 +1,3 @@
1
- import PropTypes from 'prop-types';
2
1
  import type { ReactNode } from 'react';
3
2
  import { RATING_SIZES, RATING_SCALES } from './common-types';
4
3
  type ValueOf<T> = T[keyof T];
@@ -11,26 +10,7 @@ type Props = {
11
10
  subtitle?: string;
12
11
  title?: string | ReactNode;
13
12
  value: string | number;
13
+ [rest: string]: any;
14
14
  };
15
- declare const BpkRating: {
16
- (props: Props): import("react/jsx-runtime").JSX.Element;
17
- propTypes: {
18
- ariaLabel: PropTypes.Validator<string>;
19
- value: PropTypes.Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
20
- className: PropTypes.Requireable<string>;
21
- ratingScale: PropTypes.Requireable<string>;
22
- size: PropTypes.Requireable<string>;
23
- subtitle: PropTypes.Requireable<string>;
24
- showScale: PropTypes.Requireable<boolean>;
25
- title: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
26
- };
27
- defaultProps: {
28
- className: null;
29
- ratingScale: "zeroToFive";
30
- size: "base";
31
- subtitle: null;
32
- showScale: boolean;
33
- title: null;
34
- };
35
- };
15
+ declare const BpkRating: ({ ariaLabel, className, ratingScale, showScale, size, subtitle, title, value, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
36
16
  export default BpkRating;
@@ -16,7 +16,6 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import PropTypes from 'prop-types';
20
19
  import clamp from 'lodash.clamp';
21
20
  import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
22
21
  import { cssModules } from "../../bpk-react-utils";
@@ -37,18 +36,17 @@ const getMaxValue = ratingScale => {
37
36
  return 10;
38
37
  }
39
38
  };
40
- const BpkRating = props => {
41
- const {
42
- ariaLabel,
43
- className,
44
- ratingScale,
45
- showScale,
46
- size,
47
- subtitle,
48
- title,
49
- value,
50
- ...rest
51
- } = props;
39
+ const BpkRating = ({
40
+ ariaLabel,
41
+ className,
42
+ ratingScale = RATING_SCALES.zeroToFive,
43
+ showScale = true,
44
+ size = RATING_SIZES.base,
45
+ subtitle = undefined,
46
+ title = null,
47
+ value,
48
+ ...rest
49
+ }) => {
52
50
  const classNames = getClassName('bpk-rating', className, size === RATING_SIZES.large && title && subtitle && 'bpk-rating--large');
53
51
  const valueStyles = getClassName('bpk-rating__value');
54
52
  const scaleStyles = getClassName('bpk-rating__scale');
@@ -96,42 +94,24 @@ const BpkRating = props => {
96
94
  })]
97
95
  }), /*#__PURE__*/_jsxs("div", {
98
96
  className: textWrapperStyles,
99
- children: [title && /*#__PURE__*/_jsx(BpkText, {
100
- textStyle: titleTextSize,
101
- tagName: "span",
102
- "aria-hidden": "true",
103
- children: /*#__PURE__*/_jsx("span", {
104
- className: titleStyles,
97
+ children: [title && /*#__PURE__*/_jsx("span", {
98
+ className: titleStyles,
99
+ children: /*#__PURE__*/_jsx(BpkText, {
100
+ textStyle: titleTextSize,
101
+ tagName: "span",
102
+ "aria-hidden": "true",
105
103
  children: title
106
104
  })
107
- }), subtitle && /*#__PURE__*/_jsx(BpkText, {
108
- textStyle: subtitleTextSize,
109
- tagName: "span",
110
- "aria-hidden": "true",
111
- children: /*#__PURE__*/_jsx("span", {
112
- className: subtitleStyles,
105
+ }), subtitle && /*#__PURE__*/_jsx("span", {
106
+ className: subtitleStyles,
107
+ children: /*#__PURE__*/_jsx(BpkText, {
108
+ textStyle: subtitleTextSize,
109
+ tagName: "span",
110
+ "aria-hidden": "true",
113
111
  children: subtitle
114
112
  })
115
113
  })]
116
114
  })]
117
115
  });
118
116
  };
119
- BpkRating.propTypes = {
120
- ariaLabel: PropTypes.string.isRequired,
121
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
122
- className: PropTypes.string,
123
- ratingScale: PropTypes.oneOf(Object.keys(RATING_SCALES)),
124
- size: PropTypes.oneOf(Object.keys(RATING_SIZES)),
125
- subtitle: PropTypes.string,
126
- showScale: PropTypes.bool,
127
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
128
- };
129
- BpkRating.defaultProps = {
130
- className: null,
131
- ratingScale: RATING_SCALES.zeroToFive,
132
- size: RATING_SIZES.base,
133
- subtitle: null,
134
- showScale: true,
135
- title: null
136
- };
137
117
  export default BpkRating;
@@ -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-rating{display:flex;flex-flow:row nowrap;align-items:baseline}.bpk-rating--large{align-items:center}.bpk-rating__value{padding-inline-end:.5rem}.bpk-rating__text-wrapper{display:flex;flex-direction:row;align-items:baseline;white-space:nowrap}.bpk-rating__text-wrapper--large{padding-top:.0625rem;flex-direction:column;align-items:flex-start}.bpk-rating__scale{color:#626971}.bpk-rating__title--with-subtitle{padding-right:.5rem}html[dir=rtl] .bpk-rating__title--with-subtitle{padding-right:0;padding-left:.5rem}.bpk-rating__subtitle{color:#626971}
18
+ .bpk-rating{display:flex;flex-flow:row nowrap;align-items:baseline}.bpk-rating--large{align-items:center}.bpk-rating__value{padding-inline-end:.5rem}.bpk-rating__text-wrapper{display:flex;min-width:0;flex-direction:row;align-items:baseline;white-space:nowrap}.bpk-rating__text-wrapper--large{padding-top:.0625rem;flex-direction:column;align-items:flex-start}.bpk-rating__scale{color:#626971}.bpk-rating__title--with-subtitle{padding-right:.5rem}html[dir=rtl] .bpk-rating__title--with-subtitle{padding-right:0;padding-left:.5rem}.bpk-rating__subtitle{min-width:0;max-width:100%;flex:1 1 auto;color:#626971;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}
@@ -39,8 +39,9 @@ type Props = {
39
39
  textStyle?: TextStyle;
40
40
  tagName?: Tag;
41
41
  className?: string | null;
42
+ color?: string | null;
42
43
  id?: string;
43
44
  [rest: string]: any;
44
45
  };
45
- declare const BpkText: ({ children, className, tagName: TagName, textStyle, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
46
+ declare const BpkText: ({ children, className, color, tagName: TagName, textStyle, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
46
47
  export default BpkText;
@@ -56,18 +56,30 @@ export const TEXT_STYLES = {
56
56
  const BpkText = ({
57
57
  children,
58
58
  className = null,
59
+ color = null,
59
60
  tagName: TagName = 'span',
60
61
  textStyle = TEXT_STYLES.bodyDefault,
61
62
  ...rest
62
63
  }) => {
63
64
  const classNames = getClassName('bpk-text', `bpk-text--${textStyle}`, className);
65
+ const {
66
+ style,
67
+ ...otherProps
68
+ } = rest;
69
+ const computedStyles = {
70
+ ...style,
71
+ ...(color ? {
72
+ color
73
+ } : {})
74
+ };
64
75
  return (
65
76
  /*#__PURE__*/
66
77
  // Allowed, TagName is always a dom element.
67
78
  // eslint-disable-next-line @skyscanner/rules/forbid-component-props
68
79
  _jsx(TagName, {
69
80
  className: classNames,
70
- ...rest,
81
+ style: computedStyles,
82
+ ...otherProps,
71
83
  children: children
72
84
  })
73
85
  );
@@ -36,7 +36,6 @@
36
36
  display: block;
37
37
  background-color: $bpk-card-background-color;
38
38
 
39
- @include bpk-border-sm($bpk-panel-border-color);
40
39
  @include bpk-border-radius-md;
41
40
  }
42
41
 
@@ -53,7 +52,21 @@
53
52
  padding: $bpk-card-padding;
54
53
  }
55
54
 
56
- /// Makes panel full width by removing left and right border.
55
+ /// Controls if we have a keyline or not on the panel
56
+ /// Modifies the bpk-panel mixin.
57
+ ///
58
+ /// @require {mixin} bpk-panel
59
+ ///
60
+ /// @example scss
61
+ /// .selector {
62
+ /// @include bpk-panel();
63
+ /// @include bpk-panel--keyline();
64
+ /// }
65
+ @mixin bpk-panel--keyline {
66
+ @include bpk-border-sm($bpk-panel-border-color);
67
+ }
68
+
69
+ /// Makes panel full width by removing the border radius
57
70
  /// Modifies the bpk-panel mixin.
58
71
  ///
59
72
  /// @require {mixin} bpk-panel
@@ -65,6 +78,18 @@
65
78
  /// }
66
79
  @mixin bpk-panel--full-width {
67
80
  border-radius: 0;
81
+ }
82
+
83
+ /// Sets the keyline to only show on the top and bottom when full
84
+ ///
85
+ /// @require {mixin} bpk-panel
86
+ ///
87
+ /// @example scss
88
+ /// .selector {
89
+ /// @include bpk-panel();
90
+ /// @include bpk-panel--full-width-keyline();
91
+ /// }
92
+ @mixin bpk-panel--full-width-keyline {
68
93
  box-shadow:
69
94
  $bpk-panel-border-color 0 -1 * $bpk-one-pixel-rem 0 0 inset,
70
95
  $bpk-panel-border-color 0 $bpk-one-pixel-rem 0 0 inset;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "37.10.0",
3
+ "version": "37.11.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,9 +31,9 @@
31
31
  "@skyscanner/bpk-svgs": "^20.6.0",
32
32
  "a11y-focus-scope": "^1.1.3",
33
33
  "a11y-focus-store": "^1.0.0",
34
- "d3-path": "^2.0.0",
34
+ "d3-path": "^3.1.0",
35
35
  "d3-scale": "^4.0.2",
36
- "intersection-observer": "^0.7.0",
36
+ "intersection-observer": "^0.12.2",
37
37
  "lodash": "^4.17.20",
38
38
  "lodash.clamp": "^4.0.3",
39
39
  "lodash.debounce": "^4.0.8",
@@ -36,7 +36,6 @@
36
36
  display: block;
37
37
  background-color: tokens.$bpk-card-background-color;
38
38
 
39
- @include borders.bpk-border-sm(tokens.$bpk-panel-border-color);
40
39
  @include radii.bpk-border-radius-md;
41
40
  }
42
41
 
@@ -53,7 +52,21 @@
53
52
  padding: tokens.$bpk-card-padding;
54
53
  }
55
54
 
56
- /// Makes panel full width by removing left and right border.
55
+ /// Controls if we have a keyline or not on the panel
56
+ /// Modifies the bpk-panel mixin.
57
+ ///
58
+ /// @require {mixin} bpk-panel
59
+ ///
60
+ /// @example scss
61
+ /// .selector {
62
+ /// @include bpk-panel();
63
+ /// @include bpk-panel--keyline();
64
+ /// }
65
+ @mixin bpk-panel--keyline {
66
+ @include borders.bpk-border-sm(tokens.$bpk-panel-border-color);
67
+ }
68
+
69
+ /// Makes panel full width by removing the border radius
57
70
  /// Modifies the bpk-panel mixin.
58
71
  ///
59
72
  /// @require {mixin} bpk-panel
@@ -65,6 +78,18 @@
65
78
  /// }
66
79
  @mixin bpk-panel--full-width {
67
80
  border-radius: 0;
81
+ }
82
+
83
+ /// Sets the keyline to only show on the top and bottom when full
84
+ ///
85
+ /// @require {mixin} bpk-panel
86
+ ///
87
+ /// @example scss
88
+ /// .selector {
89
+ /// @include bpk-panel();
90
+ /// @include bpk-panel--full-width-keyline();
91
+ /// }
92
+ @mixin bpk-panel--full-width-keyline {
68
93
  box-shadow:
69
94
  tokens.$bpk-panel-border-color 0 -1 * tokens.$bpk-one-pixel-rem 0 0 inset,
70
95
  tokens.$bpk-panel-border-color 0 tokens.$bpk-one-pixel-rem 0 0 inset;