@skyscanner/backpack-web 42.5.2 → 42.6.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.
@@ -6,7 +6,7 @@ export type Props = {
6
6
  onClose?: (arg0?: TouchEvent | MouseEvent | KeyboardEvent, arg1?: {
7
7
  source: 'ESCAPE' | 'DOCUMENT_CLICK';
8
8
  }) => void;
9
- title: string;
9
+ title: ReactNode;
10
10
  getApplicationElement: () => HTMLElement | null;
11
11
  width?: string;
12
12
  renderTarget?: null | HTMLElement | (() => null | HTMLElement);
@@ -5,7 +5,7 @@ type Props = {
5
5
  onCloseAnimationComplete: () => void;
6
6
  onClose: () => void;
7
7
  id: string;
8
- title: string;
8
+ title: ReactNode;
9
9
  width?: string;
10
10
  className?: string | null;
11
11
  contentClassName?: string;
@@ -16,3 +16,5 @@ export type { BpkCommonLayoutProps, BpkBoxSpecificProps, BpkFlexSpecificProps, B
16
16
  export type { BpkStackSpecificProps } from './src/types';
17
17
  export type { BpkSpacingToken, BpkBreakpointToken, BpkSpacingValue, BpkBreakpointValue, } from './src/tokens';
18
18
  export { BpkSpacing, BpkBreakpoint, isValidSpacingValue, isPercentage, } from './src/tokens';
19
+ export { BACKGROUND_COLORS } from './src/backgroundColors';
20
+ export type { BpkLayoutBackgroundColor } from './src/backgroundColors';
@@ -26,4 +26,7 @@ export { BpkStack, BpkHStack, BpkVStack } from "./src/BpkStack";
26
26
 
27
27
  // Export token types and utilities
28
28
 
29
- export { BpkSpacing, BpkBreakpoint, isValidSpacingValue, isPercentage } from "./src/tokens";
29
+ export { BpkSpacing, BpkBreakpoint, isValidSpacingValue, isPercentage } from "./src/tokens";
30
+
31
+ // Export color constants and types
32
+ export { BACKGROUND_COLORS } from "./src/backgroundColors";
@@ -18,21 +18,31 @@
18
18
 
19
19
  import { forwardRef } from 'react';
20
20
  import { Box } from '@chakra-ui/react';
21
- import { getDataComponentAttribute } from "../../bpk-react-utils";
21
+ import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
22
22
  import { processBpkComponentProps } from "./tokenUtils";
23
+ import STYLES from "./BpkLayout.module.css";
23
24
  import { jsx as _jsx } from "react/jsx-runtime";
25
+ const getClassName = cssModules(STYLES);
24
26
  export const BpkBox = /*#__PURE__*/forwardRef(({
27
+ backgroundColor,
25
28
  children,
29
+ color,
26
30
  ...props
27
31
  }, ref) => {
28
32
  const processedProps = processBpkComponentProps(props, {
29
33
  component: 'BpkBox'
30
34
  });
31
- return /*#__PURE__*/_jsx(Box, {
32
- ref: ref,
33
- ...getDataComponentAttribute('Box'),
34
- ...processedProps,
35
- children: children
36
- });
35
+ const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
36
+ return (
37
+ /*#__PURE__*/
38
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
39
+ _jsx(Box, {
40
+ ref: ref,
41
+ className: classNames,
42
+ ...getDataComponentAttribute('Box'),
43
+ ...processedProps,
44
+ children: children
45
+ })
46
+ );
37
47
  });
38
48
  BpkBox.displayName = 'BpkBox';
@@ -18,13 +18,17 @@
18
18
 
19
19
  import { forwardRef } from 'react';
20
20
  import { Flex } from '@chakra-ui/react';
21
- import { getDataComponentAttribute } from "../../bpk-react-utils";
21
+ import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
22
22
  import { processBpkComponentProps } from "./tokenUtils";
23
+ import STYLES from "./BpkLayout.module.css";
23
24
  import { jsx as _jsx } from "react/jsx-runtime";
25
+ const getClassName = cssModules(STYLES);
24
26
  export const BpkFlex = /*#__PURE__*/forwardRef(({
25
27
  align,
28
+ backgroundColor,
26
29
  basis,
27
30
  children,
31
+ color,
28
32
  direction,
29
33
  grow,
30
34
  inline,
@@ -47,8 +51,12 @@ export const BpkFlex = /*#__PURE__*/forwardRef(({
47
51
  flexBasis: basis
48
52
  }
49
53
  });
54
+ const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
50
55
  return /*#__PURE__*/_jsx(Flex, {
51
- ref: ref,
56
+ ref: ref
57
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
58
+ ,
59
+ className: classNames,
52
60
  ...getDataComponentAttribute('Flex'),
53
61
  ...processedProps,
54
62
  display: inline ? 'inline-flex' : undefined,
@@ -18,15 +18,19 @@
18
18
 
19
19
  import { forwardRef } from 'react';
20
20
  import { Grid } from '@chakra-ui/react';
21
- import { getDataComponentAttribute } from "../../bpk-react-utils";
21
+ import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
22
22
  import { processBpkComponentProps } from "./tokenUtils";
23
+ import STYLES from "./BpkLayout.module.css";
23
24
  import { jsx as _jsx } from "react/jsx-runtime";
25
+ const getClassName = cssModules(STYLES);
24
26
  export const BpkGrid = /*#__PURE__*/forwardRef(({
25
27
  align,
26
28
  autoColumns,
27
29
  autoFlow,
28
30
  autoRows,
31
+ backgroundColor,
29
32
  children,
33
+ color,
30
34
  column,
31
35
  inline,
32
36
  justify,
@@ -53,8 +57,12 @@ export const BpkGrid = /*#__PURE__*/forwardRef(({
53
57
  gridRow: row
54
58
  }
55
59
  });
60
+ const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
56
61
  return /*#__PURE__*/_jsx(Grid, {
57
- ref: ref,
62
+ ref: ref
63
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
64
+ ,
65
+ className: classNames,
58
66
  ...getDataComponentAttribute('Grid'),
59
67
  ...processedProps,
60
68
  display: inline ? 'inline-grid' : undefined,
@@ -18,15 +18,19 @@
18
18
 
19
19
  import { forwardRef } from 'react';
20
20
  import { GridItem } from '@chakra-ui/react';
21
- import { getDataComponentAttribute } from "../../bpk-react-utils";
21
+ import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
22
22
  import { processBpkComponentProps } from "./tokenUtils";
23
+ import STYLES from "./BpkLayout.module.css";
23
24
  import { jsx as _jsx } from "react/jsx-runtime";
25
+ const getClassName = cssModules(STYLES);
24
26
  export const BpkGridItem = /*#__PURE__*/forwardRef(({
25
27
  area,
28
+ backgroundColor,
26
29
  children,
27
30
  colEnd,
28
31
  colSpan,
29
32
  colStart,
33
+ color,
30
34
  rowEnd,
31
35
  rowSpan,
32
36
  rowStart,
@@ -39,8 +43,12 @@ export const BpkGridItem = /*#__PURE__*/forwardRef(({
39
43
  }, {
40
44
  component: 'BpkGridItem'
41
45
  });
46
+ const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
42
47
  return /*#__PURE__*/_jsx(GridItem, {
43
- ref: ref,
48
+ ref: ref
49
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
50
+ ,
51
+ className: classNames,
44
52
  ...getDataComponentAttribute('GridItem'),
45
53
  ...processedProps,
46
54
  area: area,
@@ -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-layout.bpk-layout--text-disabled{color:rgba(0,0,0,.2)}.bpk-layout.bpk-layout--text-disabled-on-dark{color:hsla(0,0%,100%,.5)}.bpk-layout.bpk-layout--text-error{color:#e70866}.bpk-layout.bpk-layout--text-hero{color:#0062e3}.bpk-layout.bpk-layout--text-link{color:#0062e3}.bpk-layout.bpk-layout--text-on-dark{color:#fff}.bpk-layout.bpk-layout--text-on-light{color:#161616}.bpk-layout.bpk-layout--text-primary{color:#161616}.bpk-layout.bpk-layout--text-primary-inverse{color:#fff}.bpk-layout.bpk-layout--text-secondary{color:#626971}.bpk-layout.bpk-layout--text-success{color:#0c838a}.bpk-layout.bpk-layout--surface-default{background-color:#fff}.bpk-layout.bpk-layout--surface-elevated{background-color:#fff}.bpk-layout.bpk-layout--surface-hero{background-color:#0062e3}.bpk-layout.bpk-layout--surface-contrast{background-color:#05203c}.bpk-layout.bpk-layout--surface-highlight{background-color:#e0e4e9}.bpk-layout.bpk-layout--surface-subtle{background-color:#e3f0ff}.bpk-layout.bpk-layout--surface-low-contrast{background-color:#f5f7fa}.bpk-layout.bpk-layout--surface-tint{background-color:hsla(0,0%,100%,.1)}.bpk-layout.bpk-layout--canvas{background-color:#fff}.bpk-layout.bpk-layout--canvas-contrast{background-color:#eff3f8}.bpk-layout.bpk-layout--status-success-fill{background-color:#d4fff2}.bpk-layout.bpk-layout--status-danger-fill{background-color:#ffe9f9}.bpk-layout.bpk-layout--status-warning-fill{background-color:#fff7cf}
@@ -18,51 +18,77 @@
18
18
 
19
19
  import { forwardRef } from 'react';
20
20
  import { Stack, VStack, HStack } from '@chakra-ui/react';
21
- import { getDataComponentAttribute } from "../../bpk-react-utils";
21
+ import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
22
22
  import { processBpkComponentProps } from "./tokenUtils";
23
+ import STYLES from "./BpkLayout.module.css";
23
24
  import { jsx as _jsx } from "react/jsx-runtime";
25
+ const getClassName = cssModules(STYLES);
24
26
  export const BpkStack = /*#__PURE__*/forwardRef(({
27
+ backgroundColor,
25
28
  children,
29
+ color,
26
30
  ...props
27
31
  }, ref) => {
28
32
  const processedProps = processBpkComponentProps(props, {
29
33
  component: 'BpkStack'
30
34
  });
31
- return /*#__PURE__*/_jsx(Stack, {
32
- ref: ref,
33
- ...getDataComponentAttribute('Stack'),
34
- ...processedProps,
35
- children: children
36
- });
35
+ const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
36
+ return (
37
+ /*#__PURE__*/
38
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
39
+ _jsx(Stack, {
40
+ ref: ref,
41
+ className: classNames,
42
+ ...getDataComponentAttribute('Stack'),
43
+ ...processedProps,
44
+ children: children
45
+ })
46
+ );
37
47
  });
38
48
  BpkStack.displayName = 'BpkStack';
39
49
  export const BpkHStack = /*#__PURE__*/forwardRef(({
50
+ backgroundColor,
40
51
  children,
52
+ color,
41
53
  ...props
42
54
  }, ref) => {
43
55
  const processedProps = processBpkComponentProps(props, {
44
56
  component: 'BpkStack'
45
57
  });
46
- return /*#__PURE__*/_jsx(HStack, {
47
- ref: ref,
48
- ...getDataComponentAttribute('HStack'),
49
- ...processedProps,
50
- children: children
51
- });
58
+ const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
59
+ return (
60
+ /*#__PURE__*/
61
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
62
+ _jsx(HStack, {
63
+ ref: ref,
64
+ className: classNames,
65
+ ...getDataComponentAttribute('HStack'),
66
+ ...processedProps,
67
+ children: children
68
+ })
69
+ );
52
70
  });
53
71
  BpkHStack.displayName = 'BpkHStack';
54
72
  export const BpkVStack = /*#__PURE__*/forwardRef(({
73
+ backgroundColor,
55
74
  children,
75
+ color,
56
76
  ...props
57
77
  }, ref) => {
58
78
  const processedProps = processBpkComponentProps(props, {
59
79
  component: 'BpkStack'
60
80
  });
61
- return /*#__PURE__*/_jsx(VStack, {
62
- ref: ref,
63
- ...getDataComponentAttribute('VStack'),
64
- ...processedProps,
65
- children: children
66
- });
81
+ const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
82
+ return (
83
+ /*#__PURE__*/
84
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
85
+ _jsx(VStack, {
86
+ ref: ref,
87
+ className: classNames,
88
+ ...getDataComponentAttribute('VStack'),
89
+ ...processedProps,
90
+ children: children
91
+ })
92
+ );
67
93
  });
68
94
  BpkVStack.displayName = 'BpkVStack';
@@ -0,0 +1,16 @@
1
+ export declare const BACKGROUND_COLORS: {
2
+ readonly statusSuccessFill: "status-success-fill";
3
+ readonly statusDangerFill: "status-danger-fill";
4
+ readonly statusWarningFill: "status-warning-fill";
5
+ readonly canvas: "canvas";
6
+ readonly canvasContrast: "canvas-contrast";
7
+ readonly surfaceDefault: "surface-default";
8
+ readonly surfaceElevated: "surface-elevated";
9
+ readonly surfaceHero: "surface-hero";
10
+ readonly surfaceContrast: "surface-contrast";
11
+ readonly surfaceHighlight: "surface-highlight";
12
+ readonly surfaceSubtle: "surface-subtle";
13
+ readonly surfaceLowContrast: "surface-low-contrast";
14
+ readonly surfaceTint: "surface-tint";
15
+ };
16
+ export type BpkLayoutBackgroundColor = (typeof BACKGROUND_COLORS)[keyof typeof BACKGROUND_COLORS];
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import { SURFACE_COLORS } from "../../bpk-react-utils";
20
+
21
+ // Canvas colors (day mode only)
22
+ const CANVAS_COLORS = {
23
+ canvas: 'canvas',
24
+ canvasContrast: 'canvas-contrast'
25
+ };
26
+
27
+ // Status fill colors (day mode only — only fill, not spot or on-dark)
28
+ const STATUS_FILL_COLORS = {
29
+ statusSuccessFill: 'status-success-fill',
30
+ statusDangerFill: 'status-danger-fill',
31
+ statusWarningFill: 'status-warning-fill'
32
+ };
33
+ export const BACKGROUND_COLORS = {
34
+ ...SURFACE_COLORS,
35
+ ...CANVAS_COLORS,
36
+ ...STATUS_FILL_COLORS
37
+ };
@@ -1,6 +1,7 @@
1
1
  import type { AriaRole, KeyboardEventHandler, MouseEventHandler } from 'react';
2
+ import type { BpkLayoutBackgroundColor } from './backgroundColors';
2
3
  import type { BpkSpacingValue, BpkSizeValue, BpkPositionValue, BpkResponsiveValue } from './tokens';
3
- import type { TextStyle } from '../../bpk-component-text/src/BpkText';
4
+ import type { TextColor, TextStyle } from '../../bpk-component-text';
4
5
  /**
5
6
  * Common spacing-related props shared by all Backpack layout components
6
7
  * All spacing props must use Backpack spacing tokens or percentages
@@ -55,9 +56,9 @@ export interface BpkCommonLayoutProps extends BpkSpacingProps {
55
56
  textStyle?: BpkResponsiveValue<TextStyle>;
56
57
  'data-testid'?: string;
57
58
  'data-cy'?: string;
58
- color?: never;
59
+ color?: TextColor;
60
+ backgroundColor?: BpkLayoutBackgroundColor;
59
61
  background?: never;
60
- backgroundColor?: never;
61
62
  borderColor?: never;
62
63
  borderTopColor?: never;
63
64
  borderRightColor?: never;
@@ -37,7 +37,11 @@
37
37
  /// @access private
38
38
 
39
39
  @mixin _bpk-border-top($size, $color, $inset) {
40
- $offset-y: if($inset == inset, $size, -#{$size});
40
+ $offset-y: $size;
41
+
42
+ @if $inset != inset {
43
+ $offset-y: -#{$size};
44
+ }
41
45
 
42
46
  box-shadow: 0 $offset-y 0 0 $color #{$inset};
43
47
  }
@@ -47,7 +51,11 @@
47
51
  /// @access private
48
52
 
49
53
  @mixin bpk-border-right($size, $color, $inset) {
50
- $offset-x: if($inset == inset, -#{$size}, $size);
54
+ $offset-x: -#{$size};
55
+
56
+ @if $inset != inset {
57
+ $offset-x: $size;
58
+ }
51
59
 
52
60
  box-shadow: $offset-x 0 0 0 $color #{$inset};
53
61
  }
@@ -57,7 +65,11 @@
57
65
  /// @access private
58
66
 
59
67
  @mixin _bpk-border-bottom($size, $color, $inset) {
60
- $offset-y: if($inset == inset, -#{$size}, $size);
68
+ $offset-y: -#{$size};
69
+
70
+ @if $inset != inset {
71
+ $offset-y: $size;
72
+ }
61
73
 
62
74
  box-shadow: 0 $offset-y 0 0 $color #{$inset};
63
75
  }
@@ -67,7 +79,11 @@
67
79
  /// @access private
68
80
 
69
81
  @mixin bpk-border-left($size, $color, $inset) {
70
- $offset-x: if($inset == inset, $size, -#{$size});
82
+ $offset-x: $size;
83
+
84
+ @if $inset != inset {
85
+ $offset-x: -#{$size};
86
+ }
71
87
 
72
88
  box-shadow: $offset-x 0 0 0 $color #{$inset};
73
89
  }
@@ -29,7 +29,11 @@
29
29
  /// @access private
30
30
 
31
31
  @mixin _bpk-scroll-indicator($gradient-color, $direction: 'left') {
32
- $gradient-direction: if($direction == 'left', 90deg, 270deg);
32
+ $gradient-direction: 90deg;
33
+
34
+ @if $direction != 'left' {
35
+ $gradient-direction: 270deg;
36
+ }
33
37
 
34
38
  position: absolute;
35
39
  top: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "42.5.2",
3
+ "version": "42.6.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",