@skyscanner/backpack-web 42.6.0-dev-v24171492044.1 → 42.7.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-aria-live/src/BpkAriaLive.story-helpers.d.ts +11 -0
- package/bpk-component-aria-live/src/BpkAriaLive.story-helpers.js +48 -0
- package/bpk-component-bubble/src/BpkBubble.module.css +1 -1
- package/bpk-component-layout/src/BpkProvider.js +6 -10
- package/bpk-component-layout/src/commonProps.d.ts +9 -3
- package/bpk-component-layout/src/theme.d.ts +14 -0
- package/bpk-component-layout/src/theme.js +204 -137
- package/bpk-component-layout/src/tokenUtils.js +23 -7
- package/bpk-component-layout/src/tokens.d.ts +17 -3
- package/bpk-component-layout/src/tokens.js +19 -3
- package/bpk-component-spinner/src/SpinnerLayout.story-helpers.d.ts +12 -0
- package/bpk-component-spinner/src/SpinnerLayout.story-helpers.js +47 -0
- package/bpk-component-spinner/src/SpinnerLayout.story-helpers.module.css +18 -0
- package/bpk-component-text/src/BpkText.module.css +1 -1
- package/bpk-stylesheets/base.css +1 -1
- package/package.json +2 -2
- package/bpk-component-layout/src/spacingMap.d.ts +0 -21
- package/bpk-component-layout/src/spacingMap.js +0 -92
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
type AriaLiveDemoProps = {
|
|
3
|
+
preamble?: ReactElement | null;
|
|
4
|
+
children: ReactElement;
|
|
5
|
+
className?: string | null;
|
|
6
|
+
style?: {};
|
|
7
|
+
visible?: Boolean;
|
|
8
|
+
[rest: string]: any;
|
|
9
|
+
};
|
|
10
|
+
declare const AriaLiveDemo: ({ children, className, preamble, style, visible, ...rest }: AriaLiveDemoProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default AriaLiveDemo;
|
|
@@ -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 { ARIA_LIVE_POLITENESS_SETTINGS } from '..';
|
|
20
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
21
|
+
import BpkAriaLive from "./BpkAriaLive";
|
|
22
|
+
import STYLES from "./BpkAriaLive.stories.module.css";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
const getClassName = cssModules(STYLES);
|
|
25
|
+
const AriaLiveDemo = ({
|
|
26
|
+
children,
|
|
27
|
+
className = null,
|
|
28
|
+
preamble = null,
|
|
29
|
+
style = undefined,
|
|
30
|
+
visible = false,
|
|
31
|
+
...rest
|
|
32
|
+
}) => /*#__PURE__*/_jsxs("div", {
|
|
33
|
+
className: getClassName('bpk-storybook-aria-live-demo', className),
|
|
34
|
+
style: style,
|
|
35
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
36
|
+
children: /*#__PURE__*/_jsx("strong", {
|
|
37
|
+
children: "ARIA live region:"
|
|
38
|
+
})
|
|
39
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
40
|
+
children: visible ? 'This content is relevant to everyone, not just assistive technologies, so it is permanently visible.' : 'This would usually be visually hidden, and only visible to assistive technologies. It is visible here for demo purposes.'
|
|
41
|
+
}), preamble, /*#__PURE__*/_jsx(BpkAriaLive, {
|
|
42
|
+
...rest,
|
|
43
|
+
visible: true,
|
|
44
|
+
politenessSetting: ARIA_LIVE_POLITENESS_SETTINGS.assertive,
|
|
45
|
+
children: children
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
export default AriaLiveDemo;
|
|
@@ -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-bubble{position:relative;display:inline-flex;width:auto;height:1.25rem;padding:0 .5rem;flex-direction:column;justify-content:center;border-radius:.25rem;background-color:#e70866;font-family:var(--bpk-larken-font-stack, "Larken", "Noto Sans Arabic", "Noto Serif Hebrew", "Noto Serif", "Noto Serif Devanagari", "Noto Serif Thai", "Noto Serif
|
|
18
|
+
.bpk-bubble{position:relative;display:inline-flex;width:auto;height:1.25rem;padding:0 .5rem;flex-direction:column;justify-content:center;border-radius:.25rem;background-color:#e70866;font-family:var(--bpk-larken-font-stack, "Larken", "Noto Sans Arabic", "Noto Serif Hebrew", "Noto Serif", "Noto Serif Devanagari", "Noto Serif Thai", "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Noto Serif SC", sans-serif);text-align:center;white-space:nowrap;font-size:.75rem;line-height:1rem;font-weight:400}.bpk-bubble__arrow{position:absolute;bottom:-5px;left:50%;transform:translateX(-50%);color:#e70866}
|
|
@@ -18,21 +18,17 @@
|
|
|
18
18
|
|
|
19
19
|
import { useEffect, useState } from 'react';
|
|
20
20
|
import { LocaleProvider } from '@ark-ui/react';
|
|
21
|
-
import { ChakraProvider, createSystem } from '@chakra-ui/react';
|
|
21
|
+
import { ChakraProvider, createSystem, defaultBaseConfig } from '@chakra-ui/react';
|
|
22
22
|
import { createBpkConfig } from "./theme";
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
/**
|
|
25
|
-
* Creates a Chakra UI system with
|
|
25
|
+
* Creates a Chakra UI system with Backpack token mappings.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* them to Chakra, so the utility transform layer is unused. Standard CSS
|
|
31
|
-
* properties still pass through via Chakra's `isCssProperty` check, and
|
|
32
|
-
* responsive objects work because breakpoint conditions are derived from
|
|
33
|
-
* `theme.breakpoints` in our config.
|
|
27
|
+
* Uses `defaultBaseConfig` (conditions + utilities only) instead of
|
|
28
|
+
* `defaultConfig` to avoid bundling ~141KB of unused component recipes.
|
|
29
|
+
* See: https://chakra-ui.com/guides/component-bundle-optimization
|
|
34
30
|
*/
|
|
35
|
-
const bpkSystem = createSystem(createBpkConfig());
|
|
31
|
+
const bpkSystem = createSystem(defaultBaseConfig, createBpkConfig());
|
|
36
32
|
// Fallback locale mapping used when no explicit locale is available on the document.
|
|
37
33
|
// Maps DOM direction to minimal BCP 47 locales understood by Ark's isRTL() utility.
|
|
38
34
|
// 'ar-SA' is the minimal RTL locale — Ark only uses it to derive dir='rtl'.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AriaRole, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
1
|
+
import type { AriaAttributes, AriaRole, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
2
|
import type { BpkLayoutBackgroundColor } from './backgroundColors';
|
|
3
|
-
import type { BpkSpacingValue, BpkSizeValue, BpkPositionValue, BpkResponsiveValue } from './tokens';
|
|
3
|
+
import type { BpkSpacingValue, BpkSizeValue, BpkPositionValue, BpkPositionKeyword, BpkOverflowValue, BpkZIndexValue, BpkResponsiveValue } from './tokens';
|
|
4
4
|
import type { TextColor, TextStyle } from '../../bpk-component-text';
|
|
5
5
|
/**
|
|
6
6
|
* Common spacing-related props shared by all Backpack layout components
|
|
@@ -46,14 +46,20 @@ export interface BpkSpacingProps {
|
|
|
46
46
|
* container patterns (e.g. clickable cards, landmark regions).
|
|
47
47
|
* - BpkBox additionally exposes onFocus and onBlur on its own props type.
|
|
48
48
|
*/
|
|
49
|
-
export interface BpkCommonLayoutProps extends BpkSpacingProps {
|
|
49
|
+
export interface BpkCommonLayoutProps extends BpkSpacingProps, AriaAttributes {
|
|
50
50
|
className?: never;
|
|
51
51
|
style?: never;
|
|
52
|
+
id?: string;
|
|
52
53
|
tabIndex?: number;
|
|
53
54
|
role?: AriaRole;
|
|
54
55
|
onClick?: MouseEventHandler<HTMLElement>;
|
|
55
56
|
onKeyDown?: KeyboardEventHandler<HTMLElement>;
|
|
56
57
|
textStyle?: BpkResponsiveValue<TextStyle>;
|
|
58
|
+
position?: BpkResponsiveValue<BpkPositionKeyword>;
|
|
59
|
+
overflow?: BpkResponsiveValue<BpkOverflowValue>;
|
|
60
|
+
overflowX?: BpkResponsiveValue<BpkOverflowValue>;
|
|
61
|
+
overflowY?: BpkResponsiveValue<BpkOverflowValue>;
|
|
62
|
+
zIndex?: BpkZIndexValue;
|
|
57
63
|
'data-testid'?: string;
|
|
58
64
|
'data-cy'?: string;
|
|
59
65
|
color?: TextColor;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exports spacing map for use in tokenUtils
|
|
3
|
+
* This allows tokenUtils to look up actual spacing values
|
|
4
|
+
*
|
|
5
|
+
* @returns {Record<string, string>} A map of spacing token names to values.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getSpacingMap(): Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the actual spacing value for a Backpack spacing token
|
|
10
|
+
*
|
|
11
|
+
* @param {string} token - Backpack spacing token name.
|
|
12
|
+
* @returns {string | undefined} The actual spacing value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getSpacingValue(token: string): string | undefined;
|
|
1
15
|
/**
|
|
2
16
|
* Gets the actual border width value for a Backpack border size token
|
|
3
17
|
*
|
|
@@ -18,33 +18,16 @@
|
|
|
18
18
|
|
|
19
19
|
import { defineConfig } from '@chakra-ui/react';
|
|
20
20
|
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
import
|
|
24
|
-
// Border sizes
|
|
25
|
-
borderSizeSm, borderSizeLg, borderSizeXl,
|
|
26
|
-
// Border radii
|
|
27
|
-
borderRadiusXs, borderRadiusSm, borderRadiusMd, borderRadiusLg, borderRadiusXl, borderRadiusFull,
|
|
28
|
-
// Box shadows
|
|
29
|
-
boxShadowSm, boxShadowLg, boxShadowXl,
|
|
30
|
-
// Font sizes
|
|
31
|
-
fontSizeXs, fontSizeSm, fontSizeBase, fontSizeLg, fontSizeXl, fontSizeXxl, fontSizeXxxl, fontSizeXxxxl, fontSizeXxxxxl, fontSize6Xl, fontSize7Xl, fontSize8Xl,
|
|
32
|
-
// Line heights
|
|
33
|
-
lineHeightXs, lineHeightSm, lineHeightBase, lineHeightBaseTight, lineHeightLg, lineHeightLgTight, lineHeightXl, lineHeightXlTight, lineHeightXxl, lineHeightXxxl, lineHeightXxxxl, lineHeightXxxxxl, lineHeight6Xl, lineHeight7Xl, lineHeight8Xl,
|
|
34
|
-
// Font weights
|
|
35
|
-
fontWeightBook, fontWeightBold, fontWeightBlack, fontWeightLight,
|
|
36
|
-
// Letter spacing
|
|
37
|
-
letterSpacingTight, letterSpacingHero,
|
|
38
|
-
// Font family
|
|
39
|
-
fontFamilyLarken } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
40
|
-
import { spacingMap } from "./spacingMap";
|
|
21
|
+
// Import tokens from Backpack foundations
|
|
22
|
+
// Note: Some tokens may not be in TypeScript definitions but exist at runtime
|
|
23
|
+
import * as bpkTokens from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
41
24
|
// NOTE:
|
|
42
25
|
// We intentionally do not use the raw breakpoint *values* from foundations here.
|
|
43
26
|
// Foundations exports breakpoint values such as `breakpointMobile = "32rem"` which
|
|
44
27
|
// are used primarily for max-width queries (e.g. `(max-width: 32rem)`).
|
|
45
28
|
//
|
|
46
29
|
// Backpack layout responsive values in this package are mobile-first and behave
|
|
47
|
-
// like Chakra breakpoints (min-width thresholds). To align with Backpack
|
|
30
|
+
// like Chakra breakpoints (min-width thresholds). To align with Backpack’s
|
|
48
31
|
// intended breakpoint ranges we define lower-bound (min-width) thresholds:
|
|
49
32
|
//
|
|
50
33
|
// - small-mobile: 320px+
|
|
@@ -53,14 +36,73 @@ import { spacingMap } from "./spacingMap";
|
|
|
53
36
|
// - tablet: 769px+
|
|
54
37
|
// - desktop: 1025px+
|
|
55
38
|
|
|
39
|
+
// Note: Spacing tokens are defined as SCSS functions in Backpack foundations,
|
|
40
|
+
// not as direct values. We need to use the actual rem values from the SCSS functions.
|
|
41
|
+
// Based on @skyscanner/bpk-foundations-web/tokens/base.default.scss:
|
|
42
|
+
// - bpk-spacing-sm() returns .25rem
|
|
43
|
+
// - bpk-spacing-md() returns .5rem
|
|
44
|
+
// - bpk-spacing-lg() returns 1.5rem
|
|
45
|
+
// - bpk-spacing-xl() returns 2rem (needs verification)
|
|
46
|
+
// - bpk-spacing-xxl() returns 2.5rem
|
|
47
|
+
// - bpk-spacing-base() returns 1rem (standard base spacing)
|
|
48
|
+
// TODO: CLOV-1021 - will add spacing tokens to Backpack Foundations package and use them here after we ship the PoC
|
|
49
|
+
const spacingXs = '.125rem'; // 2px
|
|
50
|
+
const spacingSm = '.25rem';
|
|
51
|
+
const spacingBase = '1rem'; // Standard base spacing
|
|
52
|
+
const spacingMd = '.5rem';
|
|
53
|
+
const spacingLg = '1.5rem';
|
|
54
|
+
const spacingXl = '2rem';
|
|
55
|
+
const spacingXxl = '2.5rem';
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Backpack Theme Configuration for Chakra UI
|
|
59
|
+
*
|
|
60
|
+
* This theme maps Backpack design tokens from @skyscanner/bpk-foundations-web
|
|
61
|
+
* to Chakra UI's theme structure.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Maps Backpack spacing tokens to actual rem values.
|
|
66
|
+
* These come directly from @skyscanner/bpk-foundations-web.
|
|
67
|
+
*/
|
|
68
|
+
// Spacing tokens - directly imported from foundations
|
|
69
|
+
const spacingMap = {
|
|
70
|
+
'bpk-spacing-none': {
|
|
71
|
+
value: '0'
|
|
72
|
+
},
|
|
73
|
+
// Temporary: Foundations does not yet export a 2px spacing token. This will be
|
|
74
|
+
// replaced with a foundations value once available.
|
|
75
|
+
'bpk-spacing-xs': {
|
|
76
|
+
value: spacingXs
|
|
77
|
+
},
|
|
78
|
+
'bpk-spacing-sm': {
|
|
79
|
+
value: spacingSm
|
|
80
|
+
},
|
|
81
|
+
'bpk-spacing-base': {
|
|
82
|
+
value: spacingBase
|
|
83
|
+
},
|
|
84
|
+
'bpk-spacing-md': {
|
|
85
|
+
value: spacingMd
|
|
86
|
+
},
|
|
87
|
+
'bpk-spacing-lg': {
|
|
88
|
+
value: spacingLg
|
|
89
|
+
},
|
|
90
|
+
'bpk-spacing-xl': {
|
|
91
|
+
value: spacingXl
|
|
92
|
+
},
|
|
93
|
+
'bpk-spacing-xxl': {
|
|
94
|
+
value: spacingXxl
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
56
98
|
/**
|
|
57
99
|
* Maps Backpack border size tokens to actual border width values
|
|
58
100
|
* These come directly from @skyscanner/bpk-foundations-web
|
|
59
101
|
*/
|
|
60
102
|
const borderSizeMap = {
|
|
61
|
-
'bpk-border-size-sm': borderSizeSm,
|
|
62
|
-
'bpk-border-size-lg': borderSizeLg,
|
|
63
|
-
'bpk-border-size-xl': borderSizeXl
|
|
103
|
+
'bpk-border-size-sm': bpkTokens.borderSizeSm,
|
|
104
|
+
'bpk-border-size-lg': bpkTokens.borderSizeLg,
|
|
105
|
+
'bpk-border-size-xl': bpkTokens.borderSizeXl
|
|
64
106
|
};
|
|
65
107
|
|
|
66
108
|
/**
|
|
@@ -69,12 +111,12 @@ const borderSizeMap = {
|
|
|
69
111
|
*/
|
|
70
112
|
const borderRadiusMap = {
|
|
71
113
|
'bpk-border-radius-none': '0',
|
|
72
|
-
'bpk-border-radius-xs': borderRadiusXs,
|
|
73
|
-
'bpk-border-radius-sm': borderRadiusSm,
|
|
74
|
-
'bpk-border-radius-md': borderRadiusMd,
|
|
75
|
-
'bpk-border-radius-lg': borderRadiusLg,
|
|
76
|
-
'bpk-border-radius-xl': borderRadiusXl,
|
|
77
|
-
'bpk-border-radius-full': borderRadiusFull
|
|
114
|
+
'bpk-border-radius-xs': bpkTokens.borderRadiusXs,
|
|
115
|
+
'bpk-border-radius-sm': bpkTokens.borderRadiusSm,
|
|
116
|
+
'bpk-border-radius-md': bpkTokens.borderRadiusMd,
|
|
117
|
+
'bpk-border-radius-lg': bpkTokens.borderRadiusLg,
|
|
118
|
+
'bpk-border-radius-xl': bpkTokens.borderRadiusXl,
|
|
119
|
+
'bpk-border-radius-full': bpkTokens.borderRadiusFull
|
|
78
120
|
};
|
|
79
121
|
|
|
80
122
|
/**
|
|
@@ -82,9 +124,9 @@ const borderRadiusMap = {
|
|
|
82
124
|
* These come directly from @skyscanner/bpk-foundations-web
|
|
83
125
|
*/
|
|
84
126
|
const shadowMap = {
|
|
85
|
-
'bpk-shadow-sm': boxShadowSm,
|
|
86
|
-
'bpk-shadow-lg': boxShadowLg,
|
|
87
|
-
'bpk-shadow-xl': boxShadowXl
|
|
127
|
+
'bpk-shadow-sm': bpkTokens.boxShadowSm,
|
|
128
|
+
'bpk-shadow-lg': bpkTokens.boxShadowLg,
|
|
129
|
+
'bpk-shadow-xl': bpkTokens.boxShadowXl
|
|
88
130
|
};
|
|
89
131
|
|
|
90
132
|
/**
|
|
@@ -113,6 +155,31 @@ const breakpointMap = {
|
|
|
113
155
|
'2xl': '64.0625rem' // 1025px
|
|
114
156
|
};
|
|
115
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Exports spacing map for use in tokenUtils
|
|
160
|
+
* This allows tokenUtils to look up actual spacing values
|
|
161
|
+
*
|
|
162
|
+
* @returns {Record<string, string>} A map of spacing token names to values.
|
|
163
|
+
*/
|
|
164
|
+
export function getSpacingMap() {
|
|
165
|
+
// Return simple string values for backward compatibility with utilities
|
|
166
|
+
const simpleMap = {};
|
|
167
|
+
Object.entries(spacingMap).forEach(([key, obj]) => {
|
|
168
|
+
simpleMap[key] = obj.value;
|
|
169
|
+
});
|
|
170
|
+
return simpleMap;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Gets the actual spacing value for a Backpack spacing token
|
|
175
|
+
*
|
|
176
|
+
* @param {string} token - Backpack spacing token name.
|
|
177
|
+
* @returns {string | undefined} The actual spacing value.
|
|
178
|
+
*/
|
|
179
|
+
export function getSpacingValue(token) {
|
|
180
|
+
return spacingMap[token]?.value;
|
|
181
|
+
}
|
|
182
|
+
|
|
116
183
|
/**
|
|
117
184
|
* Gets the actual border width value for a Backpack border size token
|
|
118
185
|
*
|
|
@@ -151,230 +218,230 @@ export function getShadowValue(token) {
|
|
|
151
218
|
const textStylesMap = {
|
|
152
219
|
xs: {
|
|
153
220
|
value: {
|
|
154
|
-
fontSize: fontSizeXs,
|
|
155
|
-
lineHeight: lineHeightXs,
|
|
156
|
-
fontWeight: fontWeightBook
|
|
221
|
+
fontSize: bpkTokens.fontSizeXs,
|
|
222
|
+
lineHeight: bpkTokens.lineHeightXs,
|
|
223
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
157
224
|
}
|
|
158
225
|
},
|
|
159
226
|
sm: {
|
|
160
227
|
value: {
|
|
161
|
-
fontSize: fontSizeSm,
|
|
162
|
-
lineHeight: lineHeightSm,
|
|
163
|
-
fontWeight: fontWeightBook
|
|
228
|
+
fontSize: bpkTokens.fontSizeSm,
|
|
229
|
+
lineHeight: bpkTokens.lineHeightSm,
|
|
230
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
164
231
|
}
|
|
165
232
|
},
|
|
166
233
|
base: {
|
|
167
234
|
value: {
|
|
168
|
-
fontSize: fontSizeBase,
|
|
169
|
-
lineHeight: lineHeightBase,
|
|
170
|
-
fontWeight: fontWeightBook
|
|
235
|
+
fontSize: bpkTokens.fontSizeBase,
|
|
236
|
+
lineHeight: bpkTokens.lineHeightBase,
|
|
237
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
171
238
|
}
|
|
172
239
|
},
|
|
173
240
|
lg: {
|
|
174
241
|
value: {
|
|
175
|
-
fontSize: fontSizeLg,
|
|
176
|
-
lineHeight: lineHeightLg,
|
|
177
|
-
fontWeight: fontWeightBook
|
|
242
|
+
fontSize: bpkTokens.fontSizeLg,
|
|
243
|
+
lineHeight: bpkTokens.lineHeightLg,
|
|
244
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
178
245
|
}
|
|
179
246
|
},
|
|
180
247
|
xl: {
|
|
181
248
|
value: {
|
|
182
|
-
fontSize: fontSizeXl,
|
|
183
|
-
lineHeight: lineHeightXl,
|
|
184
|
-
fontWeight: fontWeightBook
|
|
249
|
+
fontSize: bpkTokens.fontSizeXl,
|
|
250
|
+
lineHeight: bpkTokens.lineHeightXl,
|
|
251
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
185
252
|
}
|
|
186
253
|
},
|
|
187
254
|
xxl: {
|
|
188
255
|
value: {
|
|
189
|
-
fontSize: fontSizeXxl,
|
|
190
|
-
lineHeight: lineHeightXxl,
|
|
191
|
-
fontWeight: fontWeightBold
|
|
256
|
+
fontSize: bpkTokens.fontSizeXxl,
|
|
257
|
+
lineHeight: bpkTokens.lineHeightXxl,
|
|
258
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
192
259
|
}
|
|
193
260
|
},
|
|
194
261
|
xxxl: {
|
|
195
262
|
value: {
|
|
196
|
-
fontSize: fontSizeXxxl,
|
|
197
|
-
lineHeight: lineHeightXxxl,
|
|
198
|
-
fontWeight: fontWeightBold
|
|
263
|
+
fontSize: bpkTokens.fontSizeXxxl,
|
|
264
|
+
lineHeight: bpkTokens.lineHeightXxxl,
|
|
265
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
199
266
|
}
|
|
200
267
|
},
|
|
201
268
|
xxxxl: {
|
|
202
269
|
value: {
|
|
203
|
-
fontSize: fontSizeXxxxl,
|
|
204
|
-
lineHeight: lineHeightXxxxl,
|
|
205
|
-
fontWeight: fontWeightBold,
|
|
206
|
-
letterSpacing: letterSpacingTight
|
|
270
|
+
fontSize: bpkTokens.fontSizeXxxxl,
|
|
271
|
+
lineHeight: bpkTokens.lineHeightXxxxl,
|
|
272
|
+
fontWeight: bpkTokens.fontWeightBold,
|
|
273
|
+
letterSpacing: bpkTokens.letterSpacingTight
|
|
207
274
|
}
|
|
208
275
|
},
|
|
209
276
|
xxxxxl: {
|
|
210
277
|
value: {
|
|
211
|
-
fontSize: fontSizeXxxxxl,
|
|
212
|
-
lineHeight: lineHeightXxxxxl,
|
|
213
|
-
fontWeight: fontWeightBold,
|
|
214
|
-
letterSpacing: letterSpacingTight
|
|
278
|
+
fontSize: bpkTokens.fontSizeXxxxxl,
|
|
279
|
+
lineHeight: bpkTokens.lineHeightXxxxxl,
|
|
280
|
+
fontWeight: bpkTokens.fontWeightBold,
|
|
281
|
+
letterSpacing: bpkTokens.letterSpacingTight
|
|
215
282
|
}
|
|
216
283
|
},
|
|
217
284
|
caption: {
|
|
218
285
|
value: {
|
|
219
|
-
fontSize: fontSizeXs,
|
|
220
|
-
lineHeight: lineHeightXs,
|
|
221
|
-
fontWeight: fontWeightBook
|
|
286
|
+
fontSize: bpkTokens.fontSizeXs,
|
|
287
|
+
lineHeight: bpkTokens.lineHeightXs,
|
|
288
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
222
289
|
}
|
|
223
290
|
},
|
|
224
291
|
footnote: {
|
|
225
292
|
value: {
|
|
226
|
-
fontSize: fontSizeSm,
|
|
227
|
-
lineHeight: lineHeightSm,
|
|
228
|
-
fontWeight: fontWeightBook
|
|
293
|
+
fontSize: bpkTokens.fontSizeSm,
|
|
294
|
+
lineHeight: bpkTokens.lineHeightSm,
|
|
295
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
229
296
|
}
|
|
230
297
|
},
|
|
231
298
|
'label-1': {
|
|
232
299
|
value: {
|
|
233
|
-
fontSize: fontSizeBase,
|
|
234
|
-
lineHeight: lineHeightBase,
|
|
235
|
-
fontWeight: fontWeightBold
|
|
300
|
+
fontSize: bpkTokens.fontSizeBase,
|
|
301
|
+
lineHeight: bpkTokens.lineHeightBase,
|
|
302
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
236
303
|
}
|
|
237
304
|
},
|
|
238
305
|
'label-2': {
|
|
239
306
|
value: {
|
|
240
|
-
fontSize: fontSizeSm,
|
|
241
|
-
lineHeight: lineHeightSm,
|
|
242
|
-
fontWeight: fontWeightBold
|
|
307
|
+
fontSize: bpkTokens.fontSizeSm,
|
|
308
|
+
lineHeight: bpkTokens.lineHeightSm,
|
|
309
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
243
310
|
}
|
|
244
311
|
},
|
|
245
312
|
'label-3': {
|
|
246
313
|
value: {
|
|
247
|
-
fontSize: fontSizeXs,
|
|
248
|
-
lineHeight: lineHeightXs,
|
|
249
|
-
fontWeight: fontWeightBold
|
|
314
|
+
fontSize: bpkTokens.fontSizeXs,
|
|
315
|
+
lineHeight: bpkTokens.lineHeightXs,
|
|
316
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
250
317
|
}
|
|
251
318
|
},
|
|
252
319
|
'body-default': {
|
|
253
320
|
value: {
|
|
254
|
-
fontSize: fontSizeBase,
|
|
255
|
-
lineHeight: lineHeightBase,
|
|
256
|
-
fontWeight: fontWeightBook
|
|
321
|
+
fontSize: bpkTokens.fontSizeBase,
|
|
322
|
+
lineHeight: bpkTokens.lineHeightBase,
|
|
323
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
257
324
|
}
|
|
258
325
|
},
|
|
259
326
|
'body-longform': {
|
|
260
327
|
value: {
|
|
261
|
-
fontSize: fontSizeLg,
|
|
262
|
-
lineHeight: lineHeightLg,
|
|
263
|
-
fontWeight: fontWeightBook
|
|
328
|
+
fontSize: bpkTokens.fontSizeLg,
|
|
329
|
+
lineHeight: bpkTokens.lineHeightLg,
|
|
330
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
264
331
|
}
|
|
265
332
|
},
|
|
266
333
|
subheading: {
|
|
267
334
|
value: {
|
|
268
|
-
fontSize: fontSizeXl,
|
|
269
|
-
lineHeight: lineHeightXl,
|
|
270
|
-
fontWeight: fontWeightBook
|
|
335
|
+
fontSize: bpkTokens.fontSizeXl,
|
|
336
|
+
lineHeight: bpkTokens.lineHeightXl,
|
|
337
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
271
338
|
}
|
|
272
339
|
},
|
|
273
340
|
'heading-1': {
|
|
274
341
|
value: {
|
|
275
|
-
fontSize: fontSizeXxxl,
|
|
276
|
-
lineHeight: lineHeightXxxl,
|
|
277
|
-
fontWeight: fontWeightBold
|
|
342
|
+
fontSize: bpkTokens.fontSizeXxxl,
|
|
343
|
+
lineHeight: bpkTokens.lineHeightXxxl,
|
|
344
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
278
345
|
}
|
|
279
346
|
},
|
|
280
347
|
'heading-2': {
|
|
281
348
|
value: {
|
|
282
|
-
fontSize: fontSizeXxl,
|
|
283
|
-
lineHeight: lineHeightXxl,
|
|
284
|
-
fontWeight: fontWeightBold
|
|
349
|
+
fontSize: bpkTokens.fontSizeXxl,
|
|
350
|
+
lineHeight: bpkTokens.lineHeightXxl,
|
|
351
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
285
352
|
}
|
|
286
353
|
},
|
|
287
354
|
'heading-3': {
|
|
288
355
|
value: {
|
|
289
|
-
fontSize: fontSizeXl,
|
|
290
|
-
lineHeight: lineHeightXlTight,
|
|
291
|
-
fontWeight: fontWeightBold
|
|
356
|
+
fontSize: bpkTokens.fontSizeXl,
|
|
357
|
+
lineHeight: bpkTokens.lineHeightXlTight,
|
|
358
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
292
359
|
}
|
|
293
360
|
},
|
|
294
361
|
'heading-4': {
|
|
295
362
|
value: {
|
|
296
|
-
fontSize: fontSizeLg,
|
|
297
|
-
lineHeight: lineHeightLgTight,
|
|
298
|
-
fontWeight: fontWeightBold
|
|
363
|
+
fontSize: bpkTokens.fontSizeLg,
|
|
364
|
+
lineHeight: bpkTokens.lineHeightLgTight,
|
|
365
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
299
366
|
}
|
|
300
367
|
},
|
|
301
368
|
'heading-5': {
|
|
302
369
|
value: {
|
|
303
|
-
fontSize: fontSizeBase,
|
|
304
|
-
lineHeight: lineHeightBaseTight,
|
|
305
|
-
fontWeight: fontWeightBold
|
|
370
|
+
fontSize: bpkTokens.fontSizeBase,
|
|
371
|
+
lineHeight: bpkTokens.lineHeightBaseTight,
|
|
372
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
306
373
|
}
|
|
307
374
|
},
|
|
308
375
|
'hero-1': {
|
|
309
376
|
value: {
|
|
310
|
-
fontSize: fontSize8Xl,
|
|
311
|
-
lineHeight: lineHeight8Xl,
|
|
312
|
-
fontWeight: fontWeightBlack,
|
|
313
|
-
letterSpacing: letterSpacingHero
|
|
377
|
+
fontSize: bpkTokens.fontSize8Xl,
|
|
378
|
+
lineHeight: bpkTokens.lineHeight8Xl,
|
|
379
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
380
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
314
381
|
}
|
|
315
382
|
},
|
|
316
383
|
'hero-2': {
|
|
317
384
|
value: {
|
|
318
|
-
fontSize: fontSize7Xl,
|
|
319
|
-
lineHeight: lineHeight7Xl,
|
|
320
|
-
fontWeight: fontWeightBlack,
|
|
321
|
-
letterSpacing: letterSpacingHero
|
|
385
|
+
fontSize: bpkTokens.fontSize7Xl,
|
|
386
|
+
lineHeight: bpkTokens.lineHeight7Xl,
|
|
387
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
388
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
322
389
|
}
|
|
323
390
|
},
|
|
324
391
|
'hero-3': {
|
|
325
392
|
value: {
|
|
326
|
-
fontSize: fontSize6Xl,
|
|
327
|
-
lineHeight: lineHeight6Xl,
|
|
328
|
-
fontWeight: fontWeightBlack,
|
|
329
|
-
letterSpacing: letterSpacingHero
|
|
393
|
+
fontSize: bpkTokens.fontSize6Xl,
|
|
394
|
+
lineHeight: bpkTokens.lineHeight6Xl,
|
|
395
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
396
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
330
397
|
}
|
|
331
398
|
},
|
|
332
399
|
'hero-4': {
|
|
333
400
|
value: {
|
|
334
|
-
fontSize: fontSizeXxxxxl,
|
|
335
|
-
lineHeight: lineHeightXxxxxl,
|
|
336
|
-
fontWeight: fontWeightBlack,
|
|
337
|
-
letterSpacing: letterSpacingHero
|
|
401
|
+
fontSize: bpkTokens.fontSizeXxxxxl,
|
|
402
|
+
lineHeight: bpkTokens.lineHeightXxxxxl,
|
|
403
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
404
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
338
405
|
}
|
|
339
406
|
},
|
|
340
407
|
'hero-5': {
|
|
341
408
|
value: {
|
|
342
|
-
fontSize: fontSizeXxxxl,
|
|
343
|
-
lineHeight: lineHeightXxxl,
|
|
344
|
-
fontWeight: fontWeightBlack,
|
|
345
|
-
letterSpacing: letterSpacingHero
|
|
409
|
+
fontSize: bpkTokens.fontSizeXxxxl,
|
|
410
|
+
lineHeight: bpkTokens.lineHeightXxxl,
|
|
411
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
412
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
346
413
|
}
|
|
347
414
|
},
|
|
348
415
|
'hero-6': {
|
|
349
416
|
value: {
|
|
350
|
-
fontSize: fontSizeXxxl,
|
|
351
|
-
lineHeight: lineHeightXxl,
|
|
352
|
-
fontWeight: fontWeightBlack,
|
|
353
|
-
letterSpacing: letterSpacingHero
|
|
417
|
+
fontSize: bpkTokens.fontSizeXxxl,
|
|
418
|
+
lineHeight: bpkTokens.lineHeightXxl,
|
|
419
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
420
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
354
421
|
}
|
|
355
422
|
},
|
|
356
423
|
'editorial-1': {
|
|
357
424
|
value: {
|
|
358
|
-
fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
|
|
359
|
-
fontSize: fontSizeXxxxl,
|
|
360
|
-
lineHeight: lineHeightXxxxl,
|
|
361
|
-
fontWeight: fontWeightLight
|
|
425
|
+
fontFamily: `var(--bpk-larken-font-stack, ${bpkTokens.fontFamilyLarken})`,
|
|
426
|
+
fontSize: bpkTokens.fontSizeXxxxl,
|
|
427
|
+
lineHeight: bpkTokens.lineHeightXxxxl,
|
|
428
|
+
fontWeight: bpkTokens.fontWeightLight
|
|
362
429
|
}
|
|
363
430
|
},
|
|
364
431
|
'editorial-2': {
|
|
365
432
|
value: {
|
|
366
|
-
fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
|
|
367
|
-
fontSize: fontSizeXxl,
|
|
368
|
-
lineHeight: lineHeightXxl,
|
|
369
|
-
fontWeight: fontWeightLight
|
|
433
|
+
fontFamily: `var(--bpk-larken-font-stack, ${bpkTokens.fontFamilyLarken})`,
|
|
434
|
+
fontSize: bpkTokens.fontSizeXxl,
|
|
435
|
+
lineHeight: bpkTokens.lineHeightXxl,
|
|
436
|
+
fontWeight: bpkTokens.fontWeightLight
|
|
370
437
|
}
|
|
371
438
|
},
|
|
372
439
|
'editorial-3': {
|
|
373
440
|
value: {
|
|
374
|
-
fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
|
|
375
|
-
fontSize: fontSizeLg,
|
|
376
|
-
lineHeight: lineHeightLg,
|
|
377
|
-
fontWeight: fontWeightBook
|
|
441
|
+
fontFamily: `var(--bpk-larken-font-stack, ${bpkTokens.fontFamilyLarken})`,
|
|
442
|
+
fontSize: bpkTokens.fontSizeLg,
|
|
443
|
+
lineHeight: bpkTokens.lineHeightLg,
|
|
444
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
378
445
|
}
|
|
379
446
|
}
|
|
380
447
|
};
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import StackOptionKeys from "./BpkStack.constant";
|
|
20
|
-
import { getSpacingValue } from "./
|
|
20
|
+
import { getSpacingValue } from "./theme";
|
|
21
21
|
import { BpkBreakpointToChakraKey, isValidSpacingValue, isValidSizeValue, isValidPositionValue, isPercentage } from "./tokens";
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -41,7 +41,9 @@ export const BPK_RESPONSIVE_PROP_GROUPS_BY_COMPONENT = {
|
|
|
41
41
|
// Flex container props
|
|
42
42
|
'flexDirection', 'flexWrap', 'justifyContent', 'alignItems', 'alignContent',
|
|
43
43
|
// Grid container props
|
|
44
|
-
'gridTemplateColumns', 'gridTemplateRows', 'gridTemplateAreas', 'gridAutoFlow', 'gridAutoRows', 'gridAutoColumns'
|
|
44
|
+
'gridTemplateColumns', 'gridTemplateRows', 'gridTemplateAreas', 'gridAutoFlow', 'gridAutoRows', 'gridAutoColumns',
|
|
45
|
+
// Position keyword and overflow (from BpkCommonLayoutProps)
|
|
46
|
+
'position', 'overflow', 'overflowX', 'overflowY'],
|
|
45
47
|
item: [
|
|
46
48
|
// Flex item props
|
|
47
49
|
'flex', 'flexGrow', 'flexShrink', 'flexBasis', 'order', 'alignSelf', 'justifySelf',
|
|
@@ -50,22 +52,28 @@ export const BPK_RESPONSIVE_PROP_GROUPS_BY_COMPONENT = {
|
|
|
50
52
|
},
|
|
51
53
|
// Note: BpkFlex maps its public API props to these Chakra keys.
|
|
52
54
|
BpkFlex: {
|
|
53
|
-
container: ['textStyle', 'flexDirection', 'justifyContent', 'alignItems', 'flexWrap'
|
|
55
|
+
container: ['textStyle', 'flexDirection', 'justifyContent', 'alignItems', 'flexWrap',
|
|
56
|
+
// Position keyword and overflow (from BpkCommonLayoutProps)
|
|
57
|
+
'position', 'overflow', 'overflowX', 'overflowY'],
|
|
54
58
|
item: ['flexGrow', 'flexShrink', 'flexBasis']
|
|
55
59
|
},
|
|
56
60
|
// Note: BpkGrid maps its public API props to these Chakra keys.
|
|
57
61
|
BpkGrid: {
|
|
58
|
-
container: ['textStyle', 'justifyContent', 'alignItems', 'gridTemplateColumns', 'gridTemplateRows', 'gridTemplateAreas', 'gridAutoFlow', 'gridAutoRows', 'gridAutoColumns'
|
|
62
|
+
container: ['textStyle', 'justifyContent', 'alignItems', 'gridTemplateColumns', 'gridTemplateRows', 'gridTemplateAreas', 'gridAutoFlow', 'gridAutoRows', 'gridAutoColumns',
|
|
63
|
+
// Position keyword and overflow (from BpkCommonLayoutProps)
|
|
64
|
+
'position', 'overflow', 'overflowX', 'overflowY'],
|
|
59
65
|
item: [
|
|
60
66
|
// Used when placing the grid itself within a parent grid.
|
|
61
67
|
'gridColumn', 'gridRow']
|
|
62
68
|
},
|
|
63
69
|
BpkGridItem: {
|
|
64
|
-
container: ['textStyle']
|
|
70
|
+
container: ['textStyle', 'position', 'overflow', 'overflowX', 'overflowY']
|
|
65
71
|
},
|
|
66
72
|
// Note: BpkStack uses Chakra Stack option prop names directly.
|
|
67
73
|
BpkStack: {
|
|
68
|
-
container: ['textStyle', ...StackOptionKeys
|
|
74
|
+
container: ['textStyle', ...StackOptionKeys,
|
|
75
|
+
// Position keyword and overflow (from BpkCommonLayoutProps)
|
|
76
|
+
'position', 'overflow', 'overflowX', 'overflowY']
|
|
69
77
|
}
|
|
70
78
|
};
|
|
71
79
|
export const BPK_RESPONSIVE_PROP_KEYS_BY_COMPONENT = {
|
|
@@ -101,7 +109,15 @@ function filterToAllowlist(props, allowlist) {
|
|
|
101
109
|
export function processBpkComponentProps(props, options) {
|
|
102
110
|
const processed = processBpkProps(props);
|
|
103
111
|
const allowlist = BPK_RESPONSIVE_PROP_KEYS_BY_COMPONENT[options.component];
|
|
104
|
-
|
|
112
|
+
// When responsiveProps is provided (e.g. BpkFlex maps direction→flexDirection),
|
|
113
|
+
// merge it with any allowlisted props already in `processed` (e.g. position/overflow
|
|
114
|
+
// that come in via ...props and are NOT included in responsiveProps).
|
|
115
|
+
// responsiveProps takes precedence so that explicit prop-name mappings always win.
|
|
116
|
+
const processedAllowlisted = filterToAllowlist(processed, allowlist);
|
|
117
|
+
const responsiveSource = options.responsiveProps ? {
|
|
118
|
+
...processedAllowlisted,
|
|
119
|
+
...filterToAllowlist(options.responsiveProps, allowlist)
|
|
120
|
+
} : processedAllowlisted;
|
|
105
121
|
if (Object.keys(responsiveSource).length === 0) {
|
|
106
122
|
return processed;
|
|
107
123
|
}
|
|
@@ -47,10 +47,24 @@ export type BpkBreakpointValue = BpkBreakpointToken;
|
|
|
47
47
|
*/
|
|
48
48
|
export type BpkSizeValue = `${number}rem` | `${number}%` | 'auto' | 'full' | 'fit-content';
|
|
49
49
|
/**
|
|
50
|
-
* Helper type for position props that can use rem or
|
|
51
|
-
*
|
|
50
|
+
* Helper type for position props that can use rem, percentages, or bare zero.
|
|
51
|
+
* CSS allows `0` without a unit; `'0'` is therefore an explicit allowed value.
|
|
52
|
+
* We intentionally do not allow other semantic values like 'auto' here.
|
|
52
53
|
*/
|
|
53
|
-
export type BpkPositionValue = `${number}rem` | `${number}
|
|
54
|
+
export type BpkPositionValue = `${number}rem` | `${number}%` | '0';
|
|
55
|
+
/**
|
|
56
|
+
* CSS `position` property keyword values.
|
|
57
|
+
*/
|
|
58
|
+
export type BpkPositionKeyword = 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky';
|
|
59
|
+
/**
|
|
60
|
+
* CSS `overflow` property keyword values.
|
|
61
|
+
*/
|
|
62
|
+
export type BpkOverflowValue = 'visible' | 'hidden' | 'scroll' | 'auto' | 'clip';
|
|
63
|
+
/**
|
|
64
|
+
* CSS `z-index` values. Numeric values only; 'auto' is also permitted.
|
|
65
|
+
* Avoid magic numbers — prefer a shared z-index scale in your app.
|
|
66
|
+
*/
|
|
67
|
+
export type BpkZIndexValue = number | 'auto';
|
|
54
68
|
/**
|
|
55
69
|
* Helper type for flex-basis prop that can use rem, percentages or semantic values.
|
|
56
70
|
* Excludes 'px' values to enforce design system constraints.
|
|
@@ -71,8 +71,22 @@ export const BpkBreakpointToChakraKey = {
|
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Helper type for position props that can use rem or
|
|
75
|
-
*
|
|
74
|
+
* Helper type for position props that can use rem, percentages, or bare zero.
|
|
75
|
+
* CSS allows `0` without a unit; `'0'` is therefore an explicit allowed value.
|
|
76
|
+
* We intentionally do not allow other semantic values like 'auto' here.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* CSS `position` property keyword values.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* CSS `overflow` property keyword values.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* CSS `z-index` values. Numeric values only; 'auto' is also permitted.
|
|
89
|
+
* Avoid magic numbers — prefer a shared z-index scale in your app.
|
|
76
90
|
*/
|
|
77
91
|
|
|
78
92
|
/**
|
|
@@ -131,7 +145,9 @@ export function isValidSizeValue(value) {
|
|
|
131
145
|
* @returns {boolean} True if the value is a valid rem or percentage
|
|
132
146
|
*/
|
|
133
147
|
export function isValidPositionValue(value) {
|
|
134
|
-
return
|
|
148
|
+
return value === '0' ||
|
|
149
|
+
// bare zero — valid CSS without a unit
|
|
150
|
+
/^-?\d+(\.\d+)?rem$/.test(value) ||
|
|
135
151
|
// rem values
|
|
136
152
|
isPercentage(value) // percentage values
|
|
137
153
|
;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
type Props = {
|
|
4
|
+
children: Array<ReactElement<any, any>> | ReactElement<any, any>;
|
|
5
|
+
};
|
|
6
|
+
declare const SpinnerLayout: {
|
|
7
|
+
(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
propTypes: {
|
|
9
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default SpinnerLayout;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
20
|
+
import { Children } from 'react';
|
|
21
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
22
|
+
import SPINNER_TYPES from "./spinnerTypes";
|
|
23
|
+
import STYLES from "./SpinnerLayout.story-helpers.module.css";
|
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
+
const getClassName = cssModules(STYLES);
|
|
26
|
+
const SpinnerLayout = props => {
|
|
27
|
+
const {
|
|
28
|
+
children
|
|
29
|
+
} = props;
|
|
30
|
+
return /*#__PURE__*/_jsx("div", {
|
|
31
|
+
className: getClassName('bpk-spinner-layout'),
|
|
32
|
+
children: Children.map(children, child => {
|
|
33
|
+
const classNames = [getClassName('bpk-spinner-layout__spinner')];
|
|
34
|
+
if (child.props.type === SPINNER_TYPES.light) {
|
|
35
|
+
classNames.push(getClassName('bpk-spinner-layout__spinner--light'));
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/_jsx("div", {
|
|
38
|
+
className: classNames.join(' '),
|
|
39
|
+
children: child
|
|
40
|
+
});
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
SpinnerLayout.propTypes = {
|
|
45
|
+
children: PropTypes.node.isRequired
|
|
46
|
+
};
|
|
47
|
+
export default SpinnerLayout;
|
|
@@ -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-spinner-layout{display:flex;flex-direction:column}.bpk-spinner-layout__spinner{display:flex;padding:1.5rem;justify-content:center}.bpk-spinner-layout__spinner--light{background-color:#05203c;border-radius:.25rem}
|
|
@@ -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-text{margin:0}.bpk-text--xs{font-size:.75rem;line-height:1rem;font-weight:400}.bpk-text--sm{font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-text--base{font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-text--lg{font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text--xl{font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-text--xxl{font-size:2rem;line-height:2.5rem;font-weight:700}.bpk-text--xxxl{font-size:2.5rem;line-height:3rem;font-weight:700}.bpk-text--xxxxl{font-size:3rem;line-height:3.5rem;font-weight:700;letter-spacing:-0.02em}.bpk-text--xxxxxl{font-size:4rem;line-height:4rem;font-weight:700;letter-spacing:-0.02em}.bpk-text--caption{font-size:.75rem;line-height:1rem;font-weight:400}.bpk-text--footnote{font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-text--label-1{font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-text--label-2{font-size:.875rem;line-height:1.25rem;font-weight:700}.bpk-text--label-3{font-size:.75rem;line-height:1rem;font-weight:700}.bpk-text--body-default{font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-text--body-longform{font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text--subheading{font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-text--heading-1{font-size:2.5rem;line-height:3rem;font-weight:700}.bpk-text--heading-2{font-size:2rem;line-height:2.5rem;font-weight:700}.bpk-text--heading-3{font-size:1.5rem;line-height:1.75rem;font-weight:700}.bpk-text--heading-4{font-size:1.25rem;line-height:1.5rem;font-weight:700}.bpk-text--heading-5{font-size:1rem;line-height:1.25rem;font-weight:700}.bpk-text--hero-1{font-size:7.5rem;line-height:7.5rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-2{font-size:6rem;line-height:6rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-3{font-size:4.75rem;line-height:4.75rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-4{font-size:4rem;line-height:4rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-5{font-size:3rem;line-height:3rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-6{font-size:2.5rem;line-height:2.5rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--editorial-1{font-family:var(--bpk-larken-font-stack, "Larken", "Noto Sans Arabic", "Noto Serif Hebrew", "Noto Serif", "Noto Serif Devanagari", "Noto Serif Thai", "Noto Serif
|
|
18
|
+
.bpk-text{margin:0}.bpk-text--xs{font-size:.75rem;line-height:1rem;font-weight:400}.bpk-text--sm{font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-text--base{font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-text--lg{font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text--xl{font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-text--xxl{font-size:2rem;line-height:2.5rem;font-weight:700}.bpk-text--xxxl{font-size:2.5rem;line-height:3rem;font-weight:700}.bpk-text--xxxxl{font-size:3rem;line-height:3.5rem;font-weight:700;letter-spacing:-0.02em}.bpk-text--xxxxxl{font-size:4rem;line-height:4rem;font-weight:700;letter-spacing:-0.02em}.bpk-text--caption{font-size:.75rem;line-height:1rem;font-weight:400}.bpk-text--footnote{font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-text--label-1{font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-text--label-2{font-size:.875rem;line-height:1.25rem;font-weight:700}.bpk-text--label-3{font-size:.75rem;line-height:1rem;font-weight:700}.bpk-text--body-default{font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-text--body-longform{font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text--subheading{font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-text--heading-1{font-size:2.5rem;line-height:3rem;font-weight:700}.bpk-text--heading-2{font-size:2rem;line-height:2.5rem;font-weight:700}.bpk-text--heading-3{font-size:1.5rem;line-height:1.75rem;font-weight:700}.bpk-text--heading-4{font-size:1.25rem;line-height:1.5rem;font-weight:700}.bpk-text--heading-5{font-size:1rem;line-height:1.25rem;font-weight:700}.bpk-text--hero-1{font-size:7.5rem;line-height:7.5rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-2{font-size:6rem;line-height:6rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-3{font-size:4.75rem;line-height:4.75rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-4{font-size:4rem;line-height:4rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-5{font-size:3rem;line-height:3rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--hero-6{font-size:2.5rem;line-height:2.5rem;font-weight:900;letter-spacing:-0.04em}.bpk-text--editorial-1{font-family:var(--bpk-larken-font-stack, "Larken", "Noto Sans Arabic", "Noto Serif Hebrew", "Noto Serif", "Noto Serif Devanagari", "Noto Serif Thai", "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Noto Serif SC", sans-serif);font-size:3rem;line-height:3.5rem;font-weight:300}.bpk-text--editorial-2{font-family:var(--bpk-larken-font-stack, "Larken", "Noto Sans Arabic", "Noto Serif Hebrew", "Noto Serif", "Noto Serif Devanagari", "Noto Serif Thai", "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Noto Serif SC", sans-serif);font-size:2rem;line-height:2.5rem;font-weight:300}.bpk-text--editorial-3{font-family:var(--bpk-larken-font-stack, "Larken", "Noto Sans Arabic", "Noto Serif Hebrew", "Noto Serif", "Noto Serif Devanagari", "Noto Serif Thai", "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Noto Serif SC", sans-serif);font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text.bpk-text--text-disabled{color:rgba(0,0,0,.2)}.bpk-text.bpk-text--text-disabled-on-dark{color:hsla(0,0%,100%,.5)}.bpk-text.bpk-text--text-error{color:#e70866}.bpk-text.bpk-text--text-hero{color:#0062e3}.bpk-text.bpk-text--text-link{color:#0062e3}.bpk-text.bpk-text--text-on-dark{color:#fff}.bpk-text.bpk-text--text-on-light{color:#161616}.bpk-text.bpk-text--text-primary{color:#161616}.bpk-text.bpk-text--text-primary-inverse{color:#fff}.bpk-text.bpk-text--text-secondary{color:#626971}.bpk-text.bpk-text--text-success{color:#0c838a}
|
package/bpk-stylesheets/base.css
CHANGED
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*
|
|
19
|
-
*//*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}template,[hidden]{display:none}a{background-color:rgba(0,0,0,0);-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,optgroup,select,textarea{font:inherit;margin:0}optgroup{font-weight:bold}button,input{overflow:visible}button,select{text-transform:none}button,html [type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}html{font-size:100%;box-sizing:border-box}*{box-sizing:inherit}*::before,*::after{box-sizing:inherit}body{color:#161616;font-family:var(--bpk-base-font-stack, "Skyscanner Relative", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans", "Noto Sans Devanagari", "Noto Sans Thai", "Noto Sans
|
|
19
|
+
*//*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}template,[hidden]{display:none}a{background-color:rgba(0,0,0,0);-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,optgroup,select,textarea{font:inherit;margin:0}optgroup{font-weight:bold}button,input{overflow:visible}button,select{text-transform:none}button,html [type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}html{font-size:100%;box-sizing:border-box}*{box-sizing:inherit}*::before,*::after{box-sizing:inherit}body{color:#161616;font-family:var(--bpk-base-font-stack, "Skyscanner Relative", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans", "Noto Sans Devanagari", "Noto Sans Thai", "Noto Sans TC", "Noto Sans JP", "Noto Sans KR", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif);font-size:1rem;line-height:1.3rem}body.scaffold-font-size{font-size:13px}body.enable-font-smoothing{-webkit-font-smoothing:antialiased}:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.hidden,.hide{display:none !important}.visuallyhidden,.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus,.visually-hidden.focusable:active,.visually-hidden.focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.invisible{visibility:hidden}.clearfix::before,.clearfix::after{content:"";display:table}.clearfix::after{clear:both}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "42.
|
|
3
|
+
"version": "42.7.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
|
30
30
|
"@radix-ui/react-slider": "1.3.5",
|
|
31
31
|
"@react-google-maps/api": "^2.19.3",
|
|
32
|
-
"@skyscanner/bpk-foundations-web": "^24.
|
|
32
|
+
"@skyscanner/bpk-foundations-web": "^24.4.0",
|
|
33
33
|
"@skyscanner/bpk-svgs": "^20.11.0",
|
|
34
34
|
"a11y-focus-scope": "^1.1.3",
|
|
35
35
|
"a11y-focus-store": "^1.0.0",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Maps Backpack spacing tokens to actual rem values.
|
|
3
|
-
* These come directly from @skyscanner/bpk-foundations-web.
|
|
4
|
-
*/
|
|
5
|
-
export declare const spacingMap: Record<string, {
|
|
6
|
-
value: string;
|
|
7
|
-
}>;
|
|
8
|
-
/**
|
|
9
|
-
* Exports spacing map for use in tokenUtils
|
|
10
|
-
* This allows tokenUtils to look up actual spacing values
|
|
11
|
-
*
|
|
12
|
-
* @returns {Record<string, string>} A map of spacing token names to values.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getSpacingMap(): Record<string, string>;
|
|
15
|
-
/**
|
|
16
|
-
* Gets the actual spacing value for a Backpack spacing token
|
|
17
|
-
*
|
|
18
|
-
* @param {string} token - Backpack spacing token name.
|
|
19
|
-
* @returns {string | undefined} The actual spacing value.
|
|
20
|
-
*/
|
|
21
|
-
export declare function getSpacingValue(token: string): string | undefined;
|
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
// Note: Spacing tokens are defined as SCSS functions in Backpack foundations,
|
|
20
|
-
// not as direct values. We need to use the actual rem values from the SCSS functions.
|
|
21
|
-
// Based on @skyscanner/bpk-foundations-web/tokens/base.default.scss:
|
|
22
|
-
// - bpk-spacing-sm() returns .25rem
|
|
23
|
-
// - bpk-spacing-md() returns .5rem
|
|
24
|
-
// - bpk-spacing-lg() returns 1.5rem
|
|
25
|
-
// - bpk-spacing-xl() returns 2rem (needs verification)
|
|
26
|
-
// - bpk-spacing-xxl() returns 2.5rem
|
|
27
|
-
// - bpk-spacing-base() returns 1rem (standard base spacing)
|
|
28
|
-
// TODO: CLOV-1021 - will add spacing tokens to Backpack Foundations package and use them here after we ship the PoC
|
|
29
|
-
const spacingXs = '.125rem'; // 2px
|
|
30
|
-
const spacingSm = '.25rem';
|
|
31
|
-
const spacingBase = '1rem'; // Standard base spacing
|
|
32
|
-
const spacingMd = '.5rem';
|
|
33
|
-
const spacingLg = '1.5rem';
|
|
34
|
-
const spacingXl = '2rem';
|
|
35
|
-
const spacingXxl = '2.5rem';
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Maps Backpack spacing tokens to actual rem values.
|
|
39
|
-
* These come directly from @skyscanner/bpk-foundations-web.
|
|
40
|
-
*/
|
|
41
|
-
export const spacingMap = {
|
|
42
|
-
'bpk-spacing-none': {
|
|
43
|
-
value: '0'
|
|
44
|
-
},
|
|
45
|
-
// Temporary: Foundations does not yet export a 2px spacing token. This will be
|
|
46
|
-
// replaced with a foundations value once available.
|
|
47
|
-
'bpk-spacing-xs': {
|
|
48
|
-
value: spacingXs
|
|
49
|
-
},
|
|
50
|
-
'bpk-spacing-sm': {
|
|
51
|
-
value: spacingSm
|
|
52
|
-
},
|
|
53
|
-
'bpk-spacing-base': {
|
|
54
|
-
value: spacingBase
|
|
55
|
-
},
|
|
56
|
-
'bpk-spacing-md': {
|
|
57
|
-
value: spacingMd
|
|
58
|
-
},
|
|
59
|
-
'bpk-spacing-lg': {
|
|
60
|
-
value: spacingLg
|
|
61
|
-
},
|
|
62
|
-
'bpk-spacing-xl': {
|
|
63
|
-
value: spacingXl
|
|
64
|
-
},
|
|
65
|
-
'bpk-spacing-xxl': {
|
|
66
|
-
value: spacingXxl
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Exports spacing map for use in tokenUtils
|
|
72
|
-
* This allows tokenUtils to look up actual spacing values
|
|
73
|
-
*
|
|
74
|
-
* @returns {Record<string, string>} A map of spacing token names to values.
|
|
75
|
-
*/
|
|
76
|
-
export function getSpacingMap() {
|
|
77
|
-
const simpleMap = {};
|
|
78
|
-
Object.entries(spacingMap).forEach(([key, obj]) => {
|
|
79
|
-
simpleMap[key] = obj.value;
|
|
80
|
-
});
|
|
81
|
-
return simpleMap;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Gets the actual spacing value for a Backpack spacing token
|
|
86
|
-
*
|
|
87
|
-
* @param {string} token - Backpack spacing token name.
|
|
88
|
-
* @returns {string | undefined} The actual spacing value.
|
|
89
|
-
*/
|
|
90
|
-
export function getSpacingValue(token) {
|
|
91
|
-
return spacingMap[token]?.value;
|
|
92
|
-
}
|