@atlaskit/primitives 0.14.3 → 0.15.1
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 +17 -0
- package/constellation/responsive/examples.mdx +51 -0
- package/constellation/responsive/usage.mdx +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{helpers/responsive → responsive}/build-media-query-css.js +41 -6
- package/dist/cjs/responsive/hide.js +35 -0
- package/dist/cjs/{helpers/responsive → responsive}/index.js +15 -1
- package/dist/cjs/responsive/show.js +38 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/xcss/style-maps.partial.js +2 -2
- package/dist/cjs/xcss/xcss.js +2 -2
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/responsive/build-media-query-css.js +76 -0
- package/dist/es2019/responsive/hide.js +28 -0
- package/dist/es2019/{helpers/responsive → responsive}/index.js +3 -1
- package/dist/es2019/responsive/show.js +31 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/xcss/style-maps.partial.js +2 -2
- package/dist/es2019/xcss/xcss.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/{helpers/responsive → responsive}/build-media-query-css.js +39 -5
- package/dist/esm/responsive/hide.js +28 -0
- package/dist/esm/{helpers/responsive → responsive}/index.js +3 -1
- package/dist/esm/responsive/show.js +31 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/xcss/style-maps.partial.js +2 -2
- package/dist/esm/xcss/xcss.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/responsive/build-media-query-css.d.ts +53 -0
- package/dist/types/responsive/hide.d.ts +39 -0
- package/dist/types/{helpers/responsive → responsive}/index.d.ts +2 -0
- package/dist/types/responsive/show.d.ts +39 -0
- package/dist/types/xcss/style-maps.partial.d.ts +2 -2
- package/dist/types/xcss/xcss.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/responsive/build-media-query-css.d.ts +53 -0
- package/dist/types-ts4.5/responsive/hide.d.ts +39 -0
- package/dist/types-ts4.5/{helpers/responsive → responsive}/index.d.ts +2 -0
- package/dist/types-ts4.5/responsive/show.d.ts +39 -0
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +2 -2
- package/dist/types-ts4.5/xcss/xcss.d.ts +1 -1
- package/package.json +3 -3
- package/responsive/package.json +5 -5
- package/dist/es2019/helpers/responsive/build-media-query-css.js +0 -36
- package/dist/types/helpers/responsive/build-media-query-css.d.ts +0 -27
- package/dist/types-ts4.5/helpers/responsive/build-media-query-css.d.ts +0 -27
- /package/dist/cjs/{helpers/responsive → responsive}/constants.js +0 -0
- /package/dist/cjs/{helpers/responsive → responsive}/media-helper.js +0 -0
- /package/dist/cjs/{helpers/responsive → responsive}/types.js +0 -0
- /package/dist/cjs/{helpers/responsive → responsive}/use-media-query.js +0 -0
- /package/dist/es2019/{helpers/responsive → responsive}/constants.js +0 -0
- /package/dist/es2019/{helpers/responsive → responsive}/media-helper.js +0 -0
- /package/dist/es2019/{helpers/responsive → responsive}/types.js +0 -0
- /package/dist/es2019/{helpers/responsive → responsive}/use-media-query.js +0 -0
- /package/dist/esm/{helpers/responsive → responsive}/constants.js +0 -0
- /package/dist/esm/{helpers/responsive → responsive}/media-helper.js +0 -0
- /package/dist/esm/{helpers/responsive → responsive}/types.js +0 -0
- /package/dist/esm/{helpers/responsive → responsive}/use-media-query.js +0 -0
- /package/dist/types/{helpers/responsive → responsive}/constants.d.ts +0 -0
- /package/dist/types/{helpers/responsive → responsive}/media-helper.d.ts +0 -0
- /package/dist/types/{helpers/responsive → responsive}/types.d.ts +0 -0
- /package/dist/types/{helpers/responsive → responsive}/use-media-query.d.ts +0 -0
- /package/dist/types-ts4.5/{helpers/responsive → responsive}/constants.d.ts +0 -0
- /package/dist/types-ts4.5/{helpers/responsive → responsive}/media-helper.d.ts +0 -0
- /package/dist/types-ts4.5/{helpers/responsive → responsive}/types.d.ts +0 -0
- /package/dist/types-ts4.5/{helpers/responsive → responsive}/use-media-query.d.ts +0 -0
|
@@ -23,10 +23,10 @@ export var dimensionMap = {
|
|
|
23
23
|
*/
|
|
24
24
|
/**
|
|
25
25
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
26
|
-
* @codegen <<SignedSource::
|
|
26
|
+
* @codegen <<SignedSource::429dca3ce1fa6d723cb98e2468802267>>
|
|
27
27
|
* @codegenId spacing
|
|
28
28
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
29
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::
|
|
29
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::68f6bde7e6b186964ee53458284bbb90>>
|
|
30
30
|
*/
|
|
31
31
|
export var spaceMap = {
|
|
32
32
|
'space.0': "var(--ds-space-0, 0px)",
|
package/dist/esm/xcss/xcss.js
CHANGED
|
@@ -4,7 +4,7 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
4
4
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
5
5
|
import { css as cssEmotion } from '@emotion/react';
|
|
6
6
|
import warnOnce from '@atlaskit/ds-lib/warn-once';
|
|
7
|
-
import { media } from '../
|
|
7
|
+
import { media } from '../responsive/media-helper';
|
|
8
8
|
import { backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
|
|
9
9
|
var tokensMap = {
|
|
10
10
|
backgroundColor: backgroundColorMap,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { default as Box, type BoxProps } from './components/box';
|
|
|
2
2
|
export { default as Inline, type InlineProps } from './components/inline';
|
|
3
3
|
export { xcss } from './xcss/xcss';
|
|
4
4
|
export { default as Stack, type StackProps } from './components/stack';
|
|
5
|
-
export { UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG, type Breakpoint, } from './
|
|
5
|
+
export { UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG, type Breakpoint, } from './responsive';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CSSObject } from '@emotion/react';
|
|
2
|
+
import type { Breakpoint } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Build a map of breakpoints to css with media queries and nested styles.
|
|
5
|
+
*
|
|
6
|
+
* @internal Not intended to be used outside of DST at this stage.
|
|
7
|
+
* @experimental Not intended to be used outside of DST at this stage.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* A map to build optional `display:none` for consumption on a div.
|
|
11
|
+
* ```ts
|
|
12
|
+
* const hideMediaQueries = buildAboveMediaQueryCSS({ display: 'none' });
|
|
13
|
+
*
|
|
14
|
+
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
15
|
+
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* This roughly builds a map that will look roughly like this (if done manually):
|
|
20
|
+
* ```ts
|
|
21
|
+
* {
|
|
22
|
+
* xxs: css({ '@media all': { display: 'none' } }),
|
|
23
|
+
* xs: css({ '@media (min-width: 30rem)': { display: 'none' } }),
|
|
24
|
+
* sm: css({ '@media (min-width: 48rem)': { display: 'none' } }),
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
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
|
+
* @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
|
+
* @example
|
|
36
|
+
* A map to build optional `display:none` for consumption on a div.
|
|
37
|
+
* ```ts
|
|
38
|
+
* const hideMediaQueries = buildBelowMediaQueryCSS({ display: 'none' });
|
|
39
|
+
*
|
|
40
|
+
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
41
|
+
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* This roughly builds a map that will look roughly like this (if done manually):
|
|
46
|
+
* ```ts
|
|
47
|
+
* {
|
|
48
|
+
* xs: css({ '@media not all and (min-width: 30rem)': { display: 'none' } }),
|
|
49
|
+
* sm: css({ '@media not all and (min-width: 48rem)': { display: 'none' } }),
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const UNSAFE_buildBelowMediaQueryCSS: (input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { Breakpoint } from './types';
|
|
5
|
+
type As = 'article' | 'aside' | 'dialog' | 'div' | 'footer' | 'header' | 'li' | 'main' | 'nav' | 'ol' | 'section' | 'span' | 'ul';
|
|
6
|
+
type ResponsiveHideProps = {
|
|
7
|
+
as?: As;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Apply CSS to hide this specifically **above** this breakpoint.
|
|
11
|
+
* The smallest breakpoint is not included as it would always be shown and this would not be performant.
|
|
12
|
+
*
|
|
13
|
+
* @important do not mix `above` and `below` (TypeScript should prevent this)
|
|
14
|
+
*/
|
|
15
|
+
above?: Exclude<Breakpoint, 'xxs'>;
|
|
16
|
+
/**
|
|
17
|
+
* Apply CSS to hide this specifically **below** this breakpoint.
|
|
18
|
+
* The smallest breakpoint is not included as it would never be shown and this would not be performant.
|
|
19
|
+
*
|
|
20
|
+
* @important do not mix `above` and `below` (TypeScript should prevent this)
|
|
21
|
+
*/
|
|
22
|
+
below?: Exclude<Breakpoint, 'xxs'>;
|
|
23
|
+
} & ({
|
|
24
|
+
above?: never;
|
|
25
|
+
below: Exclude<Breakpoint, 'xxs'>;
|
|
26
|
+
} | {
|
|
27
|
+
above: Exclude<Breakpoint, 'xxs'>;
|
|
28
|
+
below?: never;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Hides the content at a given breakpoint. By default, content is shown. The primary use case is for visual presentation.
|
|
32
|
+
* Mix `<Hide above="md">` with `<Show above="md">` to achieve content that shifts at a breakpoint.
|
|
33
|
+
*
|
|
34
|
+
* Please note:
|
|
35
|
+
* - This only uses `display: none` hide, it does not skip rendering of children trees.
|
|
36
|
+
* - As this is rendered at all times, there is little performance savings here (just that this is not painted).
|
|
37
|
+
*/
|
|
38
|
+
export declare const Hide: ({ above, below, children, as: AsElement, }: ResponsiveHideProps) => jsx.JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -3,3 +3,5 @@ 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';
|
|
6
|
+
export { Show } from './show';
|
|
7
|
+
export { Hide } from './hide';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { Breakpoint } from './types';
|
|
5
|
+
type As = 'article' | 'aside' | 'dialog' | 'div' | 'footer' | 'header' | 'li' | 'main' | 'nav' | 'ol' | 'section' | 'span' | 'ul';
|
|
6
|
+
type ResponsiveShowProps = {
|
|
7
|
+
as?: As;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Apply CSS to show this specifically **above** this breakpoint.
|
|
11
|
+
* The smallest breakpoint is not included as it would always be shown and this would not be performant.
|
|
12
|
+
*
|
|
13
|
+
* @important do not mix `above` and `below` (TypeScript should prevent this)
|
|
14
|
+
*/
|
|
15
|
+
above?: Exclude<Breakpoint, 'xxs'>;
|
|
16
|
+
/**
|
|
17
|
+
* Apply CSS to show this specifically **below** this breakpoint.
|
|
18
|
+
* The smallest breakpoint is not included as it would never be shown and this would not be performant.
|
|
19
|
+
*
|
|
20
|
+
* @important do not mix `above` and `below` (TypeScript should prevent this)
|
|
21
|
+
*/
|
|
22
|
+
below?: Exclude<Breakpoint, 'xxs'>;
|
|
23
|
+
} & ({
|
|
24
|
+
above?: never;
|
|
25
|
+
below: Exclude<Breakpoint, 'xxs'>;
|
|
26
|
+
} | {
|
|
27
|
+
above: Exclude<Breakpoint, 'xxs'>;
|
|
28
|
+
below?: never;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Shows the content at a given breakpoint. By default, content is hidden. The primary use case is for visual presentation.
|
|
32
|
+
* Mix `<Show above="md">` with `<Hide above="md">` to achieve content that shifts at a breakpoint.
|
|
33
|
+
*
|
|
34
|
+
* Please note:
|
|
35
|
+
* - This only uses `display: none` and `display: revert` to show/hide, it does not skip rendering of children trees.
|
|
36
|
+
* - As this is rendered at all times, there is little performance savings here (just that this is not painted).
|
|
37
|
+
*/
|
|
38
|
+
export declare const Show: ({ above, below, children, as: AsElement, }: ResponsiveShowProps) => jsx.JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -23,10 +23,10 @@ export type Dimension = keyof typeof dimensionMap;
|
|
|
23
23
|
*/
|
|
24
24
|
/**
|
|
25
25
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
26
|
-
* @codegen <<SignedSource::
|
|
26
|
+
* @codegen <<SignedSource::429dca3ce1fa6d723cb98e2468802267>>
|
|
27
27
|
* @codegenId spacing
|
|
28
28
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
29
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::
|
|
29
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::68f6bde7e6b186964ee53458284bbb90>>
|
|
30
30
|
*/
|
|
31
31
|
export declare const spaceMap: {
|
|
32
32
|
'space.0': "var(--ds-space-0)";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { css as cssEmotion } from '@emotion/react';
|
|
3
3
|
import { CSSPropertiesWithMultiValues, SerializedStyles } from '@emotion/serialize';
|
|
4
4
|
import type * as CSS from 'csstype';
|
|
5
|
-
import { MediaQuery } from '../helpers/responsive/types';
|
|
6
5
|
import { Box, Inline } from '../index';
|
|
6
|
+
import type { MediaQuery } from '../responsive/types';
|
|
7
7
|
import { TokenisedProps } from './style-maps.partial';
|
|
8
8
|
declare const uniqueSymbol: unique symbol;
|
|
9
9
|
/**
|
|
@@ -2,4 +2,4 @@ export { default as Box, type BoxProps } from './components/box';
|
|
|
2
2
|
export { default as Inline, type InlineProps } from './components/inline';
|
|
3
3
|
export { xcss } from './xcss/xcss';
|
|
4
4
|
export { default as Stack, type StackProps } from './components/stack';
|
|
5
|
-
export { UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG, type Breakpoint, } from './
|
|
5
|
+
export { UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG, type Breakpoint, } from './responsive';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CSSObject } from '@emotion/react';
|
|
2
|
+
import type { Breakpoint } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Build a map of breakpoints to css with media queries and nested styles.
|
|
5
|
+
*
|
|
6
|
+
* @internal Not intended to be used outside of DST at this stage.
|
|
7
|
+
* @experimental Not intended to be used outside of DST at this stage.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* A map to build optional `display:none` for consumption on a div.
|
|
11
|
+
* ```ts
|
|
12
|
+
* const hideMediaQueries = buildAboveMediaQueryCSS({ display: 'none' });
|
|
13
|
+
*
|
|
14
|
+
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
15
|
+
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* This roughly builds a map that will look roughly like this (if done manually):
|
|
20
|
+
* ```ts
|
|
21
|
+
* {
|
|
22
|
+
* xxs: css({ '@media all': { display: 'none' } }),
|
|
23
|
+
* xs: css({ '@media (min-width: 30rem)': { display: 'none' } }),
|
|
24
|
+
* sm: css({ '@media (min-width: 48rem)': { display: 'none' } }),
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
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
|
+
* @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
|
+
* @example
|
|
36
|
+
* A map to build optional `display:none` for consumption on a div.
|
|
37
|
+
* ```ts
|
|
38
|
+
* const hideMediaQueries = buildBelowMediaQueryCSS({ display: 'none' });
|
|
39
|
+
*
|
|
40
|
+
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
41
|
+
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* This roughly builds a map that will look roughly like this (if done manually):
|
|
46
|
+
* ```ts
|
|
47
|
+
* {
|
|
48
|
+
* xs: css({ '@media not all and (min-width: 30rem)': { display: 'none' } }),
|
|
49
|
+
* sm: css({ '@media not all and (min-width: 48rem)': { display: 'none' } }),
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const UNSAFE_buildBelowMediaQueryCSS: (input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { Breakpoint } from './types';
|
|
5
|
+
type As = 'article' | 'aside' | 'dialog' | 'div' | 'footer' | 'header' | 'li' | 'main' | 'nav' | 'ol' | 'section' | 'span' | 'ul';
|
|
6
|
+
type ResponsiveHideProps = {
|
|
7
|
+
as?: As;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Apply CSS to hide this specifically **above** this breakpoint.
|
|
11
|
+
* The smallest breakpoint is not included as it would always be shown and this would not be performant.
|
|
12
|
+
*
|
|
13
|
+
* @important do not mix `above` and `below` (TypeScript should prevent this)
|
|
14
|
+
*/
|
|
15
|
+
above?: Exclude<Breakpoint, 'xxs'>;
|
|
16
|
+
/**
|
|
17
|
+
* Apply CSS to hide this specifically **below** this breakpoint.
|
|
18
|
+
* The smallest breakpoint is not included as it would never be shown and this would not be performant.
|
|
19
|
+
*
|
|
20
|
+
* @important do not mix `above` and `below` (TypeScript should prevent this)
|
|
21
|
+
*/
|
|
22
|
+
below?: Exclude<Breakpoint, 'xxs'>;
|
|
23
|
+
} & ({
|
|
24
|
+
above?: never;
|
|
25
|
+
below: Exclude<Breakpoint, 'xxs'>;
|
|
26
|
+
} | {
|
|
27
|
+
above: Exclude<Breakpoint, 'xxs'>;
|
|
28
|
+
below?: never;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Hides the content at a given breakpoint. By default, content is shown. The primary use case is for visual presentation.
|
|
32
|
+
* Mix `<Hide above="md">` with `<Show above="md">` to achieve content that shifts at a breakpoint.
|
|
33
|
+
*
|
|
34
|
+
* Please note:
|
|
35
|
+
* - This only uses `display: none` hide, it does not skip rendering of children trees.
|
|
36
|
+
* - As this is rendered at all times, there is little performance savings here (just that this is not painted).
|
|
37
|
+
*/
|
|
38
|
+
export declare const Hide: ({ above, below, children, as: AsElement, }: ResponsiveHideProps) => jsx.JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -3,3 +3,5 @@ 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';
|
|
6
|
+
export { Show } from './show';
|
|
7
|
+
export { Hide } from './hide';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { Breakpoint } from './types';
|
|
5
|
+
type As = 'article' | 'aside' | 'dialog' | 'div' | 'footer' | 'header' | 'li' | 'main' | 'nav' | 'ol' | 'section' | 'span' | 'ul';
|
|
6
|
+
type ResponsiveShowProps = {
|
|
7
|
+
as?: As;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Apply CSS to show this specifically **above** this breakpoint.
|
|
11
|
+
* The smallest breakpoint is not included as it would always be shown and this would not be performant.
|
|
12
|
+
*
|
|
13
|
+
* @important do not mix `above` and `below` (TypeScript should prevent this)
|
|
14
|
+
*/
|
|
15
|
+
above?: Exclude<Breakpoint, 'xxs'>;
|
|
16
|
+
/**
|
|
17
|
+
* Apply CSS to show this specifically **below** this breakpoint.
|
|
18
|
+
* The smallest breakpoint is not included as it would never be shown and this would not be performant.
|
|
19
|
+
*
|
|
20
|
+
* @important do not mix `above` and `below` (TypeScript should prevent this)
|
|
21
|
+
*/
|
|
22
|
+
below?: Exclude<Breakpoint, 'xxs'>;
|
|
23
|
+
} & ({
|
|
24
|
+
above?: never;
|
|
25
|
+
below: Exclude<Breakpoint, 'xxs'>;
|
|
26
|
+
} | {
|
|
27
|
+
above: Exclude<Breakpoint, 'xxs'>;
|
|
28
|
+
below?: never;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Shows the content at a given breakpoint. By default, content is hidden. The primary use case is for visual presentation.
|
|
32
|
+
* Mix `<Show above="md">` with `<Hide above="md">` to achieve content that shifts at a breakpoint.
|
|
33
|
+
*
|
|
34
|
+
* Please note:
|
|
35
|
+
* - This only uses `display: none` and `display: revert` to show/hide, it does not skip rendering of children trees.
|
|
36
|
+
* - As this is rendered at all times, there is little performance savings here (just that this is not painted).
|
|
37
|
+
*/
|
|
38
|
+
export declare const Show: ({ above, below, children, as: AsElement, }: ResponsiveShowProps) => jsx.JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -23,10 +23,10 @@ export type Dimension = keyof typeof dimensionMap;
|
|
|
23
23
|
*/
|
|
24
24
|
/**
|
|
25
25
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
26
|
-
* @codegen <<SignedSource::
|
|
26
|
+
* @codegen <<SignedSource::429dca3ce1fa6d723cb98e2468802267>>
|
|
27
27
|
* @codegenId spacing
|
|
28
28
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
29
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::
|
|
29
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::68f6bde7e6b186964ee53458284bbb90>>
|
|
30
30
|
*/
|
|
31
31
|
export declare const spaceMap: {
|
|
32
32
|
'space.0': "var(--ds-space-0)";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { css as cssEmotion } from '@emotion/react';
|
|
3
3
|
import { CSSPropertiesWithMultiValues, SerializedStyles } from '@emotion/serialize';
|
|
4
4
|
import type * as CSS from 'csstype';
|
|
5
|
-
import { MediaQuery } from '../helpers/responsive/types';
|
|
6
5
|
import { Box, Inline } from '../index';
|
|
6
|
+
import type { MediaQuery } from '../responsive/types';
|
|
7
7
|
import { TokenisedProps } from './style-maps.partial';
|
|
8
8
|
declare const uniqueSymbol: unique symbol;
|
|
9
9
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"./box": "./src/components/box.tsx",
|
|
100
100
|
"./stack": "./src/components/stack.tsx",
|
|
101
101
|
"./inline": "./src/components/inline.tsx",
|
|
102
|
-
"./responsive": "./src/
|
|
102
|
+
"./responsive": "./src/responsive/index.tsx"
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
105
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"@atlaskit/visual-regression": "*",
|
|
133
133
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
134
134
|
"@atlassian/codegen": "^0.1.0",
|
|
135
|
-
"@atlassian/gemini-visual-regression": "^0.0.
|
|
135
|
+
"@atlassian/gemini-visual-regression": "^0.0.35",
|
|
136
136
|
"@testing-library/react": "^12.1.5",
|
|
137
137
|
"@testing-library/react-hooks": "^8.0.1",
|
|
138
138
|
"csstype": "^3.1.0",
|
package/responsive/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives/responsive",
|
|
3
|
-
"main": "../dist/cjs/
|
|
4
|
-
"module": "../dist/esm/
|
|
5
|
-
"module:es2019": "../dist/es2019/
|
|
3
|
+
"main": "../dist/cjs/responsive/index.js",
|
|
4
|
+
"module": "../dist/esm/responsive/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/responsive/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/
|
|
7
|
+
"types": "../dist/types/responsive/index.d.ts",
|
|
8
8
|
"typesVersions": {
|
|
9
9
|
">=4.5 <4.9": {
|
|
10
10
|
"*": [
|
|
11
|
-
"../dist/types-ts4.5/
|
|
11
|
+
"../dist/types-ts4.5/responsive/index.d.ts"
|
|
12
12
|
]
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
import { UNSAFE_BREAKPOINTS_ORDERED_LIST } from './constants';
|
|
3
|
-
import { media } from './media-helper';
|
|
4
|
-
/**
|
|
5
|
-
* Build a map of breakpoints to css with media queries and nested styles.
|
|
6
|
-
*
|
|
7
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* A map to build optional `display:none` for consumption on a div.
|
|
11
|
-
* ```ts
|
|
12
|
-
* const hideMediaQueries = buildAboveMediaQueryCSS({ display: 'none' });
|
|
13
|
-
*
|
|
14
|
-
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
15
|
-
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* This roughly builds a map that will look roughly like this (if done manually):
|
|
20
|
-
* ```ts
|
|
21
|
-
* {
|
|
22
|
-
* xxs: css({ '@media (min-width: 0px)': { display: 'none' } }),
|
|
23
|
-
* xs: css({ '@media (min-width: …px)': { display: 'none' } }),
|
|
24
|
-
* sm: css({ '@media (min-width: …px)': { display: 'none' } }),
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export const UNSAFE_buildAboveMediaQueryCSS = input => {
|
|
29
|
-
return UNSAFE_BREAKPOINTS_ORDERED_LIST.reduce((acc, breakpoint) => ({
|
|
30
|
-
...acc,
|
|
31
|
-
[breakpoint]: css({
|
|
32
|
-
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
33
|
-
[media.above[breakpoint]]: typeof input === 'function' ? input(breakpoint) : input
|
|
34
|
-
})
|
|
35
|
-
}), {});
|
|
36
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CSSObject } from '@emotion/react';
|
|
2
|
-
import type { Breakpoint } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Build a map of breakpoints to css with media queries and nested styles.
|
|
5
|
-
*
|
|
6
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* A map to build optional `display:none` for consumption on a div.
|
|
10
|
-
* ```ts
|
|
11
|
-
* const hideMediaQueries = buildAboveMediaQueryCSS({ display: 'none' });
|
|
12
|
-
*
|
|
13
|
-
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
14
|
-
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* This roughly builds a map that will look roughly like this (if done manually):
|
|
19
|
-
* ```ts
|
|
20
|
-
* {
|
|
21
|
-
* xxs: css({ '@media (min-width: 0px)': { display: 'none' } }),
|
|
22
|
-
* xs: css({ '@media (min-width: …px)': { display: 'none' } }),
|
|
23
|
-
* sm: css({ '@media (min-width: …px)': { display: 'none' } }),
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare const UNSAFE_buildAboveMediaQueryCSS: (input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CSSObject } from '@emotion/react';
|
|
2
|
-
import type { Breakpoint } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Build a map of breakpoints to css with media queries and nested styles.
|
|
5
|
-
*
|
|
6
|
-
* @experimental Unsafe for usage as the API is not finalized.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* A map to build optional `display:none` for consumption on a div.
|
|
10
|
-
* ```ts
|
|
11
|
-
* const hideMediaQueries = buildAboveMediaQueryCSS({ display: 'none' });
|
|
12
|
-
*
|
|
13
|
-
* const Component = ({ hideAtBreakpoints: ('xs' | 'sm')[], children: ReactNode }) => {
|
|
14
|
-
* return <div css={hideAtBreakpoints.map(b => hideMediaQueries[b])}>{children}</div>;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* This roughly builds a map that will look roughly like this (if done manually):
|
|
19
|
-
* ```ts
|
|
20
|
-
* {
|
|
21
|
-
* xxs: css({ '@media (min-width: 0px)': { display: 'none' } }),
|
|
22
|
-
* xs: css({ '@media (min-width: …px)': { display: 'none' } }),
|
|
23
|
-
* sm: css({ '@media (min-width: …px)': { display: 'none' } }),
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare const UNSAFE_buildAboveMediaQueryCSS: (input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|