@atlaskit/primitives 7.0.0 → 7.0.2
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/.eslintrc.js +1 -1
- package/CHANGELOG.md +19 -1
- package/LICENSE.md +6 -8
- package/constellation/anchor/code.mdx +3 -3
- package/constellation/anchor/examples.mdx +33 -39
- package/constellation/anchor/usage.mdx +60 -30
- package/constellation/bleed/code.mdx +3 -3
- package/constellation/bleed/examples.mdx +17 -13
- package/constellation/box/code.mdx +3 -3
- package/constellation/box/examples.mdx +25 -19
- package/constellation/box/usage.mdx +15 -5
- package/constellation/flex/code.mdx +3 -3
- package/constellation/flex/examples.mdx +12 -11
- package/constellation/grid/code.mdx +3 -3
- package/constellation/grid/examples.mdx +15 -10
- package/constellation/inline/code.mdx +3 -3
- package/constellation/inline/examples.mdx +32 -38
- package/constellation/inline/usage.mdx +15 -6
- package/constellation/overview/index.mdx +29 -27
- package/constellation/pressable/code.mdx +5 -4
- package/constellation/pressable/examples.mdx +41 -55
- package/constellation/pressable/usage.mdx +59 -36
- package/constellation/responsive/01-show/code.mdx +3 -3
- package/constellation/responsive/01-show/examples.mdx +9 -13
- package/constellation/responsive/02-hide/code.mdx +3 -3
- package/constellation/responsive/02-hide/examples.mdx +9 -13
- package/constellation/responsive/03-breakpoints/examples.mdx +3 -3
- package/constellation/responsive/examples.mdx +10 -10
- package/constellation/responsive/usage.mdx +23 -15
- package/constellation/stack/code.mdx +3 -3
- package/constellation/stack/examples.mdx +26 -20
- package/constellation/stack/usage.mdx +13 -5
- package/constellation/text/code.mdx +3 -3
- package/constellation/text/examples.mdx +29 -15
- package/constellation/text/usage.mdx +6 -3
- package/constellation/xcss/examples.mdx +7 -5
- package/constellation/xcss/migration.mdx +32 -25
- package/constellation/xcss/usage.mdx +72 -60
- package/dist/cjs/components/anchor.js +4 -4
- package/dist/cjs/components/pressable.js +1 -1
- package/dist/cjs/xcss/style-maps.partial.js +13 -13
- package/dist/es2019/components/anchor.js +4 -4
- package/dist/es2019/components/pressable.js +1 -1
- package/dist/es2019/xcss/style-maps.partial.js +13 -13
- package/dist/esm/components/anchor.js +4 -4
- package/dist/esm/components/pressable.js +1 -1
- package/dist/esm/xcss/style-maps.partial.js +13 -13
- package/dist/types/components/anchor.d.ts +4 -4
- package/dist/types/responsive/index.d.ts +2 -2
- package/dist/types/xcss/style-maps.partial.d.ts +13 -13
- package/dist/types-ts4.5/components/anchor.d.ts +4 -4
- package/dist/types-ts4.5/responsive/index.d.ts +2 -2
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +13 -13
- package/extract-react-types/anchor-props.tsx +108 -116
- package/extract-react-types/bleed-props.tsx +17 -22
- package/extract-react-types/box-props.tsx +67 -70
- package/extract-react-types/flex-props.tsx +61 -61
- package/extract-react-types/grid-props.tsx +92 -92
- package/extract-react-types/hide-props.tsx +35 -35
- package/extract-react-types/inline-props.tsx +68 -68
- package/extract-react-types/pressable-props.tsx +101 -107
- package/extract-react-types/show-props.tsx +35 -35
- package/extract-react-types/stack-props.tsx +55 -55
- package/package.json +2 -2
- package/report.api.md +940 -965
- package/scripts/border-codegen-template.tsx +40 -47
- package/scripts/codegen-file-templates/dimensions.tsx +8 -8
- package/scripts/codegen-file-templates/layer.tsx +9 -9
- package/scripts/codegen-styles.tsx +97 -103
- package/scripts/color-codegen-template.tsx +61 -73
- package/scripts/elevation-codegen-template.tsx +50 -62
- package/scripts/inverse-color-map-template.tsx +26 -31
- package/scripts/misc-codegen-template.tsx +4 -9
- package/scripts/spacing-codegen-template.tsx +25 -31
- package/scripts/typography-codegen-template.tsx +59 -65
- package/scripts/utils.tsx +36 -43
|
@@ -15,28 +15,31 @@ import ResponsiveGrid from '../../examples/constellation/grid/responsive';
|
|
|
15
15
|
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
16
16
|
|
|
17
17
|
<CodeDocsHeader
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
name="@atlaskit/primitives"
|
|
19
|
+
repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
|
|
20
|
+
directoryName="primitives"
|
|
21
21
|
/>
|
|
22
22
|
|
|
23
23
|
## Basic
|
|
24
24
|
|
|
25
|
-
The `Grid` component is designed as a very basic mapping to the CSS Grid API.
|
|
26
|
-
|
|
25
|
+
The `Grid` component is designed as a very basic mapping to the CSS Grid API. It can be used as an
|
|
26
|
+
alternative to [Flex](/components/primitives/flex), [Inline](/components/primitives/inline) or
|
|
27
|
+
[Stack](/components/primitives/stack).
|
|
27
28
|
|
|
28
29
|
<Example Component={GridBasic} packageName="@atlaskit/primitives/grid" />
|
|
29
30
|
|
|
30
31
|
## Gap properties
|
|
31
32
|
|
|
32
|
-
Gap properties `rowGap`, `columnGap` and `gap` only allow token-backed values. This is to aid
|
|
33
|
+
Gap properties `rowGap`, `columnGap` and `gap` only allow token-backed values. This is to aid
|
|
34
|
+
ergonomics and keep the whitespace of the grid harmonious with the spacing system.
|
|
33
35
|
|
|
34
36
|
<Example Component={GridGap} packageName="@atlaskit/primitives/grid" />
|
|
35
37
|
|
|
36
38
|
## Template syntax
|
|
37
39
|
|
|
38
|
-
Grid-prefixed template properties in CSS do not have this prefix in the component API.
|
|
39
|
-
|
|
40
|
+
Grid-prefixed template properties in CSS do not have this prefix in the component API. For example
|
|
41
|
+
`grid-template-*` are instead applied as `templateColumns`, `templateRows` and `templateArea`
|
|
42
|
+
properties.
|
|
40
43
|
|
|
41
44
|
### Template columns
|
|
42
45
|
|
|
@@ -58,13 +61,15 @@ Template areas enables grid to declare the grid areas are applied in the templat
|
|
|
58
61
|
|
|
59
62
|
## Autoflow syntax
|
|
60
63
|
|
|
61
|
-
Grid-prefixed properties in CSS do not have this prefix in the component API. `grid-auto-flow` is
|
|
64
|
+
Grid-prefixed properties in CSS do not have this prefix in the component API. `grid-auto-flow` is
|
|
65
|
+
instead applied via `autoFlow`.
|
|
62
66
|
|
|
63
67
|
<Example Component={GridAutoFlow} packageName="@atlaskit/primitives/grid" />
|
|
64
68
|
|
|
65
69
|
## Responsive grid
|
|
66
70
|
|
|
67
|
-
Here, we construct a grid layout that adapts from a single column to a four-column layout depending
|
|
71
|
+
Here, we construct a grid layout that adapts from a single column to a four-column layout depending
|
|
72
|
+
on the viewport size.
|
|
68
73
|
|
|
69
74
|
<Example Component={ResponsiveGrid} packageName="@atlaskit/primitives/grid" />
|
|
70
75
|
|
|
@@ -11,9 +11,9 @@ props:
|
|
|
11
11
|
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
12
12
|
|
|
13
13
|
<CodeDocsHeader
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
name="@atlaskit/primitives"
|
|
15
|
+
repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
|
|
16
|
+
directoryName="primitives"
|
|
17
17
|
/>
|
|
18
18
|
|
|
19
19
|
## Props
|
|
@@ -19,16 +19,17 @@ import InlinePracticalUseCase from '../../examples/constellation/inline/practica
|
|
|
19
19
|
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
20
20
|
|
|
21
21
|
<CodeDocsHeader
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
name="@atlaskit/primitives"
|
|
23
|
+
repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
|
|
24
|
+
directoryName="primitives"
|
|
25
25
|
/>
|
|
26
26
|
|
|
27
27
|
## Basic
|
|
28
28
|
|
|
29
29
|
Use an inline component to configure the layout of a group of elements horizontally.
|
|
30
30
|
|
|
31
|
-
Use the given props to configure display behavior using design tokens, as shown in the more complex
|
|
31
|
+
Use the given props to configure display behavior using design tokens, as shown in the more complex
|
|
32
|
+
examples below.
|
|
32
33
|
|
|
33
34
|
<Example Component={InlineBasic} packageName="@atlaskit/primitives/inline" />
|
|
34
35
|
|
|
@@ -36,57 +37,55 @@ Use the given props to configure display behavior using design tokens, as shown
|
|
|
36
37
|
|
|
37
38
|
Control the spacing between items with the `space` prop.
|
|
38
39
|
|
|
39
|
-
<Example
|
|
40
|
-
Component={InlineSpaceBasic}
|
|
41
|
-
packageName="@atlaskit/primitives/inline"
|
|
42
|
-
/>
|
|
40
|
+
<Example Component={InlineSpaceBasic} packageName="@atlaskit/primitives/inline" />
|
|
43
41
|
|
|
44
42
|
When content is set to wrap, the `space` prop applies equal spacing between rows.
|
|
45
43
|
|
|
46
44
|
For a different space value between rows use the `rowSpace` prop.
|
|
47
45
|
|
|
48
|
-
<Example
|
|
49
|
-
Component={InlineSpaceWrap}
|
|
50
|
-
packageName="@atlaskit/primitives/inline"
|
|
51
|
-
/>
|
|
46
|
+
<Example Component={InlineSpaceWrap} packageName="@atlaskit/primitives/inline" />
|
|
52
47
|
|
|
53
48
|
## Reverse content
|
|
54
49
|
|
|
55
|
-
`flex-direction: `row-reverse` is a pattern that has
|
|
50
|
+
`flex-direction: `row-reverse` is a pattern that has
|
|
51
|
+
[accessibility concerns](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction#accessibility_concerns)
|
|
52
|
+
so inline doesn't support it.
|
|
56
53
|
|
|
57
|
-
If reversing content is required, we generally recommend to use JavaScript to reverse the JSX
|
|
54
|
+
If reversing content is required, we generally recommend to use JavaScript to reverse the JSX
|
|
55
|
+
content thereby preserving the tabbing order.
|
|
58
56
|
|
|
59
|
-
In situations where tabbing order changes based on different breakpoints, then we have
|
|
57
|
+
In situations where tabbing order changes based on different breakpoints, then we have
|
|
58
|
+
[show](/components/primitives/responsive/hide/examples) and
|
|
59
|
+
[hide](/components/primitives/responsive/hide/examples) components that enable switching between
|
|
60
|
+
different orderings of content.
|
|
60
61
|
|
|
61
|
-
For non-tabbable content that needs to be reversed, `flex-direction: row-reverse` is supported in
|
|
62
|
+
For non-tabbable content that needs to be reversed, `flex-direction: row-reverse` is supported in
|
|
63
|
+
XCSS. However, please be aware that we may lint against this in the future.
|
|
62
64
|
|
|
63
65
|
## Alignment
|
|
64
66
|
|
|
65
|
-
To control the alignment of items you can use the `alignBlock` and `alignInline` props which control
|
|
67
|
+
To control the alignment of items you can use the `alignBlock` and `alignInline` props which control
|
|
68
|
+
alignment in the vertical and horizontal axis respectively.
|
|
66
69
|
|
|
67
70
|
### Block alignment
|
|
68
71
|
|
|
69
|
-
<Example
|
|
70
|
-
Component={InlineAlignBlock}
|
|
71
|
-
packageName="@atlaskit/primitives/inline"
|
|
72
|
-
/>
|
|
72
|
+
<Example Component={InlineAlignBlock} packageName="@atlaskit/primitives/inline" />
|
|
73
73
|
|
|
74
74
|
### Inline alignment
|
|
75
75
|
|
|
76
|
-
<Example
|
|
77
|
-
Component={InlineAlignInline}
|
|
78
|
-
packageName="@atlaskit/primitives/inline"
|
|
79
|
-
/>
|
|
76
|
+
<Example Component={InlineAlignInline} packageName="@atlaskit/primitives/inline" />
|
|
80
77
|
|
|
81
78
|
## Spread
|
|
82
79
|
|
|
83
|
-
Elements can be set to stay together, spaced at the given value (default behavior) or spread equally
|
|
80
|
+
Elements can be set to stay together, spaced at the given value (default behavior) or spread equally
|
|
81
|
+
in the space available.
|
|
84
82
|
|
|
85
83
|
<Example Component={InlineSpread} packageName="@atlaskit/primitives/inline" />
|
|
86
84
|
|
|
87
85
|
## Wrap
|
|
88
86
|
|
|
89
|
-
When the number of items goes beyond the available space, use `shouldWrap` to create new rows of
|
|
87
|
+
When the number of items goes beyond the available space, use `shouldWrap` to create new rows of
|
|
88
|
+
content.
|
|
90
89
|
|
|
91
90
|
<Example Component={InlineWrap} packageName="@atlaskit/primitives/inline" />
|
|
92
91
|
|
|
@@ -94,15 +93,12 @@ When the number of items goes beyond the available space, use `shouldWrap` to cr
|
|
|
94
93
|
|
|
95
94
|
For logically related elements it's possible to specify a `separator` character value.
|
|
96
95
|
|
|
97
|
-
<Example
|
|
98
|
-
Component={InlineSeparator}
|
|
99
|
-
packageName="@atlaskit/primitives/inline"
|
|
100
|
-
/>
|
|
96
|
+
<Example Component={InlineSeparator} packageName="@atlaskit/primitives/inline" />
|
|
101
97
|
|
|
102
98
|
## Width control
|
|
103
99
|
|
|
104
|
-
By default an `Inline` will have its width influenced by the context where it appears.
|
|
105
|
-
|
|
100
|
+
By default an `Inline` will have its width influenced by the context where it appears. To control
|
|
101
|
+
the width, use the `grow` prop with the values:
|
|
106
102
|
|
|
107
103
|
- `hug` (default) to use space only as required by its children, or
|
|
108
104
|
- `fill` to take all space provided by the parent element.
|
|
@@ -117,9 +113,7 @@ It's possible to control the rendered HTML element with the `as` prop.
|
|
|
117
113
|
|
|
118
114
|
## Practical use case
|
|
119
115
|
|
|
120
|
-
An example of how an inline component might be used in product, using Atlassian Design System
|
|
116
|
+
An example of how an inline component might be used in product, using Atlassian Design System
|
|
117
|
+
components.
|
|
121
118
|
|
|
122
|
-
<Example
|
|
123
|
-
Component={InlinePracticalUseCase}
|
|
124
|
-
packageName="@atlaskit/primitives/inline"
|
|
125
|
-
/>
|
|
119
|
+
<Example Component={InlinePracticalUseCase} packageName="@atlaskit/primitives/inline" />
|
|
@@ -4,23 +4,32 @@ description: An inline manages the horizontal layout of direct children using fl
|
|
|
4
4
|
order: 2
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Use the inline component in conjunction with other layout components such as
|
|
7
|
+
Use the inline component in conjunction with other layout components such as
|
|
8
|
+
[box](/components/primitives/box/usage) and [stack](/components/primitives/stack/usage) to easily
|
|
9
|
+
create customized layouts, with built-in guidance from the Atlassian Design System.
|
|
8
10
|
|
|
9
|
-
Inline components act as container to decide the horizontal layout of its children. They decide the
|
|
11
|
+
Inline components act as container to decide the horizontal layout of its children. They decide the
|
|
12
|
+
specifics of how the children are displayed, for example, where they are aligned or how much space
|
|
13
|
+
is between child elements. An inline component should be used purely for visual alignment, and
|
|
14
|
+
should have no opinions about the functionality of its children.
|
|
10
15
|
|
|
11
|
-
In its simplest form, an inline component operates like a flexbox row, however adds the built in
|
|
16
|
+
In its simplest form, an inline component operates like a flexbox row, however adds the built in
|
|
17
|
+
design token support and guidance.
|
|
12
18
|
|
|
13
19
|
```jsx
|
|
14
20
|
<Inline space="space.100" alignInline="center" alignBlock="start">
|
|
15
|
-
|
|
21
|
+
...
|
|
16
22
|
</Inline>
|
|
17
23
|
```
|
|
18
24
|
|
|
19
|
-
Inline also has a `flex-direction: row;`. This is the default for flexbox, so it is not explicitly
|
|
25
|
+
Inline also has a `flex-direction: row;`. This is the default for flexbox, so it is not explicitly
|
|
26
|
+
applied.
|
|
20
27
|
|
|
21
28
|
## Using inline
|
|
22
29
|
|
|
23
|
-
The purpose of an inline is primarily as a container element controlling how child components are
|
|
30
|
+
The purpose of an inline is primarily as a container element controlling how child components are
|
|
31
|
+
displayed and positioned horizontally. An inline should be used any time you wish to layout elements
|
|
32
|
+
or components horizontally.
|
|
24
33
|
|
|
25
34
|
Use the inline props to customize the spacing and styling on any child elements. These include:
|
|
26
35
|
|
|
@@ -14,21 +14,23 @@ import stackUsageExample from './images/stack-usage-example.png';
|
|
|
14
14
|
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
15
15
|
|
|
16
16
|
<CodeDocsHeader
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
name="@atlaskit/primitives"
|
|
18
|
+
repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
|
|
19
|
+
directoryName="primitives"
|
|
20
20
|
/>
|
|
21
21
|
|
|
22
|
-
Primitives are a new type of component for layouts, styling, and the placement of elements.
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
Primitives are a new type of component for layouts, styling, and the placement of elements. They act
|
|
23
|
+
as building blocks to compose different parts of the user experience, from the smallest design
|
|
24
|
+
decisions (for example, the spacing around an icon) to larger layout decisions (for example, how a
|
|
25
|
+
page is structured).
|
|
25
26
|
|
|
26
|
-
Primitives are powered by design tokens and make it easier to apply design decisions. This reduces
|
|
27
|
+
Primitives are powered by design tokens and make it easier to apply design decisions. This reduces
|
|
28
|
+
cognitive overhead, improves productivity and prevents accidents or mistakes.
|
|
27
29
|
|
|
28
30
|
## Available primitives
|
|
29
31
|
|
|
30
|
-
Primitives are used together to compose complex designs not otherwise implemented directly in the
|
|
31
|
-
Currently, three layout primitive components are available:
|
|
32
|
+
Primitives are used together to compose complex designs not otherwise implemented directly in the
|
|
33
|
+
Design System. Currently, three layout primitive components are available:
|
|
32
34
|
|
|
33
35
|
- in a container (see [box](/components/primitives/box))
|
|
34
36
|
- horizontally (see [inline](/components/primitives/inline))
|
|
@@ -50,36 +52,36 @@ $ yarn add @atlaskit/primitives
|
|
|
50
52
|
|
|
51
53
|
## Using primitives
|
|
52
54
|
|
|
53
|
-
Use primitives for composing layouts.
|
|
54
|
-
|
|
55
|
-
This involves breaking down a design into its core layout components to as granular level as is
|
|
55
|
+
Use primitives for composing layouts. Primitives are not currently available in Figma, so the first
|
|
56
|
+
step in implementing primitive components is identifying where they might fit in a given design.
|
|
57
|
+
This involves breaking down a design into its core layout components to as granular level as is
|
|
58
|
+
useful.
|
|
56
59
|
|
|
57
|
-
You might like to think first about breaking down a page into `Box` containers,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
You might like to think first about breaking down a page into `Box` containers, identifying larger
|
|
61
|
+
pieces of a design that function in a similar manner or fulfill a singular purpose in a layout and
|
|
62
|
+
grouping them together under a `Box`.
|
|
60
63
|
|
|
61
64
|
<Image
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
src={boxUsageExample}
|
|
66
|
+
alt="Screenshot of a typical Jira board with swimlanes. Various areas are highlighted as examples of how Box containers are used for layout"
|
|
64
67
|
/>
|
|
65
68
|
|
|
66
|
-
The behavior within and around these boxes can then be broken down into their horizontal `Inline`
|
|
69
|
+
The behavior within and around these boxes can then be broken down into their horizontal `Inline`
|
|
70
|
+
and vertical `Stack` components.
|
|
67
71
|
|
|
68
72
|
<SectionMessage>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</a>{' '}
|
|
73
|
-
offers suggestions for possible primitives to apply in a layout.
|
|
73
|
+
The ESLint rule{' '}
|
|
74
|
+
<a href="/components/eslint-plugin-design-system/use-primitives">use-primitives</a> offers
|
|
75
|
+
suggestions for possible primitives to apply in a layout.
|
|
74
76
|
</SectionMessage>
|
|
75
77
|
|
|
76
78
|
<Image
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
src={inlineUsageExample}
|
|
80
|
+
alt="Screenshot of a typical Jira board with swimlanes. Various areas are highlighted as examples of how Inline containers are used for layout"
|
|
79
81
|
/>
|
|
80
82
|
<Image
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
src={stackUsageExample}
|
|
84
|
+
alt="Screenshot of a typical Jira board with swimlanes. Various areas are highlighted as examples of how Stack containers are used for layout"
|
|
83
85
|
/>
|
|
84
86
|
|
|
85
87
|
## Related
|
|
@@ -7,15 +7,16 @@ order: 1
|
|
|
7
7
|
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
8
8
|
|
|
9
9
|
<CodeDocsHeader
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
name="@atlaskit/primitives"
|
|
11
|
+
repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
|
|
12
|
+
directoryName="primitives"
|
|
13
13
|
/>
|
|
14
14
|
|
|
15
15
|
import ERTPressable from '!!extract-react-types-loader!../../extract-react-types/pressable-props';
|
|
16
16
|
|
|
17
17
|
## Props
|
|
18
18
|
|
|
19
|
-
Pressable also supports all valid `HTMLButtonElement` props, except for `disabled` which is replaced
|
|
19
|
+
Pressable also supports all valid `HTMLButtonElement` props, except for `disabled` which is replaced
|
|
20
|
+
by the `isDisabled` prop.
|
|
20
21
|
|
|
21
22
|
<PropsTable heading="" props={ERTPressable} />
|
|
@@ -18,98 +18,84 @@ import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
|
18
18
|
import SectionMessage from '@atlaskit/section-message';
|
|
19
19
|
|
|
20
20
|
<CodeDocsHeader
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
name="@atlaskit/primitives"
|
|
22
|
+
repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
|
|
23
|
+
directoryName="primitives"
|
|
24
24
|
/>
|
|
25
25
|
|
|
26
|
-
Pressable is a primitive
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
Pressable is a primitive for building custom buttons with Atlassian Design System styling and
|
|
27
|
+
built-in event tracking. It renders a `<button>` element. Use pressable when existing
|
|
28
|
+
[buttons](/components/button/examples) can't be customized to fit your needs.
|
|
29
29
|
|
|
30
30
|
## Default
|
|
31
31
|
|
|
32
|
-
Pressable is unstyled by default.
|
|
32
|
+
Pressable is unstyled by default, aside from basic focus styles.
|
|
33
33
|
|
|
34
|
-
<Example
|
|
35
|
-
Component={PressableDefault}
|
|
36
|
-
packageName="@atlaskit/primitives/pressable"
|
|
37
|
-
/>
|
|
34
|
+
<Example Component={PressableDefault} packageName="@atlaskit/primitives/pressable" />
|
|
38
35
|
|
|
39
36
|
## Basic styling with XCSS
|
|
40
37
|
|
|
41
|
-
Pressable can be styled using
|
|
38
|
+
Pressable can be styled further using the design system styling API,
|
|
39
|
+
[XCSS](/components/primitives/xcss).
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
Make sure styling indicates the interaction state using `:hover` and `:active` pseudo-classes.
|
|
44
42
|
|
|
45
|
-
<Example
|
|
46
|
-
Component={PressableBasic}
|
|
47
|
-
packageName="@atlaskit/primitives/pressable"
|
|
48
|
-
/>
|
|
43
|
+
<Example Component={PressableBasic} packageName="@atlaskit/primitives/pressable" />
|
|
49
44
|
|
|
50
45
|
## Advanced styling
|
|
51
46
|
|
|
52
47
|
Use a combination of XCSS and other primitives for more complex designs.
|
|
53
48
|
|
|
54
49
|
<Example
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
Component={PressableStyled}
|
|
51
|
+
packageName="@atlaskit/primitives/pressable"
|
|
52
|
+
backgroundColor="white"
|
|
58
53
|
/>
|
|
59
54
|
|
|
60
55
|
## Disabled
|
|
61
56
|
|
|
62
|
-
|
|
57
|
+
You can disable pressable buttons with the `isDisabled` prop. Disabled styles should be applied and
|
|
58
|
+
defined conditionally using XCSS.
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
Disabled buttons can cause accessibility issues (disabled elements are not in the tab order) so
|
|
61
|
+
wherever possible, avoid using `isDisabled`. Instead, use validation or other techniques to show
|
|
62
|
+
users how to proceed.
|
|
63
|
+
|
|
64
|
+
<!-- todo: snippet for disabled a11y warnings? -->
|
|
65
|
+
|
|
66
|
+
<Example Component={PressableDisabled} packageName="@atlaskit/primitives/pressable" />
|
|
68
67
|
|
|
69
68
|
## Buttons without visible labels
|
|
70
69
|
|
|
71
|
-
For buttons without visible labels such as icon buttons,
|
|
70
|
+
For buttons without visible labels such as icon buttons, make an accessible label available using
|
|
71
|
+
the [visually hidden component](/components/visually-hidden/examples). This renders hidden text
|
|
72
|
+
inside the button for assistive technologies, which is preferable to an `aria-label` attribute
|
|
73
|
+
because not all screen readers translate these between languages.
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
Also, consider providing a [tooltip](/components/tooltip) to help sighted users understand the
|
|
76
|
+
button's purpose.
|
|
74
77
|
|
|
75
78
|
<Example
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
Component={PressableWithoutVisibleLabels}
|
|
80
|
+
packageName="@atlaskit/primitives/pressable"
|
|
81
|
+
backgroundColor="white"
|
|
79
82
|
/>
|
|
80
83
|
|
|
81
84
|
## HTML attributes
|
|
82
85
|
|
|
83
|
-
Pressable passes
|
|
86
|
+
Pressable passes all valid HTML attributes to the underlying `<button>` element. The `type`
|
|
87
|
+
attribute defaults to `button` to prevent unintentionally submitting forms.
|
|
84
88
|
|
|
85
|
-
<Example
|
|
86
|
-
Component={PressableHtmlAttributes}
|
|
87
|
-
packageName="@atlaskit/primitives/pressable"
|
|
88
|
-
/>
|
|
89
|
+
<Example Component={PressableHtmlAttributes} packageName="@atlaskit/primitives/pressable" />
|
|
89
90
|
|
|
90
|
-
<Snippet
|
|
91
|
-
name="primitives-event-tracking-header"
|
|
92
|
-
variables={{ componentName: 'pressable' }}
|
|
93
|
-
/>
|
|
91
|
+
<Snippet name="primitives-event-tracking-header" variables={{ componentName: 'pressable' }} />
|
|
94
92
|
|
|
95
|
-
<Example
|
|
96
|
-
Component={PressableAnalytics}
|
|
97
|
-
packageName="@atlaskit/primitives/pressable"
|
|
98
|
-
/>
|
|
93
|
+
<Example Component={PressableAnalytics} packageName="@atlaskit/primitives/pressable" />
|
|
99
94
|
|
|
100
95
|
<Snippet name="primitives-event-tracking-gasv3" />
|
|
101
96
|
|
|
102
|
-
<Example
|
|
103
|
-
Component={PressableAnalyticsGASv3}
|
|
104
|
-
packageName="@atlaskit/primitives/pressable"
|
|
105
|
-
/>
|
|
97
|
+
<Example Component={PressableAnalyticsGASv3} packageName="@atlaskit/primitives/pressable" />
|
|
106
98
|
|
|
107
|
-
<Snippet
|
|
108
|
-
name="primitives-event-tracking-ufo"
|
|
109
|
-
variables={{ componentName: 'pressable' }}
|
|
110
|
-
/>
|
|
99
|
+
<Snippet name="primitives-event-tracking-ufo" variables={{ componentName: 'pressable' }} />
|
|
111
100
|
|
|
112
|
-
<Example
|
|
113
|
-
Component={PressablePressTracing}
|
|
114
|
-
packageName="@atlaskit/primitives/pressable"
|
|
115
|
-
/>
|
|
101
|
+
<Example Component={PressablePressTracing} packageName="@atlaskit/primitives/pressable" />
|