@atlaskit/primitives 0.12.5 → 0.13.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 +15 -0
- package/constellation/responsive/usage.mdx +53 -0
- package/dist/cjs/components/inline.js +6 -1
- package/dist/cjs/helpers/responsive/build-media-query-css.js +3 -48
- package/dist/cjs/helpers/responsive/constants.js +11 -25
- package/dist/cjs/helpers/responsive/index.js +6 -6
- package/dist/cjs/helpers/responsive/media-helper.js +35 -38
- package/dist/cjs/helpers/responsive/use-media-query.js +6 -8
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/xcss/style-maps.partial.js +2 -2
- package/dist/cjs/xcss/xcss.js +5 -2
- package/dist/es2019/components/inline.js +6 -1
- package/dist/es2019/helpers/responsive/build-media-query-css.js +3 -52
- package/dist/es2019/helpers/responsive/constants.js +11 -25
- package/dist/es2019/helpers/responsive/index.js +2 -2
- package/dist/es2019/helpers/responsive/media-helper.js +33 -37
- package/dist/es2019/helpers/responsive/use-media-query.js +13 -15
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/xcss/style-maps.partial.js +2 -2
- package/dist/es2019/xcss/xcss.js +6 -2
- package/dist/esm/components/inline.js +6 -1
- package/dist/esm/helpers/responsive/build-media-query-css.js +3 -47
- package/dist/esm/helpers/responsive/constants.js +11 -25
- package/dist/esm/helpers/responsive/index.js +2 -2
- package/dist/esm/helpers/responsive/media-helper.js +33 -37
- package/dist/esm/helpers/responsive/use-media-query.js +13 -15
- package/dist/esm/version.json +1 -1
- package/dist/esm/xcss/style-maps.partial.js +2 -2
- package/dist/esm/xcss/xcss.js +6 -3
- package/dist/types/components/inline.d.ts +6 -1
- package/dist/types/helpers/responsive/build-media-query-css.d.ts +0 -30
- package/dist/types/helpers/responsive/constants.d.ts +42 -7
- package/dist/types/helpers/responsive/index.d.ts +2 -2
- package/dist/types/helpers/responsive/media-helper.d.ts +61 -31
- package/dist/types/helpers/responsive/types.d.ts +10 -10
- package/dist/types/helpers/responsive/use-media-query.d.ts +2 -2
- package/dist/types/xcss/style-maps.partial.d.ts +2 -2
- package/dist/types/xcss/xcss.d.ts +3 -3
- package/dist/types-ts4.5/components/inline.d.ts +6 -1
- package/dist/types-ts4.5/helpers/responsive/build-media-query-css.d.ts +0 -30
- package/dist/types-ts4.5/helpers/responsive/constants.d.ts +42 -8
- package/dist/types-ts4.5/helpers/responsive/index.d.ts +2 -2
- package/dist/types-ts4.5/helpers/responsive/media-helper.d.ts +61 -31
- package/dist/types-ts4.5/helpers/responsive/types.d.ts +10 -10
- package/dist/types-ts4.5/helpers/responsive/use-media-query.d.ts +2 -2
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +2 -2
- package/dist/types-ts4.5/xcss/xcss.d.ts +3 -3
- package/package.json +12 -3
- package/report.api.md +49 -32
- package/tmp/api-report-tmp.d.ts +27 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`455677dbd4c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/455677dbd4c) - - Documents the responsive media helpers into an Alpha state.
|
|
8
|
+
- BREAKING: Removes the `xxl` breakpoint from all media queries (should be unused).
|
|
9
|
+
- Adds a new `media` export without `media.below` intentionally omitted. Should be unused externally, but used internally and still available via the existing `UNSAFE_media` export.
|
|
10
|
+
- Changes the underlying media queries to be a bit safer against unexpected overlap. This changes the breakpoints ever-so-slightly, but given browsers round fractional rems, it's impractical that this will have any unintended impact—if anything, it may fix a bug.
|
|
11
|
+
|
|
12
|
+
## 0.12.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`3be327cdd6a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3be327cdd6a) - Allow styles to be applied to Inline through xcss.
|
|
17
|
+
|
|
3
18
|
## 0.12.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Responsive
|
|
3
|
+
description: Responsive helpers and primitives to build responsive UIs with
|
|
4
|
+
order: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Media query helpers
|
|
8
|
+
|
|
9
|
+
We expose two media query helper objects which map to our [breakpoints](/components/grid/usage#breakpoints) as media queries for use in css-in-js:
|
|
10
|
+
- `media.above[breakpoint]` to target all viewports **above** (larger than) the min-width of a given breakpoint
|
|
11
|
+
|
|
12
|
+
### A basic example:
|
|
13
|
+
|
|
14
|
+
Compose your default styles alongside media overrides in [xcss](/components/primitives/xcss) or `css`
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
const customStyles = xcss({
|
|
18
|
+
display: 'none', // hide by default
|
|
19
|
+
padding: 'space.100',
|
|
20
|
+
[media.above.md]: { display: 'revert' }, // show above md
|
|
21
|
+
[media.above.lg]: { padding: 'space.150' }, // increase padding above md
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const Component = ({ children }: { children: ReactNode }) => (
|
|
25
|
+
<div css={customStyles}>{children}</div>
|
|
26
|
+
);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### `media.above` usage
|
|
30
|
+
|
|
31
|
+
Please note that `media.above.xxs` will **always** match; it is explicitly `'@media all'`. This is only included for easy programatic usage, but it has a negative performance impact.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
const customStyles = css({
|
|
35
|
+
marginBlock: token('space.0'),
|
|
36
|
+
[media.above.xs]: { marginBlock: token('space.025') },
|
|
37
|
+
[media.above.sm]: { marginBlock: token('space.050') },
|
|
38
|
+
[media.above.md]: { marginBlock: token('space.075') },
|
|
39
|
+
[media.above.lg]: { marginBlock: token('space.100') },
|
|
40
|
+
[media.above.xl]: { marginBlock: token('space.150') },
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### `media.below` usage
|
|
45
|
+
|
|
46
|
+
This is intentionally excluded at the moment as we're shipping our opinion that teams should design mobile-first.
|
|
47
|
+
We understand this will not scale and we're open to change, but we'd like to change this with feedback.
|
|
48
|
+
|
|
49
|
+
If we do add it back, we'd suggest codebases prefer a single approach (eg. `above` or `below`) and use that consistently. Mixing them results in confusion (though they can be safely used together and can result in better CSS performance when done correctly).
|
|
50
|
+
|
|
51
|
+
### Some notes and suggestions
|
|
52
|
+
|
|
53
|
+
- Please combine this with our [xcss](/components/primitives/xcss) when available as this uses our media queries to allow for safe, responsive styling.
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _react2 = require("@emotion/react");
|
|
9
9
|
var _styleMaps = require("../xcss/style-maps.partial");
|
|
10
|
+
var _xcss = require("../xcss/xcss");
|
|
10
11
|
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
11
12
|
/** @jsx jsx */
|
|
12
13
|
|
|
@@ -99,6 +100,7 @@ var Inline = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
99
100
|
space = _ref2.space,
|
|
100
101
|
rowSpace = _ref2.rowSpace,
|
|
101
102
|
separator = _ref2.separator,
|
|
103
|
+
xcss = _ref2.xcss,
|
|
102
104
|
testId = _ref2.testId,
|
|
103
105
|
rawChildren = _ref2.children;
|
|
104
106
|
var Component = as || 'div';
|
|
@@ -109,8 +111,11 @@ var Inline = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
109
111
|
}, separator && index > 0 ? separatorComponent : null, child);
|
|
110
112
|
}) : rawChildren;
|
|
111
113
|
var justifyContent = spread || alignInline;
|
|
114
|
+
var className = xcss && (0, _xcss.parseXcss)(xcss);
|
|
112
115
|
return (0, _react2.jsx)(Component, {
|
|
113
|
-
css: [
|
|
116
|
+
css: [
|
|
117
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
118
|
+
className, baseStyles, space && _styleMaps.spaceStylesMap.gap[space], justifyContent && justifyContentMap[justifyContent], grow && flexGrowMap[grow], alignItems && alignItemsMap[alignItems], shouldWrap && flexWrapStyles, rowSpace && _styleMaps.spaceStylesMap.rowGap[rowSpace]],
|
|
114
119
|
"data-testid": testId,
|
|
115
120
|
ref: ref
|
|
116
121
|
}, children);
|
|
@@ -4,8 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
|
+
exports.UNSAFE_buildAboveMediaQueryCSS = void 0;
|
|
9
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _react = require("@emotion/react");
|
|
11
10
|
var _constants = require("./constants");
|
|
@@ -38,51 +37,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
38
37
|
*/
|
|
39
38
|
var UNSAFE_buildAboveMediaQueryCSS = function UNSAFE_buildAboveMediaQueryCSS(input) {
|
|
40
39
|
return _constants.UNSAFE_BREAKPOINTS_ORDERED_LIST.reduce(function (acc, breakpoint) {
|
|
41
|
-
return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, breakpoint, (0, _react.css)((0, _defineProperty2.default)({}, _mediaHelper.
|
|
40
|
+
return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, breakpoint, (0, _react.css)((0, _defineProperty2.default)({}, _mediaHelper.media.above[breakpoint], typeof input === 'function' ? input(breakpoint) : input))));
|
|
42
41
|
}, {});
|
|
43
42
|
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Build a map of breakpoints to css with media queries and nested styles.
|
|
47
|
-
*
|
|
48
|
-
* WARNING: The smallest breakpoint is not a valid key as a media query below 0px is misleading.
|
|
49
|
-
* This is separated from `buildAboveMediaQueryCSS` for that specific reason, you cannot have type safety with this variance.
|
|
50
|
-
*
|
|
51
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* A map to build optional `display:none` for consumption on a div.
|
|
55
|
-
* ```ts
|
|
56
|
-
* const hideMediaQueries = buildBelowMediaQueryCSS({ display: 'none' });
|
|
57
|
-
*
|
|
58
|
-
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
59
|
-
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* This roughly builds a map that will look roughly like this (if done manually):
|
|
64
|
-
* ```ts
|
|
65
|
-
* {
|
|
66
|
-
* xs: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
67
|
-
* sm: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
72
|
-
*/
|
|
73
|
-
exports.UNSAFE_buildAboveMediaQueryCSS = UNSAFE_buildAboveMediaQueryCSS;
|
|
74
|
-
var UNSAFE_buildBelowMediaQueryCSS = function UNSAFE_buildBelowMediaQueryCSS(input) {
|
|
75
|
-
/**
|
|
76
|
-
* WARNING: it's very important that these are in the correct order.
|
|
77
|
-
* If they are not, cascading is not in the order higher/low breakpoints do not override as expected.
|
|
78
|
-
*/
|
|
79
|
-
var reversedBreakpoints = (0, _toConsumableArray2.default)(_constants.UNSAFE_BREAKPOINTS_ORDERED_LIST).reverse();
|
|
80
|
-
return reversedBreakpoints.reduce(function (acc, breakpoint) {
|
|
81
|
-
// Omit `media.below.xxs` as it's not available as that would be `<0px`…
|
|
82
|
-
if (breakpoint === _constants.SMALLEST_BREAKPOINT) {
|
|
83
|
-
return acc;
|
|
84
|
-
}
|
|
85
|
-
return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, breakpoint, (0, _react.css)((0, _defineProperty2.default)({}, _mediaHelper.UNSAFE_media.below[breakpoint], typeof input === 'function' ? input(breakpoint) : input))));
|
|
86
|
-
}, {});
|
|
87
|
-
};
|
|
88
|
-
exports.UNSAFE_buildBelowMediaQueryCSS = UNSAFE_buildBelowMediaQueryCSS;
|
|
43
|
+
exports.UNSAFE_buildAboveMediaQueryCSS = UNSAFE_buildAboveMediaQueryCSS;
|
|
@@ -7,68 +7,56 @@ exports.UNSAFE_BREAKPOINTS_ORDERED_LIST = exports.UNSAFE_BREAKPOINTS_CONFIG = ex
|
|
|
7
7
|
/**
|
|
8
8
|
* Our internal configuration for breakpoints configuration.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* We explicitly use `-0.01rem` for "max" values to both ensure we do not overlap our media queries, but also don't skip any fractional pixels. There is a chance this is not safe in some browsers, eg. Safari has weird rounding.
|
|
11
|
+
* @see: https://tzi.fr/css/prevent-double-breakpoint/
|
|
11
12
|
*
|
|
12
|
-
* @experimental Unsafe for consumption outside of the design system itself.
|
|
13
|
+
* @experimental Unsafe for direct consumption outside of the design system itself; please use our `media` export instead for media queries.
|
|
13
14
|
*/
|
|
14
15
|
var UNSAFE_BREAKPOINTS_CONFIG = {
|
|
15
16
|
// mobile
|
|
16
17
|
xxs: {
|
|
17
18
|
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
18
19
|
gridMargin: "var(--ds-space-200, 16px)",
|
|
19
|
-
below: '0rem',
|
|
20
20
|
min: '0rem',
|
|
21
|
-
max: '29.
|
|
21
|
+
max: '29.99rem'
|
|
22
22
|
},
|
|
23
23
|
// phablet
|
|
24
24
|
xs: {
|
|
25
25
|
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
26
26
|
gridMargin: "var(--ds-space-200, 16px)",
|
|
27
|
-
below: '29.998rem',
|
|
28
27
|
min: '30rem',
|
|
29
|
-
max: '47.
|
|
28
|
+
max: '47.99rem'
|
|
30
29
|
},
|
|
31
30
|
// tablet
|
|
32
31
|
sm: {
|
|
33
32
|
gridItemGutter: "var(--ds-space-200, 16px)",
|
|
34
33
|
gridMargin: "var(--ds-space-300, 24px)",
|
|
35
|
-
below: '47.998rem',
|
|
36
34
|
min: '48rem',
|
|
37
|
-
max: '63.
|
|
35
|
+
max: '63.99rem'
|
|
38
36
|
},
|
|
39
37
|
// laptop desktop
|
|
40
38
|
md: {
|
|
41
39
|
gridItemGutter: "var(--ds-space-300, 24px)",
|
|
42
40
|
gridMargin: "var(--ds-space-400, 32px)",
|
|
43
|
-
below: '63.998rem',
|
|
44
41
|
min: '64rem',
|
|
45
|
-
max: '89.
|
|
42
|
+
max: '89.99rem'
|
|
46
43
|
},
|
|
47
44
|
// monitor
|
|
48
45
|
lg: {
|
|
49
46
|
gridItemGutter: "var(--ds-space-400, 32px)",
|
|
50
47
|
gridMargin: "var(--ds-space-400, 32px)",
|
|
51
|
-
below: '89.998rem',
|
|
52
48
|
min: '90rem',
|
|
53
|
-
max: '109.
|
|
49
|
+
max: '109.99rem'
|
|
54
50
|
},
|
|
55
51
|
// large high res
|
|
56
52
|
xl: {
|
|
57
53
|
gridItemGutter: "var(--ds-space-400, 32px)",
|
|
58
54
|
gridMargin: "var(--ds-space-500, 40px)",
|
|
59
|
-
below: '109.998rem',
|
|
60
55
|
min: '110rem',
|
|
61
|
-
max:
|
|
62
|
-
},
|
|
63
|
-
// extra large high res
|
|
64
|
-
xxl: {
|
|
65
|
-
gridItemGutter: "var(--ds-space-500, 40px)",
|
|
66
|
-
gridMargin: "var(--ds-space-500, 40px)",
|
|
67
|
-
below: '134.998rem',
|
|
68
|
-
min: '135rem',
|
|
69
|
-
max: "".concat(Number.MAX_SAFE_INTEGER, "rem")
|
|
56
|
+
max: null
|
|
70
57
|
}
|
|
71
|
-
|
|
58
|
+
// NOTE: We previously had an `xxl=135rem` breakpoint, but it was removed as it was not used anywhere and felt too large
|
|
59
|
+
}; //TODO: This `as const` should really be `satisfies Record<Breakpoint, BreakpointConfig>`, but that's not possible in our shipped TypeScript version yet.
|
|
72
60
|
|
|
73
61
|
/**
|
|
74
62
|
* The list of breakpoints in order from smallest to largest. You may need to clone and reverse this list if you want the opposite.
|
|
@@ -84,8 +72,6 @@ var UNSAFE_BREAKPOINTS_ORDERED_LIST = Object.keys(UNSAFE_BREAKPOINTS_CONFIG);
|
|
|
84
72
|
* This is our smallest breakpoint with a few nuances to it:
|
|
85
73
|
* 1. It is the default value for shorthands, eg. `<GridItem span={6} />` maps to `{ [SMALLEST_BREAKPOINT]: props.span }`
|
|
86
74
|
* 2. It's omitted in `media.below` as there's nothing below `0px`.
|
|
87
|
-
*
|
|
88
|
-
* @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.
|
|
89
75
|
*/
|
|
90
76
|
exports.UNSAFE_BREAKPOINTS_ORDERED_LIST = UNSAFE_BREAKPOINTS_ORDERED_LIST;
|
|
91
77
|
var SMALLEST_BREAKPOINT = UNSAFE_BREAKPOINTS_ORDERED_LIST[0];
|
|
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "UNSAFE_buildAboveMediaQueryCSS", {
|
|
|
21
21
|
return _buildMediaQueryCss.UNSAFE_buildAboveMediaQueryCSS;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "UNSAFE_buildBelowMediaQueryCSS", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _buildMediaQueryCss.UNSAFE_buildBelowMediaQueryCSS;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
24
|
Object.defineProperty(exports, "UNSAFE_media", {
|
|
31
25
|
enumerable: true,
|
|
32
26
|
get: function get() {
|
|
@@ -39,6 +33,12 @@ Object.defineProperty(exports, "UNSAFE_useMediaQuery", {
|
|
|
39
33
|
return _useMediaQuery.UNSAFE_useMediaQuery;
|
|
40
34
|
}
|
|
41
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "media", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _mediaHelper.media;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
42
|
var _mediaHelper = require("./media-helper");
|
|
43
43
|
var _buildMediaQueryCss = require("./build-media-query-css");
|
|
44
44
|
var _constants = require("./constants");
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UNSAFE_media = void 0;
|
|
6
|
+
exports.media = exports.UNSAFE_media = void 0;
|
|
7
7
|
var _constants = require("./constants");
|
|
8
8
|
/**
|
|
9
|
-
* This is
|
|
9
|
+
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
10
|
+
*
|
|
11
|
+
* @internal This explicitly has and should not be used outside of ADS-owned repos (via sourcegraph); to be removed following an internal deprecation and migration.
|
|
10
12
|
*/
|
|
11
|
-
var
|
|
13
|
+
var UNSAFE_media = {
|
|
12
14
|
/**
|
|
13
15
|
* A media query to target viewports above the min width of a given breakpoint.
|
|
14
16
|
* Note that `media.above.xs` is redundant and should not be used, but it's included for programatic purposes.
|
|
@@ -16,31 +18,40 @@ var internalMedia = {
|
|
|
16
18
|
above: {
|
|
17
19
|
/**
|
|
18
20
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
19
|
-
*
|
|
20
|
-
* Eg. this is `@media (min-width: 0px)`
|
|
21
21
|
*/
|
|
22
|
-
xxs: "@media
|
|
22
|
+
xxs: "@media all",
|
|
23
23
|
xs: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xs.min, ")"),
|
|
24
24
|
sm: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.min, ")"),
|
|
25
25
|
md: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.min, ")"),
|
|
26
26
|
lg: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.min, ")"),
|
|
27
|
-
xl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min, ")")
|
|
28
|
-
xxl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxl.min, ")")
|
|
27
|
+
xl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min, ")")
|
|
29
28
|
},
|
|
29
|
+
/**
|
|
30
|
+
* A media query to target viewports below the min width of a given breakpoint. We do this by testing the inverse, eg. below = not above…
|
|
31
|
+
*
|
|
32
|
+
* NOTE: `below.xxs` is intentionally not included as it could lead to incorrect usages as it's never accessible as this would be `xxs: '@media not all',`
|
|
33
|
+
*
|
|
34
|
+
* We use this syntax as a more compatible way to ensure media queries do not overlap, eg. `media.above.md` and `media.below.md` should not both trigger at once.
|
|
35
|
+
* This is well describe in this: @see https://stackoverflow.com/a/13649011
|
|
36
|
+
*
|
|
37
|
+
* Ideally we would use media queries level 4 to improve this interface, but this works and browser support might not be sufficient yet: @see https://www.w3.org/TR/mediaqueries-4/
|
|
38
|
+
*
|
|
39
|
+
* @internal Not intended to be used outside of DST at this stage.
|
|
40
|
+
* @experimental Not intended to be used outside of DST at this stage.
|
|
41
|
+
*/
|
|
30
42
|
below: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
sm: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.below, ")"),
|
|
37
|
-
md: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.below, ")"),
|
|
38
|
-
lg: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.below, ")"),
|
|
39
|
-
xl: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.below, ")"),
|
|
40
|
-
xxl: "@media (max-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxl.below, ")")
|
|
43
|
+
xs: "@media not all and (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xs.min, ")"),
|
|
44
|
+
sm: "@media not all and (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.min, ")"),
|
|
45
|
+
md: "@media not all and (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.min, ")"),
|
|
46
|
+
lg: "@media not all and (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.min, ")"),
|
|
47
|
+
xl: "@media not all and (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min, ")")
|
|
41
48
|
},
|
|
42
49
|
/**
|
|
43
50
|
* A media query to target viewports exactly between the min and max of a given breakpoint.
|
|
51
|
+
* Ideally we would use media queries level 4 to improve this interface, but this works and browser support might not be sufficient yet: @see https://www.w3.org/TR/mediaqueries-4/
|
|
52
|
+
*
|
|
53
|
+
* @internal Not intended to be used outside of DST at this stage.
|
|
54
|
+
* @experimental Not intended to be used outside of DST at this stage.
|
|
44
55
|
*/
|
|
45
56
|
only: {
|
|
46
57
|
xxs: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxs.min, ") and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxs.max, ")"),
|
|
@@ -48,31 +59,17 @@ var internalMedia = {
|
|
|
48
59
|
sm: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.min, ") and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.sm.max, ")"),
|
|
49
60
|
md: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.min, ") and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.md.max, ")"),
|
|
50
61
|
lg: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.min, ") and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.lg.max, ")"),
|
|
51
|
-
xl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min, ")
|
|
52
|
-
xxl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxl.min, ") and (max-width: ").concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xxl.max, ")")
|
|
62
|
+
xl: "@media (min-width: ".concat(_constants.UNSAFE_BREAKPOINTS_CONFIG.xl.min, ")")
|
|
53
63
|
}
|
|
54
64
|
};
|
|
55
65
|
|
|
56
66
|
/**
|
|
57
67
|
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
58
68
|
*
|
|
59
|
-
*
|
|
69
|
+
* We strictly only export `media.above` at this stage as we want makers to build mobile-first.
|
|
60
70
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
exports.UNSAFE_media = UNSAFE_media;
|
|
72
|
+
var media = {
|
|
73
|
+
above: UNSAFE_media.above
|
|
64
74
|
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* With these types:
|
|
68
|
-
* ```
|
|
69
|
-
* type MediaQuery = `@media (${string})`;
|
|
70
|
-
* type ResponsiveMediaObject = Record<Breakpoint, MediaQuery>;
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* TODO: This `media` object as of typescript@4.9, would benefit from satisfies, eg.:
|
|
74
|
-
* ```
|
|
75
|
-
* const UNSAFE_media = { … } satisfies Record<'above' | 'only', ResponsiveMediaObject> & { below: Omit<ResponsiveMediaObject, 'xxs'> }
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
exports.UNSAFE_media = UNSAFE_media;
|
|
75
|
+
exports.media = media;
|
|
@@ -7,7 +7,7 @@ exports.UNSAFE_useMediaQuery = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _bindEventListener = require("bind-event-listener");
|
|
9
9
|
var _mediaHelper = require("./media-helper");
|
|
10
|
-
var _window, _window$matchMedia, _window2, _window2$matchMedia, _window3, _window3$matchMedia, _window4, _window4$matchMedia, _window5, _window5$matchMedia, _window6, _window6$matchMedia, _window7, _window7$matchMedia, _window8, _window8$matchMedia, _window9, _window9$matchMedia, _window10, _window10$matchMedia, _window11, _window11$matchMedia
|
|
10
|
+
var _window, _window$matchMedia, _window2, _window2$matchMedia, _window3, _window3$matchMedia, _window4, _window4$matchMedia, _window5, _window5$matchMedia, _window6, _window6$matchMedia, _window7, _window7$matchMedia, _window8, _window8$matchMedia, _window9, _window9$matchMedia, _window10, _window10$matchMedia, _window11, _window11$matchMedia;
|
|
11
11
|
var queries = {
|
|
12
12
|
'above.xxs': typeof window === 'undefined' ? undefined : (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, _mediaHelper.UNSAFE_media.above.xxs.replace('@media ', '').trim()),
|
|
13
13
|
'above.xs': typeof window === 'undefined' ? undefined : (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$matchMedia = _window2.matchMedia) === null || _window2$matchMedia === void 0 ? void 0 : _window2$matchMedia.call(_window2, _mediaHelper.UNSAFE_media.above.xs.replace('@media ', '').trim()),
|
|
@@ -15,13 +15,11 @@ var queries = {
|
|
|
15
15
|
'above.md': typeof window === 'undefined' ? undefined : (_window4 = window) === null || _window4 === void 0 ? void 0 : (_window4$matchMedia = _window4.matchMedia) === null || _window4$matchMedia === void 0 ? void 0 : _window4$matchMedia.call(_window4, _mediaHelper.UNSAFE_media.above.md.replace('@media ', '').trim()),
|
|
16
16
|
'above.lg': typeof window === 'undefined' ? undefined : (_window5 = window) === null || _window5 === void 0 ? void 0 : (_window5$matchMedia = _window5.matchMedia) === null || _window5$matchMedia === void 0 ? void 0 : _window5$matchMedia.call(_window5, _mediaHelper.UNSAFE_media.above.lg.replace('@media ', '').trim()),
|
|
17
17
|
'above.xl': typeof window === 'undefined' ? undefined : (_window6 = window) === null || _window6 === void 0 ? void 0 : (_window6$matchMedia = _window6.matchMedia) === null || _window6$matchMedia === void 0 ? void 0 : _window6$matchMedia.call(_window6, _mediaHelper.UNSAFE_media.above.xl.replace('@media ', '').trim()),
|
|
18
|
-
'
|
|
19
|
-
'below.
|
|
20
|
-
'below.
|
|
21
|
-
'below.
|
|
22
|
-
'below.
|
|
23
|
-
'below.xl': typeof window === 'undefined' ? undefined : (_window12 = window) === null || _window12 === void 0 ? void 0 : (_window12$matchMedia = _window12.matchMedia) === null || _window12$matchMedia === void 0 ? void 0 : _window12$matchMedia.call(_window12, _mediaHelper.UNSAFE_media.below.xl.replace('@media ', '').trim()),
|
|
24
|
-
'below.xxl': typeof window === 'undefined' ? undefined : (_window13 = window) === null || _window13 === void 0 ? void 0 : (_window13$matchMedia = _window13.matchMedia) === null || _window13$matchMedia === void 0 ? void 0 : _window13$matchMedia.call(_window13, _mediaHelper.UNSAFE_media.below.xxl.replace('@media ', '').trim())
|
|
18
|
+
'below.xs': typeof window === 'undefined' ? undefined : (_window7 = window) === null || _window7 === void 0 ? void 0 : (_window7$matchMedia = _window7.matchMedia) === null || _window7$matchMedia === void 0 ? void 0 : _window7$matchMedia.call(_window7, _mediaHelper.UNSAFE_media.below.xs.replace('@media ', '').trim()),
|
|
19
|
+
'below.sm': typeof window === 'undefined' ? undefined : (_window8 = window) === null || _window8 === void 0 ? void 0 : (_window8$matchMedia = _window8.matchMedia) === null || _window8$matchMedia === void 0 ? void 0 : _window8$matchMedia.call(_window8, _mediaHelper.UNSAFE_media.below.sm.replace('@media ', '').trim()),
|
|
20
|
+
'below.md': typeof window === 'undefined' ? undefined : (_window9 = window) === null || _window9 === void 0 ? void 0 : (_window9$matchMedia = _window9.matchMedia) === null || _window9$matchMedia === void 0 ? void 0 : _window9$matchMedia.call(_window9, _mediaHelper.UNSAFE_media.below.md.replace('@media ', '').trim()),
|
|
21
|
+
'below.lg': typeof window === 'undefined' ? undefined : (_window10 = window) === null || _window10 === void 0 ? void 0 : (_window10$matchMedia = _window10.matchMedia) === null || _window10$matchMedia === void 0 ? void 0 : _window10$matchMedia.call(_window10, _mediaHelper.UNSAFE_media.below.lg.replace('@media ', '').trim()),
|
|
22
|
+
'below.xl': typeof window === 'undefined' ? undefined : (_window11 = window) === null || _window11 === void 0 ? void 0 : (_window11$matchMedia = _window11.matchMedia) === null || _window11$matchMedia === void 0 ? void 0 : _window11$matchMedia.call(_window11, _mediaHelper.UNSAFE_media.below.xl.replace('@media ', '').trim())
|
|
25
23
|
};
|
|
26
24
|
|
|
27
25
|
/**
|
package/dist/cjs/version.json
CHANGED
|
@@ -60,11 +60,11 @@ exports.spaceMap = spaceMap;
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
63
|
-
* @codegen <<SignedSource::
|
|
63
|
+
* @codegen <<SignedSource::80db0ba91b44837306516b95e9cf080e>>
|
|
64
64
|
* @codegenId colors
|
|
65
65
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
66
66
|
* @codegenParams ["border", "background", "shadow", "text", "fill"]
|
|
67
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
67
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::c829bed8504655cd09b971d338d7f3a1>>
|
|
68
68
|
*/
|
|
69
69
|
var borderColorMap = {
|
|
70
70
|
'color.border': "var(--ds-border, #091e4221)",
|
package/dist/cjs/xcss/xcss.js
CHANGED
|
@@ -8,7 +8,6 @@ exports.parseXcss = void 0;
|
|
|
8
8
|
exports.xcss = xcss;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
12
|
var _react = require("@emotion/react");
|
|
14
13
|
var _warnOnce = _interopRequireDefault(require("@atlaskit/ds-lib/warn-once"));
|
|
@@ -84,7 +83,11 @@ var isSafeEnvToThrow = function isSafeEnvToThrow() {
|
|
|
84
83
|
var reNestedSelectors = /(\.|\s|&+|\*\>|#|\[.*\])/;
|
|
85
84
|
var rePseudos = /^::?.*$/;
|
|
86
85
|
var reMediaQuery = /^@media .*$/;
|
|
87
|
-
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Reduce our media queries into a safe string for regex comparison.
|
|
89
|
+
*/
|
|
90
|
+
var reValidMediaQuery = new RegExp("^(".concat(Object.values(_responsive.media.above).map(function (mediaQuery) {
|
|
88
91
|
return mediaQuery.replace(/[.()]/g, '\\$&');
|
|
89
92
|
} // Escape the ".", "(", and ")" in the media query syntax.
|
|
90
93
|
).join('|'), ")$"));
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Children, forwardRef, Fragment, memo } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import { spaceStylesMap } from '../xcss/style-maps.partial';
|
|
6
|
+
import { parseXcss } from '../xcss/xcss';
|
|
6
7
|
const alignItemsMap = {
|
|
7
8
|
center: css({
|
|
8
9
|
alignItems: 'center'
|
|
@@ -89,6 +90,7 @@ const Inline = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
89
90
|
space,
|
|
90
91
|
rowSpace,
|
|
91
92
|
separator,
|
|
93
|
+
xcss,
|
|
92
94
|
testId,
|
|
93
95
|
children: rawChildren
|
|
94
96
|
}, ref) => {
|
|
@@ -100,8 +102,11 @@ const Inline = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
100
102
|
}, separator && index > 0 ? separatorComponent : null, child);
|
|
101
103
|
}) : rawChildren;
|
|
102
104
|
const justifyContent = spread || alignInline;
|
|
105
|
+
const className = xcss && parseXcss(xcss);
|
|
103
106
|
return jsx(Component, {
|
|
104
|
-
css: [
|
|
107
|
+
css: [
|
|
108
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
109
|
+
className, baseStyles, space && spaceStylesMap.gap[space], justifyContent && justifyContentMap[justifyContent], grow && flexGrowMap[grow], alignItems && alignItemsMap[alignItems], shouldWrap && flexWrapStyles, rowSpace && spaceStylesMap.rowGap[rowSpace]],
|
|
105
110
|
"data-testid": testId,
|
|
106
111
|
ref: ref
|
|
107
112
|
}, children);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { UNSAFE_BREAKPOINTS_ORDERED_LIST } from './constants';
|
|
3
|
+
import { media } from './media-helper';
|
|
4
4
|
/**
|
|
5
5
|
* Build a map of breakpoints to css with media queries and nested styles.
|
|
6
6
|
*
|
|
@@ -30,56 +30,7 @@ export const UNSAFE_buildAboveMediaQueryCSS = input => {
|
|
|
30
30
|
...acc,
|
|
31
31
|
[breakpoint]: css({
|
|
32
32
|
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
33
|
-
[
|
|
33
|
+
[media.above[breakpoint]]: typeof input === 'function' ? input(breakpoint) : input
|
|
34
34
|
})
|
|
35
35
|
}), {});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Build a map of breakpoints to css with media queries and nested styles.
|
|
40
|
-
*
|
|
41
|
-
* WARNING: The smallest breakpoint is not a valid key as a media query below 0px is misleading.
|
|
42
|
-
* This is separated from `buildAboveMediaQueryCSS` for that specific reason, you cannot have type safety with this variance.
|
|
43
|
-
*
|
|
44
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* A map to build optional `display:none` for consumption on a div.
|
|
48
|
-
* ```ts
|
|
49
|
-
* const hideMediaQueries = buildBelowMediaQueryCSS({ display: 'none' });
|
|
50
|
-
*
|
|
51
|
-
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
52
|
-
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* This roughly builds a map that will look roughly like this (if done manually):
|
|
57
|
-
* ```ts
|
|
58
|
-
* {
|
|
59
|
-
* xs: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
60
|
-
* sm: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
61
|
-
* }
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
65
|
-
*/
|
|
66
|
-
export const UNSAFE_buildBelowMediaQueryCSS = input => {
|
|
67
|
-
/**
|
|
68
|
-
* WARNING: it's very important that these are in the correct order.
|
|
69
|
-
* If they are not, cascading is not in the order higher/low breakpoints do not override as expected.
|
|
70
|
-
*/
|
|
71
|
-
const reversedBreakpoints = [...UNSAFE_BREAKPOINTS_ORDERED_LIST].reverse();
|
|
72
|
-
return reversedBreakpoints.reduce((acc, breakpoint) => {
|
|
73
|
-
// Omit `media.below.xxs` as it's not available as that would be `<0px`…
|
|
74
|
-
if (breakpoint === SMALLEST_BREAKPOINT) {
|
|
75
|
-
return acc;
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
...acc,
|
|
79
|
-
[breakpoint]: css({
|
|
80
|
-
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
81
|
-
[UNSAFE_media.below[breakpoint]]: typeof input === 'function' ? input(breakpoint) : input
|
|
82
|
-
})
|
|
83
|
-
};
|
|
84
|
-
}, {});
|
|
85
36
|
};
|