@atlaskit/primitives 0.12.6 → 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 +9 -0
- package/constellation/responsive/usage.mdx +53 -0
- 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/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/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/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-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/package.json +12 -3
- package/report.api.md +15 -26
- package/tmp/api-report-tmp.d.ts +15 -24
|
@@ -1,12 +1,49 @@
|
|
|
1
|
-
import type { Breakpoint, BreakpointConfig } from './types';
|
|
2
1
|
/**
|
|
3
2
|
* Our internal configuration for breakpoints configuration.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
4
|
+
* 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.
|
|
5
|
+
* @see: https://tzi.fr/css/prevent-double-breakpoint/
|
|
6
6
|
*
|
|
7
|
-
* @experimental Unsafe for consumption outside of the design system itself.
|
|
7
|
+
* @experimental Unsafe for direct consumption outside of the design system itself; please use our `media` export instead for media queries.
|
|
8
8
|
*/
|
|
9
|
-
export declare const UNSAFE_BREAKPOINTS_CONFIG:
|
|
9
|
+
export declare const UNSAFE_BREAKPOINTS_CONFIG: {
|
|
10
|
+
readonly xxs: {
|
|
11
|
+
readonly gridItemGutter: "var(--ds-space-200)";
|
|
12
|
+
readonly gridMargin: "var(--ds-space-200)";
|
|
13
|
+
readonly min: "0rem";
|
|
14
|
+
readonly max: "29.99rem";
|
|
15
|
+
};
|
|
16
|
+
readonly xs: {
|
|
17
|
+
readonly gridItemGutter: "var(--ds-space-200)";
|
|
18
|
+
readonly gridMargin: "var(--ds-space-200)";
|
|
19
|
+
readonly min: "30rem";
|
|
20
|
+
readonly max: "47.99rem";
|
|
21
|
+
};
|
|
22
|
+
readonly sm: {
|
|
23
|
+
readonly gridItemGutter: "var(--ds-space-200)";
|
|
24
|
+
readonly gridMargin: "var(--ds-space-300)";
|
|
25
|
+
readonly min: "48rem";
|
|
26
|
+
readonly max: "63.99rem";
|
|
27
|
+
};
|
|
28
|
+
readonly md: {
|
|
29
|
+
readonly gridItemGutter: "var(--ds-space-300)";
|
|
30
|
+
readonly gridMargin: "var(--ds-space-400)";
|
|
31
|
+
readonly min: "64rem";
|
|
32
|
+
readonly max: "89.99rem";
|
|
33
|
+
};
|
|
34
|
+
readonly lg: {
|
|
35
|
+
readonly gridItemGutter: "var(--ds-space-400)";
|
|
36
|
+
readonly gridMargin: "var(--ds-space-400)";
|
|
37
|
+
readonly min: "90rem";
|
|
38
|
+
readonly max: "109.99rem";
|
|
39
|
+
};
|
|
40
|
+
readonly xl: {
|
|
41
|
+
readonly gridItemGutter: "var(--ds-space-400)";
|
|
42
|
+
readonly gridMargin: "var(--ds-space-500)";
|
|
43
|
+
readonly min: "110rem";
|
|
44
|
+
readonly max: null;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
10
47
|
/**
|
|
11
48
|
* The list of breakpoints in order from smallest to largest. You may need to clone and reverse this list if you want the opposite.
|
|
12
49
|
*
|
|
@@ -14,12 +51,10 @@ export declare const UNSAFE_BREAKPOINTS_CONFIG: Record<Breakpoint, BreakpointCon
|
|
|
14
51
|
*
|
|
15
52
|
* @experimental Unsafe for consumption outside of the design system itself.
|
|
16
53
|
*/
|
|
17
|
-
export declare const UNSAFE_BREAKPOINTS_ORDERED_LIST: ["xxs", "xs", "sm", "md", "lg", "xl"
|
|
54
|
+
export declare const UNSAFE_BREAKPOINTS_ORDERED_LIST: ["xxs", "xs", "sm", "md", "lg", "xl"];
|
|
18
55
|
/**
|
|
19
56
|
* This is our smallest breakpoint with a few nuances to it:
|
|
20
57
|
* 1. It is the default value for shorthands, eg. `<GridItem span={6} />` maps to `{ [SMALLEST_BREAKPOINT]: props.span }`
|
|
21
58
|
* 2. It's omitted in `media.below` as there's nothing below `0px`.
|
|
22
|
-
*
|
|
23
|
-
* @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.
|
|
24
59
|
*/
|
|
25
60
|
export declare const SMALLEST_BREAKPOINT: "xxs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { UNSAFE_media } from './media-helper';
|
|
2
|
-
export { UNSAFE_buildAboveMediaQueryCSS
|
|
1
|
+
export { media, UNSAFE_media } from './media-helper';
|
|
2
|
+
export { UNSAFE_buildAboveMediaQueryCSS } from './build-media-query-css';
|
|
3
3
|
export { UNSAFE_BREAKPOINTS_ORDERED_LIST, UNSAFE_BREAKPOINTS_CONFIG, } from './constants';
|
|
4
4
|
export type { Breakpoint, ResponsiveObject, ResponsiveCSSObject, } from './types';
|
|
5
5
|
export { UNSAFE_useMediaQuery } from './use-media-query';
|
|
@@ -1,45 +1,75 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @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.
|
|
5
5
|
*/
|
|
6
6
|
export declare const UNSAFE_media: {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A media query to target viewports above the min width of a given breakpoint.
|
|
9
|
+
* Note that `media.above.xs` is redundant and should not be used, but it's included for programatic purposes.
|
|
10
|
+
*/
|
|
11
|
+
above: {
|
|
8
12
|
/**
|
|
9
13
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
10
|
-
*
|
|
11
|
-
* Eg. this is `@media (min-width: 0px)`
|
|
12
14
|
*/
|
|
13
|
-
readonly xxs:
|
|
14
|
-
readonly xs:
|
|
15
|
-
readonly sm:
|
|
16
|
-
readonly md:
|
|
17
|
-
readonly lg:
|
|
18
|
-
readonly xl:
|
|
19
|
-
readonly xxl: `@media (min-width: ${number}rem)`;
|
|
15
|
+
readonly xxs: "@media all";
|
|
16
|
+
readonly xs: "@media (min-width: 30rem)";
|
|
17
|
+
readonly sm: "@media (min-width: 48rem)";
|
|
18
|
+
readonly md: "@media (min-width: 64rem)";
|
|
19
|
+
readonly lg: "@media (min-width: 90rem)";
|
|
20
|
+
readonly xl: "@media (min-width: 110rem)";
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 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…
|
|
24
|
+
*
|
|
25
|
+
* 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',`
|
|
26
|
+
*
|
|
27
|
+
* 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.
|
|
28
|
+
* This is well describe in this: @see https://stackoverflow.com/a/13649011
|
|
29
|
+
*
|
|
30
|
+
* 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/
|
|
31
|
+
*
|
|
32
|
+
* @internal Not intended to be used outside of DST at this stage.
|
|
33
|
+
* @experimental Not intended to be used outside of DST at this stage.
|
|
34
|
+
*/
|
|
35
|
+
below: {
|
|
36
|
+
readonly xs: "@media not all and (min-width: 30rem)";
|
|
37
|
+
readonly sm: "@media not all and (min-width: 48rem)";
|
|
38
|
+
readonly md: "@media not all and (min-width: 64rem)";
|
|
39
|
+
readonly lg: "@media not all and (min-width: 90rem)";
|
|
40
|
+
readonly xl: "@media not all and (min-width: 110rem)";
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A media query to target viewports exactly between the min and max of a given breakpoint.
|
|
44
|
+
* 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/
|
|
45
|
+
*
|
|
46
|
+
* @internal Not intended to be used outside of DST at this stage.
|
|
47
|
+
* @experimental Not intended to be used outside of DST at this stage.
|
|
48
|
+
*/
|
|
49
|
+
only: {
|
|
50
|
+
readonly xxs: "@media (min-width: 0rem) and (max-width: 29.99rem)";
|
|
51
|
+
readonly xs: "@media (min-width: 30rem) and (max-width: 47.99rem)";
|
|
52
|
+
readonly sm: "@media (min-width: 48rem) and (max-width: 63.99rem)";
|
|
53
|
+
readonly md: "@media (min-width: 64rem) and (max-width: 89.99rem)";
|
|
54
|
+
readonly lg: "@media (min-width: 90rem) and (max-width: 109.99rem)";
|
|
55
|
+
readonly xl: "@media (min-width: 110rem)";
|
|
32
56
|
};
|
|
33
57
|
};
|
|
34
58
|
/**
|
|
35
|
-
*
|
|
36
|
-
* ```
|
|
37
|
-
* type MediaQuery = `@media (${string})`;
|
|
38
|
-
* type ResponsiveMediaObject = Record<Breakpoint, MediaQuery>;
|
|
39
|
-
* ```
|
|
59
|
+
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
40
60
|
*
|
|
41
|
-
*
|
|
42
|
-
* ```
|
|
43
|
-
* const UNSAFE_media = { … } satisfies Record<'above' | 'only', ResponsiveMediaObject> & { below: Omit<ResponsiveMediaObject, 'xxs'> }
|
|
44
|
-
* ```
|
|
61
|
+
* We strictly only export `media.above` at this stage as we want makers to build mobile-first.
|
|
45
62
|
*/
|
|
63
|
+
export declare const media: {
|
|
64
|
+
readonly above: {
|
|
65
|
+
/**
|
|
66
|
+
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
67
|
+
*/
|
|
68
|
+
readonly xxs: "@media all";
|
|
69
|
+
readonly xs: "@media (min-width: 30rem)";
|
|
70
|
+
readonly sm: "@media (min-width: 48rem)";
|
|
71
|
+
readonly md: "@media (min-width: 64rem)";
|
|
72
|
+
readonly lg: "@media (min-width: 90rem)";
|
|
73
|
+
readonly xl: "@media (min-width: 110rem)";
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
|
2
2
|
import { token } from '@atlaskit/tokens';
|
|
3
|
-
import {
|
|
3
|
+
import { media } from './media-helper';
|
|
4
4
|
/**
|
|
5
5
|
* The breakpoints we have for responsiveness.
|
|
6
6
|
*/
|
|
7
|
-
export type Breakpoint = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
8
|
-
|
|
7
|
+
export type Breakpoint = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
/**
|
|
9
|
+
* All supported media queries for use as keys, eg. in `xcss({ [MediaQuery]: { … } })`
|
|
10
|
+
*
|
|
11
|
+
* TODO: Should this have `media.above.xxs`? This is explicitly `@media all`, which I believe is just additional specificity (which could lead to some mistakes)
|
|
12
|
+
*/
|
|
13
|
+
export type MediaQuery = (typeof media.above)[Breakpoint];
|
|
9
14
|
/**
|
|
10
15
|
* An object type mapping a value to each breakpoint (optionally)
|
|
11
16
|
*/
|
|
@@ -43,12 +48,7 @@ export type BreakpointConfig = {
|
|
|
43
48
|
*/
|
|
44
49
|
min: `${number}rem`;
|
|
45
50
|
/**
|
|
46
|
-
* The max-width used in media queries
|
|
47
|
-
*/
|
|
48
|
-
max: `${number}rem`;
|
|
49
|
-
/**
|
|
50
|
-
* To ensure min-width and max-width do both target at the same time, we subtract a value.
|
|
51
|
-
* 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…"
|
|
51
|
+
* The max-width used in media queries; if set to `null`, it has no max-width (should strictly only be on the largest breakpoint).
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
max: `${number}rem` | null;
|
|
54
54
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UNSAFE_media
|
|
2
|
-
type NestedQueryString = `above.${keyof typeof
|
|
1
|
+
import { UNSAFE_media } from './media-helper';
|
|
2
|
+
type NestedQueryString = `above.${keyof typeof UNSAFE_media.above}` | `below.${keyof typeof UNSAFE_media.below}`;
|
|
3
3
|
/**
|
|
4
4
|
* A hook which returnes a `window.matchMedia` result to help you build responsively around breakpoints in JavaScript.
|
|
5
5
|
*
|
|
@@ -66,11 +66,11 @@ export type Space = keyof typeof spaceMap;
|
|
|
66
66
|
*/
|
|
67
67
|
/**
|
|
68
68
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
69
|
-
* @codegen <<SignedSource::
|
|
69
|
+
* @codegen <<SignedSource::80db0ba91b44837306516b95e9cf080e>>
|
|
70
70
|
* @codegenId colors
|
|
71
71
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
72
72
|
* @codegenParams ["border", "background", "shadow", "text", "fill"]
|
|
73
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
73
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::c829bed8504655cd09b971d338d7f3a1>>
|
|
74
74
|
*/
|
|
75
75
|
export declare const borderColorMap: {
|
|
76
76
|
readonly 'color.border': "var(--ds-border)";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CSSObject } from '@emotion/react';
|
|
2
|
-
import { SMALLEST_BREAKPOINT } from './constants';
|
|
3
2
|
import type { Breakpoint } from './types';
|
|
4
3
|
/**
|
|
5
4
|
* Build a map of breakpoints to css with media queries and nested styles.
|
|
@@ -26,32 +25,3 @@ import type { Breakpoint } from './types';
|
|
|
26
25
|
* ```
|
|
27
26
|
*/
|
|
28
27
|
export declare const UNSAFE_buildAboveMediaQueryCSS: (input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
29
|
-
/**
|
|
30
|
-
* Build a map of breakpoints to css with media queries and nested styles.
|
|
31
|
-
*
|
|
32
|
-
* WARNING: The smallest breakpoint is not a valid key as a media query below 0px is misleading.
|
|
33
|
-
* This is separated from `buildAboveMediaQueryCSS` for that specific reason, you cannot have type safety with this variance.
|
|
34
|
-
*
|
|
35
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* A map to build optional `display:none` for consumption on a div.
|
|
39
|
-
* ```ts
|
|
40
|
-
* const hideMediaQueries = buildBelowMediaQueryCSS({ display: 'none' });
|
|
41
|
-
*
|
|
42
|
-
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
43
|
-
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* This roughly builds a map that will look roughly like this (if done manually):
|
|
48
|
-
* ```ts
|
|
49
|
-
* {
|
|
50
|
-
* xs: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
51
|
-
* sm: css({ '@media (max-width: …px)': { display: 'none' } }),
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
56
|
-
*/
|
|
57
|
-
export declare const UNSAFE_buildBelowMediaQueryCSS: (input: CSSObject | ((breakpoint: Exclude<Breakpoint, typeof SMALLEST_BREAKPOINT>) => CSSObject)) => Required<Omit<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>, "xxs">>;
|
|
@@ -1,12 +1,49 @@
|
|
|
1
|
-
import type { Breakpoint, BreakpointConfig } from './types';
|
|
2
1
|
/**
|
|
3
2
|
* Our internal configuration for breakpoints configuration.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
4
|
+
* 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.
|
|
5
|
+
* @see: https://tzi.fr/css/prevent-double-breakpoint/
|
|
6
6
|
*
|
|
7
|
-
* @experimental Unsafe for consumption outside of the design system itself.
|
|
7
|
+
* @experimental Unsafe for direct consumption outside of the design system itself; please use our `media` export instead for media queries.
|
|
8
8
|
*/
|
|
9
|
-
export declare const UNSAFE_BREAKPOINTS_CONFIG:
|
|
9
|
+
export declare const UNSAFE_BREAKPOINTS_CONFIG: {
|
|
10
|
+
readonly xxs: {
|
|
11
|
+
readonly gridItemGutter: "var(--ds-space-200)";
|
|
12
|
+
readonly gridMargin: "var(--ds-space-200)";
|
|
13
|
+
readonly min: "0rem";
|
|
14
|
+
readonly max: "29.99rem";
|
|
15
|
+
};
|
|
16
|
+
readonly xs: {
|
|
17
|
+
readonly gridItemGutter: "var(--ds-space-200)";
|
|
18
|
+
readonly gridMargin: "var(--ds-space-200)";
|
|
19
|
+
readonly min: "30rem";
|
|
20
|
+
readonly max: "47.99rem";
|
|
21
|
+
};
|
|
22
|
+
readonly sm: {
|
|
23
|
+
readonly gridItemGutter: "var(--ds-space-200)";
|
|
24
|
+
readonly gridMargin: "var(--ds-space-300)";
|
|
25
|
+
readonly min: "48rem";
|
|
26
|
+
readonly max: "63.99rem";
|
|
27
|
+
};
|
|
28
|
+
readonly md: {
|
|
29
|
+
readonly gridItemGutter: "var(--ds-space-300)";
|
|
30
|
+
readonly gridMargin: "var(--ds-space-400)";
|
|
31
|
+
readonly min: "64rem";
|
|
32
|
+
readonly max: "89.99rem";
|
|
33
|
+
};
|
|
34
|
+
readonly lg: {
|
|
35
|
+
readonly gridItemGutter: "var(--ds-space-400)";
|
|
36
|
+
readonly gridMargin: "var(--ds-space-400)";
|
|
37
|
+
readonly min: "90rem";
|
|
38
|
+
readonly max: "109.99rem";
|
|
39
|
+
};
|
|
40
|
+
readonly xl: {
|
|
41
|
+
readonly gridItemGutter: "var(--ds-space-400)";
|
|
42
|
+
readonly gridMargin: "var(--ds-space-500)";
|
|
43
|
+
readonly min: "110rem";
|
|
44
|
+
readonly max: null;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
10
47
|
/**
|
|
11
48
|
* The list of breakpoints in order from smallest to largest. You may need to clone and reverse this list if you want the opposite.
|
|
12
49
|
*
|
|
@@ -20,14 +57,11 @@ export declare const UNSAFE_BREAKPOINTS_ORDERED_LIST: [
|
|
|
20
57
|
"sm",
|
|
21
58
|
"md",
|
|
22
59
|
"lg",
|
|
23
|
-
"xl"
|
|
24
|
-
"xxl"
|
|
60
|
+
"xl"
|
|
25
61
|
];
|
|
26
62
|
/**
|
|
27
63
|
* This is our smallest breakpoint with a few nuances to it:
|
|
28
64
|
* 1. It is the default value for shorthands, eg. `<GridItem span={6} />` maps to `{ [SMALLEST_BREAKPOINT]: props.span }`
|
|
29
65
|
* 2. It's omitted in `media.below` as there's nothing below `0px`.
|
|
30
|
-
*
|
|
31
|
-
* @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.
|
|
32
66
|
*/
|
|
33
67
|
export declare const SMALLEST_BREAKPOINT: "xxs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { UNSAFE_media } from './media-helper';
|
|
2
|
-
export { UNSAFE_buildAboveMediaQueryCSS
|
|
1
|
+
export { media, UNSAFE_media } from './media-helper';
|
|
2
|
+
export { UNSAFE_buildAboveMediaQueryCSS } from './build-media-query-css';
|
|
3
3
|
export { UNSAFE_BREAKPOINTS_ORDERED_LIST, UNSAFE_BREAKPOINTS_CONFIG, } from './constants';
|
|
4
4
|
export type { Breakpoint, ResponsiveObject, ResponsiveCSSObject, } from './types';
|
|
5
5
|
export { UNSAFE_useMediaQuery } from './use-media-query';
|
|
@@ -1,45 +1,75 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @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.
|
|
5
5
|
*/
|
|
6
6
|
export declare const UNSAFE_media: {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A media query to target viewports above the min width of a given breakpoint.
|
|
9
|
+
* Note that `media.above.xs` is redundant and should not be used, but it's included for programatic purposes.
|
|
10
|
+
*/
|
|
11
|
+
above: {
|
|
8
12
|
/**
|
|
9
13
|
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
10
|
-
*
|
|
11
|
-
* Eg. this is `@media (min-width: 0px)`
|
|
12
14
|
*/
|
|
13
|
-
readonly xxs:
|
|
14
|
-
readonly xs:
|
|
15
|
-
readonly sm:
|
|
16
|
-
readonly md:
|
|
17
|
-
readonly lg:
|
|
18
|
-
readonly xl:
|
|
19
|
-
readonly xxl: `@media (min-width: ${number}rem)`;
|
|
15
|
+
readonly xxs: "@media all";
|
|
16
|
+
readonly xs: "@media (min-width: 30rem)";
|
|
17
|
+
readonly sm: "@media (min-width: 48rem)";
|
|
18
|
+
readonly md: "@media (min-width: 64rem)";
|
|
19
|
+
readonly lg: "@media (min-width: 90rem)";
|
|
20
|
+
readonly xl: "@media (min-width: 110rem)";
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 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…
|
|
24
|
+
*
|
|
25
|
+
* 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',`
|
|
26
|
+
*
|
|
27
|
+
* 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.
|
|
28
|
+
* This is well describe in this: @see https://stackoverflow.com/a/13649011
|
|
29
|
+
*
|
|
30
|
+
* 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/
|
|
31
|
+
*
|
|
32
|
+
* @internal Not intended to be used outside of DST at this stage.
|
|
33
|
+
* @experimental Not intended to be used outside of DST at this stage.
|
|
34
|
+
*/
|
|
35
|
+
below: {
|
|
36
|
+
readonly xs: "@media not all and (min-width: 30rem)";
|
|
37
|
+
readonly sm: "@media not all and (min-width: 48rem)";
|
|
38
|
+
readonly md: "@media not all and (min-width: 64rem)";
|
|
39
|
+
readonly lg: "@media not all and (min-width: 90rem)";
|
|
40
|
+
readonly xl: "@media not all and (min-width: 110rem)";
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A media query to target viewports exactly between the min and max of a given breakpoint.
|
|
44
|
+
* 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/
|
|
45
|
+
*
|
|
46
|
+
* @internal Not intended to be used outside of DST at this stage.
|
|
47
|
+
* @experimental Not intended to be used outside of DST at this stage.
|
|
48
|
+
*/
|
|
49
|
+
only: {
|
|
50
|
+
readonly xxs: "@media (min-width: 0rem) and (max-width: 29.99rem)";
|
|
51
|
+
readonly xs: "@media (min-width: 30rem) and (max-width: 47.99rem)";
|
|
52
|
+
readonly sm: "@media (min-width: 48rem) and (max-width: 63.99rem)";
|
|
53
|
+
readonly md: "@media (min-width: 64rem) and (max-width: 89.99rem)";
|
|
54
|
+
readonly lg: "@media (min-width: 90rem) and (max-width: 109.99rem)";
|
|
55
|
+
readonly xl: "@media (min-width: 110rem)";
|
|
32
56
|
};
|
|
33
57
|
};
|
|
34
58
|
/**
|
|
35
|
-
*
|
|
36
|
-
* ```
|
|
37
|
-
* type MediaQuery = `@media (${string})`;
|
|
38
|
-
* type ResponsiveMediaObject = Record<Breakpoint, MediaQuery>;
|
|
39
|
-
* ```
|
|
59
|
+
* This is an object of usable media query helpers using our internal breakpoints configuration.
|
|
40
60
|
*
|
|
41
|
-
*
|
|
42
|
-
* ```
|
|
43
|
-
* const UNSAFE_media = { … } satisfies Record<'above' | 'only', ResponsiveMediaObject> & { below: Omit<ResponsiveMediaObject, 'xxs'> }
|
|
44
|
-
* ```
|
|
61
|
+
* We strictly only export `media.above` at this stage as we want makers to build mobile-first.
|
|
45
62
|
*/
|
|
63
|
+
export declare const media: {
|
|
64
|
+
readonly above: {
|
|
65
|
+
/**
|
|
66
|
+
* `above.xxs` is redundant and no media query should be used, but it's included for programatic purposes…
|
|
67
|
+
*/
|
|
68
|
+
readonly xxs: "@media all";
|
|
69
|
+
readonly xs: "@media (min-width: 30rem)";
|
|
70
|
+
readonly sm: "@media (min-width: 48rem)";
|
|
71
|
+
readonly md: "@media (min-width: 64rem)";
|
|
72
|
+
readonly lg: "@media (min-width: 90rem)";
|
|
73
|
+
readonly xl: "@media (min-width: 110rem)";
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
|
2
2
|
import { token } from '@atlaskit/tokens';
|
|
3
|
-
import {
|
|
3
|
+
import { media } from './media-helper';
|
|
4
4
|
/**
|
|
5
5
|
* The breakpoints we have for responsiveness.
|
|
6
6
|
*/
|
|
7
|
-
export type Breakpoint = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
8
|
-
|
|
7
|
+
export type Breakpoint = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
/**
|
|
9
|
+
* All supported media queries for use as keys, eg. in `xcss({ [MediaQuery]: { … } })`
|
|
10
|
+
*
|
|
11
|
+
* TODO: Should this have `media.above.xxs`? This is explicitly `@media all`, which I believe is just additional specificity (which could lead to some mistakes)
|
|
12
|
+
*/
|
|
13
|
+
export type MediaQuery = (typeof media.above)[Breakpoint];
|
|
9
14
|
/**
|
|
10
15
|
* An object type mapping a value to each breakpoint (optionally)
|
|
11
16
|
*/
|
|
@@ -43,12 +48,7 @@ export type BreakpointConfig = {
|
|
|
43
48
|
*/
|
|
44
49
|
min: `${number}rem`;
|
|
45
50
|
/**
|
|
46
|
-
* The max-width used in media queries
|
|
47
|
-
*/
|
|
48
|
-
max: `${number}rem`;
|
|
49
|
-
/**
|
|
50
|
-
* To ensure min-width and max-width do both target at the same time, we subtract a value.
|
|
51
|
-
* 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…"
|
|
51
|
+
* The max-width used in media queries; if set to `null`, it has no max-width (should strictly only be on the largest breakpoint).
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
max: `${number}rem` | null;
|
|
54
54
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UNSAFE_media
|
|
2
|
-
type NestedQueryString = `above.${keyof typeof
|
|
1
|
+
import { UNSAFE_media } from './media-helper';
|
|
2
|
+
type NestedQueryString = `above.${keyof typeof UNSAFE_media.above}` | `below.${keyof typeof UNSAFE_media.below}`;
|
|
3
3
|
/**
|
|
4
4
|
* A hook which returnes a `window.matchMedia` result to help you build responsively around breakpoints in JavaScript.
|
|
5
5
|
*
|
|
@@ -66,11 +66,11 @@ export type Space = keyof typeof spaceMap;
|
|
|
66
66
|
*/
|
|
67
67
|
/**
|
|
68
68
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
69
|
-
* @codegen <<SignedSource::
|
|
69
|
+
* @codegen <<SignedSource::80db0ba91b44837306516b95e9cf080e>>
|
|
70
70
|
* @codegenId colors
|
|
71
71
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
72
72
|
* @codegenParams ["border", "background", "shadow", "text", "fill"]
|
|
73
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
73
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::c829bed8504655cd09b971d338d7f3a1>>
|
|
74
74
|
*/
|
|
75
75
|
export declare const borderColorMap: {
|
|
76
76
|
readonly 'color.border': "var(--ds-border)";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -64,6 +64,15 @@
|
|
|
64
64
|
"status": {
|
|
65
65
|
"type": "closed-beta"
|
|
66
66
|
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"title": "Responsive",
|
|
70
|
+
"folder": "responsive",
|
|
71
|
+
"slug": "primitives/responsive",
|
|
72
|
+
"id": "@atlaskit/primitives/responsive",
|
|
73
|
+
"status": {
|
|
74
|
+
"type": "alpha"
|
|
75
|
+
}
|
|
67
76
|
}
|
|
68
77
|
]
|
|
69
78
|
}
|
|
@@ -94,7 +103,7 @@
|
|
|
94
103
|
},
|
|
95
104
|
"dependencies": {
|
|
96
105
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
97
|
-
"@atlaskit/tokens": "^1.
|
|
106
|
+
"@atlaskit/tokens": "^1.9.0",
|
|
98
107
|
"@babel/runtime": "^7.0.0",
|
|
99
108
|
"@emotion/react": "^11.7.1",
|
|
100
109
|
"@emotion/serialize": "^1.1.0",
|
|
@@ -123,7 +132,7 @@
|
|
|
123
132
|
"@atlaskit/visual-regression": "*",
|
|
124
133
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
125
134
|
"@atlassian/codegen": "^0.1.0",
|
|
126
|
-
"@atlassian/gemini-visual-regression": "^0.0.
|
|
135
|
+
"@atlassian/gemini-visual-regression": "^0.0.31",
|
|
127
136
|
"@testing-library/react": "^12.1.5",
|
|
128
137
|
"@testing-library/react-hooks": "^8.0.1",
|
|
129
138
|
"csstype": "^3.1.0",
|
package/report.api.md
CHANGED
|
@@ -324,7 +324,7 @@ type BoxXCSS = {
|
|
|
324
324
|
};
|
|
325
325
|
|
|
326
326
|
// @public
|
|
327
|
-
type Breakpoint = 'lg' | 'md' | 'sm' | 'xl' | 'xs' | '
|
|
327
|
+
type Breakpoint = 'lg' | 'md' | 'sm' | 'xl' | 'xs' | 'xxs';
|
|
328
328
|
|
|
329
329
|
// @public (undocumented)
|
|
330
330
|
type CSSMediaQueries = {
|
|
@@ -523,10 +523,20 @@ type MaxInlineSize = Dimension;
|
|
|
523
523
|
// @public (undocumented)
|
|
524
524
|
type MaxWidth = Dimension;
|
|
525
525
|
|
|
526
|
-
// @public
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
526
|
+
// @public
|
|
527
|
+
const media: {
|
|
528
|
+
readonly above: {
|
|
529
|
+
readonly xxs: '@media all';
|
|
530
|
+
readonly xs: '@media (min-width: 30rem)';
|
|
531
|
+
readonly sm: '@media (min-width: 48rem)';
|
|
532
|
+
readonly md: '@media (min-width: 64rem)';
|
|
533
|
+
readonly lg: '@media (min-width: 90rem)';
|
|
534
|
+
readonly xl: '@media (min-width: 110rem)';
|
|
535
|
+
};
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
// @public
|
|
539
|
+
type MediaQuery = (typeof media.above)[Breakpoint];
|
|
530
540
|
|
|
531
541
|
// @public (undocumented)
|
|
532
542
|
type MinBlockSize = Dimension;
|
|
@@ -798,27 +808,6 @@ type Top = Dimension;
|
|
|
798
808
|
// @public (undocumented)
|
|
799
809
|
const uniqueSymbol: unique symbol;
|
|
800
810
|
|
|
801
|
-
// @public
|
|
802
|
-
const UNSAFE_media: {
|
|
803
|
-
readonly above: {
|
|
804
|
-
readonly xxs: `@media (min-width: ${number}rem)`;
|
|
805
|
-
readonly xs: `@media (min-width: ${number}rem)`;
|
|
806
|
-
readonly sm: `@media (min-width: ${number}rem)`;
|
|
807
|
-
readonly md: `@media (min-width: ${number}rem)`;
|
|
808
|
-
readonly lg: `@media (min-width: ${number}rem)`;
|
|
809
|
-
readonly xl: `@media (min-width: ${number}rem)`;
|
|
810
|
-
readonly xxl: `@media (min-width: ${number}rem)`;
|
|
811
|
-
};
|
|
812
|
-
readonly below: {
|
|
813
|
-
readonly xs: `@media (max-width: ${number}rem)`;
|
|
814
|
-
readonly sm: `@media (max-width: ${number}rem)`;
|
|
815
|
-
readonly md: `@media (max-width: ${number}rem)`;
|
|
816
|
-
readonly lg: `@media (max-width: ${number}rem)`;
|
|
817
|
-
readonly xl: `@media (max-width: ${number}rem)`;
|
|
818
|
-
readonly xxl: `@media (max-width: ${number}rem)`;
|
|
819
|
-
};
|
|
820
|
-
};
|
|
821
|
-
|
|
822
811
|
// @public (undocumented)
|
|
823
812
|
type Width = Dimension;
|
|
824
813
|
|