@atlaskit/primitives 0.2.1 → 0.3.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/CHANGELOG.md +12 -0
- package/dist/cjs/components/inline.partial.js +46 -22
- package/dist/cjs/components/internal/base-box.partial.js +99 -78
- package/dist/cjs/components/internal/types.js +8 -0
- package/dist/cjs/components/internal/utils.js +16 -0
- package/dist/cjs/components/stack.partial.js +46 -22
- package/dist/cjs/constants.js +13 -0
- package/dist/cjs/helpers/responsive/build-media-query-css.js +88 -0
- package/dist/cjs/helpers/responsive/constants.js +85 -0
- package/dist/cjs/helpers/responsive/index.js +38 -0
- package/dist/cjs/helpers/responsive/media-helper.js +84 -0
- package/dist/cjs/helpers/responsive/types.js +5 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/inline.partial.js +18 -18
- package/dist/es2019/components/internal/base-box.partial.js +75 -70
- package/dist/es2019/components/internal/types.js +1 -0
- package/dist/es2019/components/internal/utils.js +2 -0
- package/dist/es2019/components/stack.partial.js +18 -18
- package/dist/es2019/constants.js +3 -1
- package/dist/es2019/helpers/responsive/build-media-query-css.js +85 -0
- package/dist/es2019/helpers/responsive/constants.js +74 -0
- package/dist/es2019/helpers/responsive/index.js +3 -0
- package/dist/es2019/helpers/responsive/media-helper.js +78 -0
- package/dist/es2019/helpers/responsive/types.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/inline.partial.js +46 -21
- package/dist/esm/components/internal/base-box.partial.js +100 -79
- package/dist/esm/components/internal/types.js +1 -0
- package/dist/esm/components/internal/utils.js +7 -0
- package/dist/esm/components/stack.partial.js +46 -21
- package/dist/esm/constants.js +3 -1
- package/dist/esm/helpers/responsive/build-media-query-css.js +79 -0
- package/dist/esm/helpers/responsive/constants.js +76 -0
- package/dist/esm/helpers/responsive/index.js +3 -0
- package/dist/esm/helpers/responsive/media-helper.js +78 -0
- package/dist/esm/helpers/responsive/types.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/components/box.d.ts +3 -5
- package/dist/types/components/inline.partial.d.ts +16 -18
- package/dist/types/components/internal/base-box.partial.d.ts +49 -50
- package/dist/types/components/internal/types.d.ts +6 -0
- package/dist/types/components/internal/utils.d.ts +3 -0
- package/dist/types/components/stack.partial.d.ts +16 -18
- package/dist/types/components/types.d.ts +49 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/helpers/responsive/build-media-query-css.d.ts +57 -0
- package/dist/types/helpers/responsive/constants.d.ts +23 -0
- package/dist/types/helpers/responsive/index.d.ts +4 -0
- package/dist/types/helpers/responsive/media-helper.d.ts +45 -0
- package/dist/types/helpers/responsive/types.d.ts +47 -0
- package/package.json +6 -3
- package/report.api.md +111 -78
- package/responsive/package.json +15 -0
- package/scripts/spacing-codegen-template.tsx +29 -24
- package/scripts/utils.tsx +4 -1
- package/tmp/api-report-tmp.d.ts +88 -77
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UNSAFE_BREAKPOINTS_ORDERED_LIST = exports.UNSAFE_BREAKPOINTS_CONFIG = exports.SMALLEST_BREAKPOINT = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Our internal configuration for breakpoints configuration.
|
|
9
|
+
*
|
|
10
|
+
* @experimental Unsafe for consumption outside of the design system itself.
|
|
11
|
+
*/
|
|
12
|
+
var UNSAFE_BREAKPOINTS_CONFIG = {
|
|
13
|
+
// mobile
|
|
14
|
+
xxs: {
|
|
15
|
+
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
16
|
+
gridMargin: "var(--ds-space-200, 16px)",
|
|
17
|
+
min: 0,
|
|
18
|
+
max: 479
|
|
19
|
+
},
|
|
20
|
+
// phablet
|
|
21
|
+
xs: {
|
|
22
|
+
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
23
|
+
gridMargin: "var(--ds-space-200, 16px)",
|
|
24
|
+
min: 480,
|
|
25
|
+
max: 767
|
|
26
|
+
},
|
|
27
|
+
// tablet
|
|
28
|
+
sm: {
|
|
29
|
+
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
30
|
+
gridMargin: "var(--ds-space-300, 24px)",
|
|
31
|
+
min: 768,
|
|
32
|
+
max: 1023
|
|
33
|
+
},
|
|
34
|
+
// laptop desktop
|
|
35
|
+
md: {
|
|
36
|
+
gridItemGutter: "var(--ds-space-300, 24px)",
|
|
37
|
+
gridMargin: "var(--ds-space-400, 32px)",
|
|
38
|
+
min: 1024,
|
|
39
|
+
max: 1439
|
|
40
|
+
},
|
|
41
|
+
// monitor
|
|
42
|
+
lg: {
|
|
43
|
+
gridItemGutter: "var(--ds-space-400, 32px)",
|
|
44
|
+
gridMargin: "var(--ds-space-400, 32px)",
|
|
45
|
+
min: 1440,
|
|
46
|
+
max: 1767
|
|
47
|
+
},
|
|
48
|
+
// large high res
|
|
49
|
+
xl: {
|
|
50
|
+
gridItemGutter: "var(--ds-space-400, 32px)",
|
|
51
|
+
gridMargin: "var(--ds-space-500, 40px)",
|
|
52
|
+
min: 1768,
|
|
53
|
+
max: 2159
|
|
54
|
+
},
|
|
55
|
+
// extra large high res
|
|
56
|
+
xxl: {
|
|
57
|
+
gridItemGutter: "var(--ds-space-500, 40px)",
|
|
58
|
+
gridMargin: "var(--ds-space-500, 40px)",
|
|
59
|
+
min: 2160,
|
|
60
|
+
max: Number.MAX_SAFE_INTEGER
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The list of breakpoints in order from smallest to largest. You may need to clone and reverse this list if you want the opposite.
|
|
66
|
+
*
|
|
67
|
+
* This is intentional for cascading with `min-width` or `media.above`. Media queries go from lowest width to highest.
|
|
68
|
+
*
|
|
69
|
+
* @experimental Unsafe for consumption outside of the design system itself.
|
|
70
|
+
*/
|
|
71
|
+
exports.UNSAFE_BREAKPOINTS_CONFIG = UNSAFE_BREAKPOINTS_CONFIG;
|
|
72
|
+
var UNSAFE_BREAKPOINTS_ORDERED_LIST = Object.keys(UNSAFE_BREAKPOINTS_CONFIG).sort(function (a, b) {
|
|
73
|
+
return UNSAFE_BREAKPOINTS_CONFIG[a].min - UNSAFE_BREAKPOINTS_CONFIG[b].min;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* This is our smallest breakpoint with a few nuances to it:
|
|
78
|
+
* 1. It is the default value for shorthands, eg. `<GridItem span={6} />` maps to `{ [SMALLEST_BREAKPOINT]: props.span }`
|
|
79
|
+
* 2. It's omitted in `media.below` as there's nothing below `0px`.
|
|
80
|
+
*
|
|
81
|
+
* @experimental There's a chance this will change in _value_, but should only be used in a way that it will not matter if this value changes.
|
|
82
|
+
*/
|
|
83
|
+
exports.UNSAFE_BREAKPOINTS_ORDERED_LIST = UNSAFE_BREAKPOINTS_ORDERED_LIST;
|
|
84
|
+
var SMALLEST_BREAKPOINT = UNSAFE_BREAKPOINTS_ORDERED_LIST[0];
|
|
85
|
+
exports.SMALLEST_BREAKPOINT = SMALLEST_BREAKPOINT;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "UNSAFE_BREAKPOINTS_CONFIG", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _constants.UNSAFE_BREAKPOINTS_CONFIG;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "UNSAFE_BREAKPOINTS_ORDERED_LIST", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _constants.UNSAFE_BREAKPOINTS_ORDERED_LIST;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "UNSAFE_buildAboveMediaQueryCSS", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _buildMediaQueryCss.UNSAFE_buildAboveMediaQueryCSS;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "UNSAFE_buildBelowMediaQueryCSS", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _buildMediaQueryCss.UNSAFE_buildBelowMediaQueryCSS;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "UNSAFE_media", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _mediaHelper.UNSAFE_media;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _mediaHelper = require("./media-helper");
|
|
37
|
+
var _buildMediaQueryCss = require("./build-media-query-css");
|
|
38
|
+
var _constants = require("./constants");
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UNSAFE_media = void 0;
|
|
7
|
+
var _constants = require("./constants");
|
|
8
|
+
/**
|
|
9
|
+
* To ensure min-width and max-width do both target at the same time, we subtract a value.
|
|
10
|
+
* We use a fractional value here as used in other libraries and described in @link https://www.w3.org/TR/mediaqueries-4/#mq-min-max: "…possibility of fractional viewport sizes which can occur as a result of non-integer pixel densities…"
|
|
11
|
+
*/
|
|
12
|
+
var BELOW_PRECISION = 0.02;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This is the full internal version. The import has been separated to only expose as-needed.
|
|
16
|
+
*/
|
|
17
|
+
var internalMedia = {
|
|
18
|
+
/**
|
|
19
|
+
* A media query to target viewports above the min width of a given breakpoint.
|
|
20
|
+
* Note that `media.above.xs` is redundant and should not be used, but it's included for programatic purposes.
|
|
21
|
+
*/
|
|
22
|
+
above: {
|
|
23
|
+
/**
|
|
24
|
+
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
25
|
+
*
|
|
26
|
+
* Eg. this is `@media (min-width: 0px)`
|
|
27
|
+
*/
|
|
28
|
+
xxs: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxs.min, "px)"),
|
|
29
|
+
xs: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xs.min, "px)"),
|
|
30
|
+
sm: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.min, "px)"),
|
|
31
|
+
md: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.min, "px)"),
|
|
32
|
+
lg: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.min, "px)"),
|
|
33
|
+
xl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min, "px)"),
|
|
34
|
+
xxl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxl.min, "px)")
|
|
35
|
+
},
|
|
36
|
+
below: {
|
|
37
|
+
/**
|
|
38
|
+
* A media query to target viewports below the min width of a given breakpoint.
|
|
39
|
+
* Note that `media.below.xxs` is intentionally omitted as this would be `@media (max-width: 0px)`
|
|
40
|
+
*/
|
|
41
|
+
xs: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xs.min - BELOW_PRECISION, "px)"),
|
|
42
|
+
sm: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.min - BELOW_PRECISION, "px)"),
|
|
43
|
+
md: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.min - BELOW_PRECISION, "px)"),
|
|
44
|
+
lg: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.min - BELOW_PRECISION, "px)"),
|
|
45
|
+
xl: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min - BELOW_PRECISION, "px)"),
|
|
46
|
+
xxl: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxl.min - BELOW_PRECISION, "px)")
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* A media query to target viewports exactly between the min and max of a given breakpoint.
|
|
50
|
+
*/
|
|
51
|
+
only: {
|
|
52
|
+
xxs: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxs.min, "px) and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxs.max, "px)"),
|
|
53
|
+
xs: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xs.min, "px) and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xs.max, "px)"),
|
|
54
|
+
sm: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.min, "px) and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.max, "px)"),
|
|
55
|
+
md: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.min, "px) and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.max, "px)"),
|
|
56
|
+
lg: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.min, "px) and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.max, "px)"),
|
|
57
|
+
xl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min, "px) and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.max, "px)"),
|
|
58
|
+
xxl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxl.min, "px) and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxl.max, "px)")
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
64
|
+
*
|
|
65
|
+
* @experimental Unsafe for usage as the API is not finalized.
|
|
66
|
+
*/
|
|
67
|
+
var UNSAFE_media = {
|
|
68
|
+
above: internalMedia.above,
|
|
69
|
+
below: internalMedia.below
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* With these types:
|
|
74
|
+
* ```
|
|
75
|
+
* type MediaQuery = `@media (${string})`;
|
|
76
|
+
* type ResponsiveMediaObject = Record<Breakpoint, MediaQuery>;
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* TODO: This `media` object as of typescript@4.9, would benefit from satisfies, eg.:
|
|
80
|
+
* ```
|
|
81
|
+
* const UNSAFE_media = { … } satisfies Record<'above' | 'only', ResponsiveMediaObject> & { below: Omit<ResponsiveMediaObject, 'xxs'> }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
exports.UNSAFE_media = UNSAFE_media;
|
package/dist/cjs/version.json
CHANGED
|
@@ -43,56 +43,56 @@ const flexWrapStyles = css({
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
46
|
-
* @codegen <<SignedSource::
|
|
46
|
+
* @codegen <<SignedSource::41d7002b7f69aa44d0d8598e07a1afc6>>
|
|
47
47
|
* @codegenId spacing
|
|
48
48
|
* @codegenCommand yarn codegen-styles
|
|
49
49
|
* @codegenParams ["space"]
|
|
50
50
|
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
|
|
51
51
|
*/
|
|
52
|
-
const spaceMap =
|
|
52
|
+
const spaceMap = {
|
|
53
53
|
'0': css({
|
|
54
|
-
|
|
54
|
+
gap: "var(--ds-space-0, 0px)"
|
|
55
55
|
}),
|
|
56
56
|
'025': css({
|
|
57
|
-
|
|
57
|
+
gap: "var(--ds-space-025, 2px)"
|
|
58
58
|
}),
|
|
59
59
|
'050': css({
|
|
60
|
-
|
|
60
|
+
gap: "var(--ds-space-050, 4px)"
|
|
61
61
|
}),
|
|
62
62
|
'075': css({
|
|
63
|
-
|
|
63
|
+
gap: "var(--ds-space-075, 6px)"
|
|
64
64
|
}),
|
|
65
65
|
'100': css({
|
|
66
|
-
|
|
66
|
+
gap: "var(--ds-space-100, 8px)"
|
|
67
67
|
}),
|
|
68
68
|
'150': css({
|
|
69
|
-
|
|
69
|
+
gap: "var(--ds-space-150, 12px)"
|
|
70
70
|
}),
|
|
71
71
|
'200': css({
|
|
72
|
-
|
|
72
|
+
gap: "var(--ds-space-200, 16px)"
|
|
73
73
|
}),
|
|
74
74
|
'250': css({
|
|
75
|
-
|
|
75
|
+
gap: "var(--ds-space-250, 20px)"
|
|
76
76
|
}),
|
|
77
77
|
'300': css({
|
|
78
|
-
|
|
78
|
+
gap: "var(--ds-space-300, 24px)"
|
|
79
79
|
}),
|
|
80
80
|
'400': css({
|
|
81
|
-
|
|
81
|
+
gap: "var(--ds-space-400, 32px)"
|
|
82
82
|
}),
|
|
83
83
|
'500': css({
|
|
84
|
-
|
|
84
|
+
gap: "var(--ds-space-500, 40px)"
|
|
85
85
|
}),
|
|
86
86
|
'600': css({
|
|
87
|
-
|
|
87
|
+
gap: "var(--ds-space-600, 48px)"
|
|
88
88
|
}),
|
|
89
89
|
'800': css({
|
|
90
|
-
|
|
90
|
+
gap: "var(--ds-space-800, 64px)"
|
|
91
91
|
}),
|
|
92
92
|
'1000': css({
|
|
93
|
-
|
|
93
|
+
gap: "var(--ds-space-1000, 80px)"
|
|
94
94
|
})
|
|
95
|
-
}
|
|
95
|
+
};
|
|
96
96
|
/**
|
|
97
97
|
* @codegenEnd
|
|
98
98
|
*/
|
|
@@ -149,7 +149,7 @@ const Inline = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
149
149
|
}) : rawChildren;
|
|
150
150
|
const justifyContent = spread || alignInline;
|
|
151
151
|
return jsx("div", {
|
|
152
|
-
css: [baseStyles, space && spaceMap
|
|
152
|
+
css: [baseStyles, space && spaceMap[space], justifyContent && justifyContentMap[justifyContent], grow && flexGrowMap[grow], alignItems && alignItemsMap[alignItems], shouldWrap && flexWrapStyles],
|
|
153
153
|
"data-testid": testId,
|
|
154
154
|
ref: ref
|
|
155
155
|
}, children);
|
|
@@ -2,7 +2,52 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
|
-
import
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
|
+
import { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST, LAYERS } from '../../constants';
|
|
7
|
+
import { BOX_RESPONSIVE_PROPS } from './types';
|
|
8
|
+
import { isResponsiveStyleProp, isStaticStyleProp } from './utils';
|
|
9
|
+
const responsiveRules = BOX_RESPONSIVE_PROPS.reduce((mapping, cssProperty) => {
|
|
10
|
+
return Object.assign(mapping, {
|
|
11
|
+
[cssProperty]: BREAKPOINTS_LIST.reduce((configs, breakpoint) => {
|
|
12
|
+
const config = BREAKPOINTS_CONFIG[breakpoint];
|
|
13
|
+
return Object.assign(configs, {
|
|
14
|
+
[breakpoint]: css({
|
|
15
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
16
|
+
[`@media (min-width: ${config.min}px)`]: {
|
|
17
|
+
[cssProperty]: `var(--ds-box-responsive-${cssProperty}-${breakpoint})`
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
}, {
|
|
22
|
+
static: css({
|
|
23
|
+
[cssProperty]: `var(--ds-box-static-${cssProperty})`
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}, {});
|
|
28
|
+
const getResponsiveVars = (propertyName, propertyValue, mapping) => {
|
|
29
|
+
if (isResponsiveStyleProp(propertyValue)) {
|
|
30
|
+
return Object.keys(propertyValue).reduce((vars, breakpoint) => ({
|
|
31
|
+
...vars,
|
|
32
|
+
[`--ds-box-responsive-${propertyName}-${breakpoint}`]: mapping[propertyValue[breakpoint]]
|
|
33
|
+
}), {});
|
|
34
|
+
} else if (isStaticStyleProp(propertyValue)) {
|
|
35
|
+
return {
|
|
36
|
+
[`--ds-box-static-${propertyName}`]: mapping[propertyValue]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const getResponsiveStyles = (propertyName, propertyValue) => {
|
|
41
|
+
invariant(typeof responsiveRules[propertyName] !== 'undefined', `Responsive rules for "${propertyName}" have not been statically defined.`);
|
|
42
|
+
if (isResponsiveStyleProp(propertyValue)) {
|
|
43
|
+
return Object.keys(propertyValue).map(responsiveProp => responsiveRules[propertyName][responsiveProp]);
|
|
44
|
+
} else if (isStaticStyleProp(propertyValue)) {
|
|
45
|
+
return responsiveRules[propertyName].static;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Without this type annotation on Box we don't get autocomplete for props due to forwardRef types
|
|
50
|
+
|
|
6
51
|
/**
|
|
7
52
|
* __Box__
|
|
8
53
|
*
|
|
@@ -39,20 +84,21 @@ export const BaseBox = /*#__PURE__*/forwardRef(({
|
|
|
39
84
|
paddingInlineEnd,
|
|
40
85
|
height,
|
|
41
86
|
width,
|
|
42
|
-
display =
|
|
87
|
+
display = displayMap.block,
|
|
43
88
|
position = 'static',
|
|
44
89
|
UNSAFE_style,
|
|
45
90
|
testId,
|
|
46
91
|
...htmlAttributes
|
|
47
92
|
}, ref) => {
|
|
48
93
|
const Component = as || 'div';
|
|
94
|
+
const inlineStyles = Object.assign({}, UNSAFE_style, getResponsiveVars('borderWidth', borderWidth, borderWidthMap), getResponsiveVars('display', display, displayMap), getResponsiveVars('padding', padding, paddingMap), getResponsiveVars('paddingBlock', paddingBlock, paddingMap), getResponsiveVars('paddingBlockStart', paddingBlockStart, paddingMap), getResponsiveVars('paddingBlockEnd', paddingBlockEnd, paddingMap), getResponsiveVars('paddingInline', paddingInline, paddingMap), getResponsiveVars('paddingInlineStart', paddingInlineStart, paddingMap), getResponsiveVars('paddingInlineEnd', paddingInlineEnd, paddingMap));
|
|
49
95
|
const node = jsx(Component, _extends({
|
|
50
|
-
style:
|
|
96
|
+
style: inlineStyles,
|
|
51
97
|
ref: ref
|
|
52
98
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
53
99
|
}, htmlAttributes, {
|
|
54
100
|
className: className,
|
|
55
|
-
css: [baseStyles, display
|
|
101
|
+
css: [baseStyles, ...[getResponsiveStyles('borderWidth', borderWidth), getResponsiveStyles('display', display), getResponsiveStyles('padding', padding), getResponsiveStyles('paddingBlock', paddingBlock), getResponsiveStyles('paddingBlockStart', paddingBlockStart), getResponsiveStyles('paddingBlockEnd', paddingBlockEnd), getResponsiveStyles('paddingInline', paddingInline), getResponsiveStyles('paddingInlineStart', paddingInlineStart), getResponsiveStyles('paddingInlineEnd', paddingInlineEnd)], backgroundColor && backgroundColorMap[backgroundColor], borderColor && borderColorMap[borderColor], color && textColorMap[color], flex && flexMap[flex], flexGrow && flexGrowMap[flexGrow], flexShrink && flexShrinkMap[flexShrink], alignSelf && alignSelfMap[alignSelf], overflow && overflowMap[overflow], overflowInline && overflowInlineMap[overflowInline], overflowBlock && overflowBlockMap[overflowBlock], position && positionMap[position], borderStyle && borderStyleMap[borderStyle], borderRadius && borderRadiusMap[borderRadius], shadow && shadowMap[shadow], layer && layerMap[layer], overflow && overflowMap[overflow], width && widthMap[width], height && heightMap[height]],
|
|
56
102
|
"data-testid": testId
|
|
57
103
|
}), children);
|
|
58
104
|
return node;
|
|
@@ -71,12 +117,9 @@ const borderStyleMap = {
|
|
|
71
117
|
})
|
|
72
118
|
};
|
|
73
119
|
const borderWidthMap = {
|
|
74
|
-
'size.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
'size.100': css({
|
|
78
|
-
borderWidth: "var(--ds-width-100, 2px)"
|
|
79
|
-
})
|
|
120
|
+
'size.0': "var(--ds-width-0, 0)",
|
|
121
|
+
'size.050': "var(--ds-width-050, 1px)",
|
|
122
|
+
'size.100': "var(--ds-width-100, 2px)"
|
|
80
123
|
};
|
|
81
124
|
const borderRadiusMap = {
|
|
82
125
|
'radius.100': css({
|
|
@@ -134,21 +177,11 @@ const alignSelfMap = {
|
|
|
134
177
|
})
|
|
135
178
|
};
|
|
136
179
|
const displayMap = {
|
|
137
|
-
block:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
inline:
|
|
141
|
-
|
|
142
|
-
}),
|
|
143
|
-
flex: css({
|
|
144
|
-
display: 'flex'
|
|
145
|
-
}),
|
|
146
|
-
'inline-flex': css({
|
|
147
|
-
display: 'inline-flex'
|
|
148
|
-
}),
|
|
149
|
-
'inline-block': css({
|
|
150
|
-
display: 'inline-block'
|
|
151
|
-
})
|
|
180
|
+
block: 'block',
|
|
181
|
+
inline: 'inline',
|
|
182
|
+
flex: 'flex',
|
|
183
|
+
'inline-flex': 'inline-flex',
|
|
184
|
+
'inline-block': 'inline-block'
|
|
152
185
|
};
|
|
153
186
|
const positionMap = {
|
|
154
187
|
absolute: css({
|
|
@@ -363,56 +396,28 @@ const maxHeightMap = {
|
|
|
363
396
|
|
|
364
397
|
/**
|
|
365
398
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
366
|
-
* @codegen <<SignedSource::
|
|
399
|
+
* @codegen <<SignedSource::84fd352b0e6509d380a0dcf8ad023ca2>>
|
|
367
400
|
* @codegenId spacing
|
|
368
401
|
* @codegenCommand yarn codegen-styles
|
|
369
402
|
* @codegenParams ["padding"]
|
|
370
403
|
* @codegenDependency ../../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
|
|
371
404
|
*/
|
|
372
|
-
const paddingMap =
|
|
373
|
-
'space.0':
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
'space.
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
'space.
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
'space.
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
'space.
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
'space.150': css({
|
|
389
|
-
[property]: "var(--ds-space-150, 12px)"
|
|
390
|
-
}),
|
|
391
|
-
'space.200': css({
|
|
392
|
-
[property]: "var(--ds-space-200, 16px)"
|
|
393
|
-
}),
|
|
394
|
-
'space.250': css({
|
|
395
|
-
[property]: "var(--ds-space-250, 20px)"
|
|
396
|
-
}),
|
|
397
|
-
'space.300': css({
|
|
398
|
-
[property]: "var(--ds-space-300, 24px)"
|
|
399
|
-
}),
|
|
400
|
-
'space.400': css({
|
|
401
|
-
[property]: "var(--ds-space-400, 32px)"
|
|
402
|
-
}),
|
|
403
|
-
'space.500': css({
|
|
404
|
-
[property]: "var(--ds-space-500, 40px)"
|
|
405
|
-
}),
|
|
406
|
-
'space.600': css({
|
|
407
|
-
[property]: "var(--ds-space-600, 48px)"
|
|
408
|
-
}),
|
|
409
|
-
'space.800': css({
|
|
410
|
-
[property]: "var(--ds-space-800, 64px)"
|
|
411
|
-
}),
|
|
412
|
-
'space.1000': css({
|
|
413
|
-
[property]: "var(--ds-space-1000, 80px)"
|
|
414
|
-
})
|
|
415
|
-
}]));
|
|
405
|
+
const paddingMap = {
|
|
406
|
+
'space.0': "var(--ds-space-0, 0px)",
|
|
407
|
+
'space.025': "var(--ds-space-025, 2px)",
|
|
408
|
+
'space.050': "var(--ds-space-050, 4px)",
|
|
409
|
+
'space.075': "var(--ds-space-075, 6px)",
|
|
410
|
+
'space.100': "var(--ds-space-100, 8px)",
|
|
411
|
+
'space.150': "var(--ds-space-150, 12px)",
|
|
412
|
+
'space.200': "var(--ds-space-200, 16px)",
|
|
413
|
+
'space.250': "var(--ds-space-250, 20px)",
|
|
414
|
+
'space.300': "var(--ds-space-300, 24px)",
|
|
415
|
+
'space.400': "var(--ds-space-400, 32px)",
|
|
416
|
+
'space.500': "var(--ds-space-500, 40px)",
|
|
417
|
+
'space.600': "var(--ds-space-600, 48px)",
|
|
418
|
+
'space.800': "var(--ds-space-800, 64px)",
|
|
419
|
+
'space.1000': "var(--ds-space-1000, 80px)"
|
|
420
|
+
};
|
|
416
421
|
/**
|
|
417
422
|
* @codegenEnd
|
|
418
423
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const BOX_RESPONSIVE_PROPS = ['borderWidth', 'display', 'padding', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd'];
|
|
@@ -37,56 +37,56 @@ const flexGrowMap = {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
40
|
-
* @codegen <<SignedSource::
|
|
40
|
+
* @codegen <<SignedSource::41d7002b7f69aa44d0d8598e07a1afc6>>
|
|
41
41
|
* @codegenId spacing
|
|
42
42
|
* @codegenCommand yarn codegen-styles
|
|
43
43
|
* @codegenParams ["space"]
|
|
44
44
|
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
|
|
45
45
|
*/
|
|
46
|
-
const spaceMap =
|
|
46
|
+
const spaceMap = {
|
|
47
47
|
'0': css({
|
|
48
|
-
|
|
48
|
+
gap: "var(--ds-space-0, 0px)"
|
|
49
49
|
}),
|
|
50
50
|
'025': css({
|
|
51
|
-
|
|
51
|
+
gap: "var(--ds-space-025, 2px)"
|
|
52
52
|
}),
|
|
53
53
|
'050': css({
|
|
54
|
-
|
|
54
|
+
gap: "var(--ds-space-050, 4px)"
|
|
55
55
|
}),
|
|
56
56
|
'075': css({
|
|
57
|
-
|
|
57
|
+
gap: "var(--ds-space-075, 6px)"
|
|
58
58
|
}),
|
|
59
59
|
'100': css({
|
|
60
|
-
|
|
60
|
+
gap: "var(--ds-space-100, 8px)"
|
|
61
61
|
}),
|
|
62
62
|
'150': css({
|
|
63
|
-
|
|
63
|
+
gap: "var(--ds-space-150, 12px)"
|
|
64
64
|
}),
|
|
65
65
|
'200': css({
|
|
66
|
-
|
|
66
|
+
gap: "var(--ds-space-200, 16px)"
|
|
67
67
|
}),
|
|
68
68
|
'250': css({
|
|
69
|
-
|
|
69
|
+
gap: "var(--ds-space-250, 20px)"
|
|
70
70
|
}),
|
|
71
71
|
'300': css({
|
|
72
|
-
|
|
72
|
+
gap: "var(--ds-space-300, 24px)"
|
|
73
73
|
}),
|
|
74
74
|
'400': css({
|
|
75
|
-
|
|
75
|
+
gap: "var(--ds-space-400, 32px)"
|
|
76
76
|
}),
|
|
77
77
|
'500': css({
|
|
78
|
-
|
|
78
|
+
gap: "var(--ds-space-500, 40px)"
|
|
79
79
|
}),
|
|
80
80
|
'600': css({
|
|
81
|
-
|
|
81
|
+
gap: "var(--ds-space-600, 48px)"
|
|
82
82
|
}),
|
|
83
83
|
'800': css({
|
|
84
|
-
|
|
84
|
+
gap: "var(--ds-space-800, 64px)"
|
|
85
85
|
}),
|
|
86
86
|
'1000': css({
|
|
87
|
-
|
|
87
|
+
gap: "var(--ds-space-1000, 80px)"
|
|
88
88
|
})
|
|
89
|
-
}
|
|
89
|
+
};
|
|
90
90
|
/**
|
|
91
91
|
* @codegenEnd
|
|
92
92
|
*/
|
|
@@ -122,7 +122,7 @@ const Stack = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
122
122
|
}, ref) => {
|
|
123
123
|
const justifyContent = spread || alignBlock;
|
|
124
124
|
return jsx("div", {
|
|
125
|
-
css: [baseStyles, space && spaceMap
|
|
125
|
+
css: [baseStyles, space && spaceMap[space], alignItems && alignItemsMap[alignItems], grow && flexGrowMap[grow], justifyContent && justifyContentMap[justifyContent]],
|
|
126
126
|
"data-testid": testId,
|
|
127
127
|
ref: ref
|
|
128
128
|
}, children);
|
package/dist/es2019/constants.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UNSAFE_Breakpoint as Breakpoint, UNSAFE_BreakpointConfig as BreakpointConfig, UNSAFE_BREAKPOINTS_CONFIG as BREAKPOINTS_CONFIG, UNSAFE_BREAKPOINTS_LIST as BREAKPOINTS_LIST } from '@atlaskit/ds-explorations';
|
|
1
2
|
export const LAYERS = {
|
|
2
3
|
card: 100,
|
|
3
4
|
navigation: 200,
|
|
@@ -8,4 +9,5 @@ export const LAYERS = {
|
|
|
8
9
|
flag: 600,
|
|
9
10
|
spotlight: 700,
|
|
10
11
|
tooltip: 800
|
|
11
|
-
};
|
|
12
|
+
};
|
|
13
|
+
export { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST };
|