@atlaskit/primitives 6.1.1 → 6.2.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 +17 -0
- package/constellation/anchor/examples.mdx +87 -5
- package/constellation/pressable/code.mdx +1 -1
- package/constellation/pressable/examples.mdx +73 -10
- package/constellation/pressable/usage.mdx +1 -1
- package/constellation/text/examples.mdx +50 -18
- package/constellation/text/usage.mdx +11 -1
- package/constellation/xcss/usage.mdx +12 -6
- package/dist/cjs/components/anchor.js +2 -2
- package/dist/cjs/components/pressable.js +2 -4
- package/dist/cjs/responsive/hide.js +6 -2
- package/dist/cjs/responsive/show.js +6 -2
- package/dist/cjs/xcss/style-maps.partial.js +5 -2
- package/dist/es2019/components/anchor.js +2 -2
- package/dist/es2019/components/pressable.js +2 -4
- package/dist/es2019/responsive/hide.js +6 -2
- package/dist/es2019/responsive/show.js +6 -2
- package/dist/es2019/xcss/style-maps.partial.js +5 -2
- package/dist/esm/components/anchor.js +2 -2
- package/dist/esm/components/pressable.js +2 -4
- package/dist/esm/responsive/hide.js +6 -2
- package/dist/esm/responsive/show.js +6 -2
- package/dist/esm/xcss/style-maps.partial.js +5 -2
- package/dist/types/components/anchor.d.ts +2 -2
- package/dist/types/components/pressable.d.ts +9 -15
- package/dist/types/responsive/hide.d.ts +5 -4
- package/dist/types/responsive/show.d.ts +4 -3
- package/dist/types/xcss/style-maps.partial.d.ts +4 -1
- package/dist/types-ts4.5/components/anchor.d.ts +2 -2
- package/dist/types-ts4.5/components/pressable.d.ts +9 -15
- package/dist/types-ts4.5/responsive/hide.d.ts +5 -4
- package/dist/types-ts4.5/responsive/show.d.ts +4 -3
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +4 -1
- package/extract-react-types/anchor-props.tsx +34 -8
- package/extract-react-types/pressable-props.tsx +14 -11
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 6.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#100442](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100442)
|
|
8
|
+
[`6b3630addb05`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6b3630addb05) -
|
|
9
|
+
Add `xcss` to responsive components `Show` and `Hide`.
|
|
10
|
+
|
|
11
|
+
## 6.1.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#98149](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98149)
|
|
16
|
+
[`45101e24202a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/45101e24202a) -
|
|
17
|
+
Internal change only; update generated styles.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 6.1.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -5,7 +5,13 @@ order: 0
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
import AnchorDefault from '../../examples/constellation/anchor/default';
|
|
8
|
+
import AnchorBasic from '../../examples/constellation/anchor/basic';
|
|
8
9
|
import AnchorStyled from '../../examples/constellation/anchor/styled';
|
|
10
|
+
import AnchorHtmlAttributes from '../../examples/constellation/anchor/html-attributes';
|
|
11
|
+
import AnchorRouterLinkConfiguration from '../../examples/constellation/anchor/router-link-configuration';
|
|
12
|
+
import AnchorPressTracing from '../../examples/constellation/anchor/press-tracing';
|
|
13
|
+
import AnchorAnalytics from '../../examples/constellation/anchor/analytics';
|
|
14
|
+
import AnchorAnalyticsGASv3 from '../../examples/constellation/anchor/analytics-gasv3';
|
|
9
15
|
|
|
10
16
|
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
11
17
|
import SectionMessage from '@atlaskit/section-message';
|
|
@@ -16,18 +22,94 @@ import SectionMessage from '@atlaskit/section-message';
|
|
|
16
22
|
directoryName="primitives"
|
|
17
23
|
/>
|
|
18
24
|
|
|
19
|
-
Anchor is a primitive used for building custom
|
|
25
|
+
Anchor is a primitive used for building custom links with Atlassian Design System styling, routing support, and built-in event tracking. Ultimately it renders an anchor `<a>` element.
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
Only use anchor when existing components such as [link](/components/link/examples) or [link button](/components/button/link-button/examples) are unsuitable and unable to be customized to fit your needs.
|
|
22
28
|
|
|
23
29
|
## Default
|
|
24
30
|
|
|
25
|
-
Anchor
|
|
31
|
+
Anchor is unstyled besides a default underline. If you are using the [CSS reset](/components/css-reset/examples), it will also inherit some global styles.
|
|
26
32
|
|
|
27
33
|
<Example Component={AnchorDefault} packageName="@atlaskit/primitives/anchor" />
|
|
28
34
|
|
|
29
|
-
##
|
|
35
|
+
## Basic styling with XCSS
|
|
30
36
|
|
|
31
|
-
Anchor
|
|
37
|
+
Anchor can be styled using XCSS. It includes consistent Atlassian Design System `:focus` styles, so it's unnecessary to add your own.
|
|
38
|
+
|
|
39
|
+
For more information on XCSS, see the [XCSS documentation](/components/primitives/xcss).
|
|
40
|
+
|
|
41
|
+
<Example Component={AnchorBasic} packageName="@atlaskit/primitives/anchor" />
|
|
42
|
+
|
|
43
|
+
## Advanced styling
|
|
44
|
+
|
|
45
|
+
Use a combination of XCSS and other primitives for more complex designs.
|
|
32
46
|
|
|
33
47
|
<Example Component={AnchorStyled} packageName="@atlaskit/primitives/anchor" />
|
|
48
|
+
|
|
49
|
+
## HTML attributes
|
|
50
|
+
|
|
51
|
+
Anchor passes through all valid HTML attributes to the underlying `<a>` element.
|
|
52
|
+
|
|
53
|
+
<Example
|
|
54
|
+
Component={AnchorHtmlAttributes}
|
|
55
|
+
packageName="@atlaskit/primitives/anchor"
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
## Router links
|
|
59
|
+
|
|
60
|
+
Routing libraries often supply their own link components enhanced with routing support. This can be configured in the [AppProvider context](/components/app-provider/examples#router-links), and anchor will automatically use it.
|
|
61
|
+
|
|
62
|
+
This example shows a configuration for [React Resource Router](https://github.com/atlassian-labs/react-resource-router), however any routing library can be used.
|
|
63
|
+
|
|
64
|
+
Using this method, anchor accepts `href` as a string for standard usage. For advanced usage, an object can be passed.
|
|
65
|
+
|
|
66
|
+
Anchor will only render a router link if:
|
|
67
|
+
|
|
68
|
+
- a link component is set in the app provider
|
|
69
|
+
- it's not an external link (starting with `http://` or `https://`)
|
|
70
|
+
- it's not a non-HTTP-based link (e.g. emails, phone numbers, hash links etc.).
|
|
71
|
+
|
|
72
|
+
<Example
|
|
73
|
+
Component={AnchorRouterLinkConfiguration}
|
|
74
|
+
packageName="@atlaskit/primitives/anchor"
|
|
75
|
+
appearance="source-only"
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
## Event tracking
|
|
79
|
+
|
|
80
|
+
Anchor has utilities to make tracking events easier. Events will not be captured unless listeners are setup to handle them.
|
|
81
|
+
|
|
82
|
+
### Track events for any analytics provider
|
|
83
|
+
|
|
84
|
+
Anchor comes with built-in Atlaskit analytics support using the [Analytics next package](https://atlaskit.atlassian.com/packages/analytics/analytics-next), and fires events for available listeners. Currently this is only available for `onClick`.
|
|
85
|
+
|
|
86
|
+
It always fires events on the `atlaskit` channel. To also fire events on other channels, use the provided `analyticsEvent` in `onClick`. To configure event data, use `componentName` (defaults to 'Anchor') and `analyticsContext` for passing other metadata.
|
|
87
|
+
|
|
88
|
+
See the event data in the console.
|
|
89
|
+
|
|
90
|
+
<Example
|
|
91
|
+
Component={AnchorAnalytics}
|
|
92
|
+
packageName="@atlaskit/primitives/anchor"
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
### Track events for Atlassian internal services
|
|
96
|
+
|
|
97
|
+
#### GASv3 analytics
|
|
98
|
+
|
|
99
|
+
The Atlassian analytics bridge makes Atlaskit analytics events compatible with GASv3 (Global Analytics Service). This can also inject an `actionSubjectId` to the event if required.
|
|
100
|
+
|
|
101
|
+
See the event data in the console.
|
|
102
|
+
|
|
103
|
+
<Example
|
|
104
|
+
Component={AnchorAnalyticsGASv3}
|
|
105
|
+
packageName="@atlaskit/primitives/anchor"
|
|
106
|
+
/>
|
|
107
|
+
|
|
108
|
+
#### React UFO press interactions
|
|
109
|
+
|
|
110
|
+
By default, anchor fires [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions) for available listeners. This helps Atlassian measure performance and reliability. Additional detail can be provided using the `interactionName` prop.
|
|
111
|
+
|
|
112
|
+
<Example
|
|
113
|
+
Component={AnchorPressTracing}
|
|
114
|
+
packageName="@atlaskit/primitives/anchor"
|
|
115
|
+
/>
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Pressable
|
|
3
|
-
description: A pressable is a primitive
|
|
3
|
+
description: A pressable is a primitive for building custom buttons.
|
|
4
4
|
order: 0
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
import PressableDefault from '../../examples/constellation/pressable/default';
|
|
8
8
|
import PressableBasic from '../../examples/constellation/pressable/basic';
|
|
9
9
|
import PressableStyled from '../../examples/constellation/pressable/styled';
|
|
10
|
+
import PressableWithoutVisibleLabels from '../../examples/constellation/pressable/without-visible-labels';
|
|
10
11
|
import PressableDisabled from '../../examples/constellation/pressable/disabled';
|
|
12
|
+
import PressableHtmlAttributes from '../../examples/constellation/pressable/html-attributes';
|
|
13
|
+
import PressablePressTracing from '../../examples/constellation/pressable/press-tracing';
|
|
14
|
+
import PressableAnalytics from '../../examples/constellation/pressable/analytics';
|
|
15
|
+
import PressableAnalyticsGASv3 from '../../examples/constellation/pressable/analytics-gasv3';
|
|
11
16
|
|
|
12
17
|
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
13
18
|
import SectionMessage from '@atlaskit/section-message';
|
|
@@ -18,9 +23,9 @@ import SectionMessage from '@atlaskit/section-message';
|
|
|
18
23
|
directoryName="primitives"
|
|
19
24
|
/>
|
|
20
25
|
|
|
21
|
-
Pressable is a primitive used for building custom buttons with Atlassian Design System styling and built-in event tracking.
|
|
26
|
+
Pressable is a primitive used for building custom buttons with Atlassian Design System styling and built-in event tracking. It renders a `<button>` element.
|
|
22
27
|
|
|
23
|
-
Only use Pressable when existing components such as [
|
|
28
|
+
Only use Pressable when existing components such as [button](/components/button/examples) are unsuitable and unable to be customized to fit your needs.
|
|
24
29
|
|
|
25
30
|
## Default
|
|
26
31
|
|
|
@@ -33,17 +38,25 @@ Pressable is unstyled by default.
|
|
|
33
38
|
|
|
34
39
|
## Basic styling with XCSS
|
|
35
40
|
|
|
36
|
-
Pressable can be styled using XCSS. Ensure styling indicates the interaction state using `:hover` and `:active` pseudo-classes.
|
|
41
|
+
Pressable can be styled using XCSS. Ensure styling indicates the interaction state using `:hover` and `:active` pseudo-classes. Pressable includes consistent Atlassian Design System `:focus` styles, so it's unnecessary to add your own.
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
For more information on XCSS, see the dedicated [XCSS documentation](/components/primitives/xcss).
|
|
43
|
+
For more information on XCSS, see the [XCSS documentation](/components/primitives/xcss).
|
|
41
44
|
|
|
42
45
|
<Example
|
|
43
46
|
Component={PressableBasic}
|
|
44
47
|
packageName="@atlaskit/primitives/pressable"
|
|
45
48
|
/>
|
|
46
49
|
|
|
50
|
+
## Advanced styling
|
|
51
|
+
|
|
52
|
+
Use a combination of XCSS and other primitives for more complex designs.
|
|
53
|
+
|
|
54
|
+
<Example
|
|
55
|
+
Component={PressableStyled}
|
|
56
|
+
packageName="@atlaskit/primitives/pressable"
|
|
57
|
+
backgroundColor="white"
|
|
58
|
+
/>
|
|
59
|
+
|
|
47
60
|
## Disabled
|
|
48
61
|
|
|
49
62
|
Pressable can be disabled using the `isDisabled` prop. Disabled styles should be conditionally applied and defined using XCSS.
|
|
@@ -53,12 +66,62 @@ Pressable can be disabled using the `isDisabled` prop. Disabled styles should be
|
|
|
53
66
|
packageName="@atlaskit/primitives/pressable"
|
|
54
67
|
/>
|
|
55
68
|
|
|
56
|
-
##
|
|
69
|
+
## Buttons without visible labels
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
For buttons without visible labels such as icon buttons, ensure an accessible label is still available by using [the visually hidden component](/components/visually-hidden/examples). This will render hidden text inside the button, which is preferable over the `aria-label` attribute because not all screen readers translate this between languages.
|
|
72
|
+
|
|
73
|
+
Provide a tooltip to help sighted users understand the button's purpose rather than relying on iconography alone.
|
|
59
74
|
|
|
60
75
|
<Example
|
|
61
|
-
Component={
|
|
76
|
+
Component={PressableWithoutVisibleLabels}
|
|
62
77
|
packageName="@atlaskit/primitives/pressable"
|
|
63
78
|
backgroundColor="white"
|
|
64
79
|
/>
|
|
80
|
+
|
|
81
|
+
## HTML attributes
|
|
82
|
+
|
|
83
|
+
Pressable passes through all valid HTML attributes to the underlying `<button>` element. It will default the `type` attribute to `button` to prevent buttons unintentionally submitting forms.
|
|
84
|
+
|
|
85
|
+
<Example
|
|
86
|
+
Component={PressableHtmlAttributes}
|
|
87
|
+
packageName="@atlaskit/primitives/pressable"
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
## Event tracking
|
|
91
|
+
|
|
92
|
+
Pressable has utilities to make tracking events easier. Events will not be captured unless listeners are setup to handle them.
|
|
93
|
+
|
|
94
|
+
### Track events for any analytics provider
|
|
95
|
+
|
|
96
|
+
Pressable comes with built-in Atlaskit analytics support using the [Analytics next package](https://atlaskit.atlassian.com/packages/analytics/analytics-next), and fires events for available listeners. Currently this is only available for `onClick`.
|
|
97
|
+
|
|
98
|
+
It always fires events on the `atlaskit` channel. To also fire events on other channels, use the provided `analyticsEvent` in `onClick`. To configure event data, use `componentName` (defaults to 'Pressable') and `analyticsContext` for passing other metadata.
|
|
99
|
+
|
|
100
|
+
See the event data in the console.
|
|
101
|
+
|
|
102
|
+
<Example
|
|
103
|
+
Component={PressableAnalytics}
|
|
104
|
+
packageName="@atlaskit/primitives/pressable"
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
### Track events for Atlassian internal services
|
|
108
|
+
|
|
109
|
+
#### GASv3 analytics
|
|
110
|
+
|
|
111
|
+
The Atlassian analytics bridge makes Atlaskit analytics events compatible with GASv3 (Global Analytics Service). This can also inject an `actionSubjectId` to the event if required.
|
|
112
|
+
|
|
113
|
+
See the event data in the console.
|
|
114
|
+
|
|
115
|
+
<Example
|
|
116
|
+
Component={PressableAnalyticsGASv3}
|
|
117
|
+
packageName="@atlaskit/primitives/pressable"
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
#### React UFO press interactions
|
|
121
|
+
|
|
122
|
+
By default, pressable fires [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions) for available listeners. This helps Atlassian measure performance and reliability. Additional detail can be provided using the `interactionName` prop.
|
|
123
|
+
|
|
124
|
+
<Example
|
|
125
|
+
Component={PressablePressTracing}
|
|
126
|
+
packageName="@atlaskit/primitives/pressable"
|
|
127
|
+
/>
|
|
@@ -4,40 +4,72 @@ description: Text is a token-backed typography component to display body text.
|
|
|
4
4
|
order: 0
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
7
|
+
import TextBasic from '../../examples/constellation/text/text-basic';
|
|
8
|
+
import TextColorInverse from '../../examples/constellation/text/text-color-inverse';
|
|
9
|
+
import TextColorInherit from '../../examples/constellation/text/text-color-inherit';
|
|
10
|
+
import TextWeight from '../../examples/constellation/text/text-weight';
|
|
11
|
+
import TextAlign from '../../examples/constellation/text/text-align';
|
|
12
|
+
import TextAsElement from '../../examples/constellation/text/text-as-element';
|
|
13
|
+
import TextSpacing from '../../examples/constellation/text/text-spacing';
|
|
14
|
+
import TextTruncation from '../../examples/constellation/text/text-truncation';
|
|
12
15
|
|
|
13
16
|
## Basic
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
Use a Text component for main content. Text typically appears after headings or subheadings as detailed descriptions and messages, but also as standalone text in components.
|
|
16
19
|
|
|
17
|
-
The `size` prop expresses the visual appearance of the text element
|
|
20
|
+
The `size` prop expresses the visual appearance of the text element:
|
|
21
|
+
- `'large'` is for long-form content. Use this size for a comfortable reading experience such as in blogs.
|
|
22
|
+
- `'medium'` is the default size in components or where space is limited, for detailed or descriptive content such as primary descriptions in flags.
|
|
23
|
+
- `'small'` should be used sparingly and is for secondary level content such as fine print or semantic messaging.
|
|
18
24
|
|
|
19
|
-
<Example Component={
|
|
25
|
+
<Example Component={TextBasic} packageName="@atlaskit/primitives" />
|
|
20
26
|
|
|
21
27
|
## Color
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
Text uses the `color.text` token which automatically switches colors to be legible across both light and dark modes.
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
Text will automatically apply the correct inverse color token if placed within a [box component](/components/primitives/box) with a bold background color.
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
<Example Component={TextColorInverse} packageName="@atlaskit/primitives" />
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
The `color` prop can be used with any text color token. If Text is nested inside another Text component, color will automatically inherit from its parent.
|
|
30
36
|
|
|
31
|
-
<Example Component={
|
|
37
|
+
<Example Component={TextColorInherit} packageName="@atlaskit/primitives" />
|
|
38
|
+
|
|
39
|
+
## Font weight
|
|
40
|
+
|
|
41
|
+
Font weight defaults to regular (400) and can be set using the `weight` prop.
|
|
42
|
+
More information about the available weights can be found on the [typography foundations page](/foundations/typography-beta/#body-font-weight).
|
|
43
|
+
|
|
44
|
+
Note: Text supports the semibold weight, however due to differences between font stacks across different operating systems, semibold text may render as bold.
|
|
45
|
+
We recommend using regular, medium, and bold for the best results.
|
|
46
|
+
|
|
47
|
+
<Example Component={TextWeight} packageName="@atlaskit/primitives" />
|
|
32
48
|
|
|
33
49
|
## Alignment
|
|
34
50
|
|
|
35
|
-
|
|
51
|
+
Text can be aligned using the `align` prop.
|
|
52
|
+
|
|
53
|
+
<Example Component={TextAlign} packageName="@atlaskit/primitives" />
|
|
54
|
+
|
|
55
|
+
## Rendered HTML element
|
|
56
|
+
|
|
57
|
+
Text renders a HTML `<span>` element by default. Use the `as` prop to change the rendered HTML element.
|
|
58
|
+
|
|
59
|
+
<Example Component={TextAsElement} packageName="@atlaskit/primitives" />
|
|
60
|
+
|
|
61
|
+
## Arrangement with other text styles
|
|
62
|
+
|
|
63
|
+
Text does not apply any vertical margin or spacing. To control space between text and other content, use a [stack component](/components/primitives/stack).
|
|
64
|
+
|
|
65
|
+
The available values for paragraph spacing are outlined in the [Typography foundations](/foundations/typography-beta/#body) page.
|
|
66
|
+
|
|
67
|
+
<Example Component={TextSpacing} packageName="@atlaskit/primitives" />
|
|
36
68
|
|
|
37
|
-
|
|
69
|
+
## Truncation
|
|
38
70
|
|
|
39
|
-
|
|
71
|
+
Truncation in product experiences [should be avoided](/content/language-and-grammar/#truncation).
|
|
40
72
|
|
|
41
|
-
|
|
73
|
+
However if truncation cannot be avoided, for example when displaying user-generated content, use the `maxLines` prop to indicate how text should be truncated.
|
|
42
74
|
|
|
43
|
-
<Example Component={
|
|
75
|
+
<Example Component={TextTruncation} packageName="@atlaskit/primitives" />
|
|
@@ -6,4 +6,14 @@ order: 2
|
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
|
-
Use
|
|
9
|
+
Use the text component for all non-heading text, including main content, detailed descriptions, and text in components.
|
|
10
|
+
|
|
11
|
+
For each size, a specific line height is automatically set ensuring text is compliant with accessibility standards.
|
|
12
|
+
|
|
13
|
+
Read more usage guidance for body text in our [Typography foundations](/foundations/typography-beta#body).
|
|
14
|
+
|
|
15
|
+
## Accessibility
|
|
16
|
+
|
|
17
|
+
### Color contrast
|
|
18
|
+
|
|
19
|
+
Text should be a minimum of 4.5:1 color contrast.
|
|
@@ -8,17 +8,23 @@ import { MediaQueriesTable } from '@af/design-system-docs-ui';
|
|
|
8
8
|
|
|
9
9
|
XCSS is an Atlassian Design System styling API that natively integrates with Atlassian's [design tokens](/tokens) and [primitives](/components/primitives/overview).
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
To ensure future compliance with XCSS as it evolves over time, we highly recommend you enable our ESLint plugins and adhere to the [UI Styling Standard](/components/eslint-plugin-ui-styling-standard) guidelines by writing local, type-safe, static styles.
|
|
12
|
+
|
|
13
|
+
- [@atlaskit/eslint-plugin-design-system](/components/eslint-plugin-design-system)
|
|
14
|
+
- [@atlaskit/eslint-plugin-ui-styling-standard](/components/eslint-plugin-ui-styling-standard)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
The XCSS utility behaves similarly to the `css` utility in libraries like `styled-components`, `@compiled` or `@emotion`, and is built off of `@emotion/react` today. If you've used these libraries, XCSS will feel familiar, with a few additional features and constraints.
|
|
12
18
|
|
|
13
19
|
Familiar features:
|
|
14
20
|
|
|
15
|
-
- XCSS
|
|
16
|
-
- XCSS
|
|
21
|
+
- XCSS is applied as an Emotion `className` to our primitive components
|
|
22
|
+
- XCSS works with the basic CSS object interface found elsewhere
|
|
17
23
|
- XCSS supports style precedence and conditional styles
|
|
18
24
|
|
|
19
25
|
Key differences:
|
|
20
26
|
|
|
21
|
-
- XCSS has type-safety that ensures token name usage for all CSS properties represented by design tokens
|
|
27
|
+
- XCSS has type-safety that ensures token name usage for all CSS properties represented by design tokens
|
|
22
28
|
- XCSS restricts nested selectors completely from usage
|
|
23
29
|
|
|
24
30
|
## Usage
|
|
@@ -115,7 +121,7 @@ The only limitation is that a media query can't contain another media query. Thi
|
|
|
115
121
|
|
|
116
122
|
Additionally, pseudo-selectors can't contain media queries. To use media queries and pseudos, the media query must contain the pseudo.
|
|
117
123
|
|
|
118
|
-
```
|
|
124
|
+
```tsx
|
|
119
125
|
import { xcss } from '@atlaskit/primitives';
|
|
120
126
|
import { media } from '@atlaskit/primitives/responsive';
|
|
121
127
|
|
|
@@ -127,7 +133,7 @@ const someStyles = xcss({
|
|
|
127
133
|
}
|
|
128
134
|
},
|
|
129
135
|
|
|
130
|
-
// This is not okay,
|
|
136
|
+
// This is not okay, we don't allow pseudos to contain media queries
|
|
131
137
|
':hover': {
|
|
132
138
|
[media.above.md]: {
|
|
133
139
|
backgroundColor: 'color.background.primary.hovered'
|
|
@@ -76,7 +76,7 @@ var Anchor = function Anchor(_ref, ref) {
|
|
|
76
76
|
action: 'clicked',
|
|
77
77
|
componentName: componentName || 'Anchor',
|
|
78
78
|
packageName: "@atlaskit/primitives",
|
|
79
|
-
packageVersion: "6.
|
|
79
|
+
packageVersion: "6.2.0",
|
|
80
80
|
analyticsData: analyticsContext,
|
|
81
81
|
actionSubject: 'link'
|
|
82
82
|
});
|
|
@@ -94,7 +94,7 @@ var Anchor = function Anchor(_ref, ref) {
|
|
|
94
94
|
*
|
|
95
95
|
* - a link component is set in the app provider
|
|
96
96
|
* - it's not an external link (starting with `http://` or `https://`)
|
|
97
|
-
* - it's not a non-HTTP-based link (e.g.
|
|
97
|
+
* - it's not a non-HTTP-based link (e.g. emails, phone numbers, hash links etc.).
|
|
98
98
|
*/
|
|
99
99
|
var isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
|
|
100
100
|
var hrefObjectUsedWithoutRouterLink = RouterLink === undefined && (0, _typeof2.default)(href) === 'object';
|
|
@@ -41,9 +41,7 @@ var focusRingStyles = (0, _xcss.xcss)({
|
|
|
41
41
|
/**
|
|
42
42
|
* __Pressable__
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* A Pressable is a primitive component that renders a `<button>`.
|
|
44
|
+
* A primitive for building custom buttons.
|
|
47
45
|
*
|
|
48
46
|
* - [Examples](https://atlassian.design/components/primitives/pressable/examples)
|
|
49
47
|
* - [Code](https://atlassian.design/components/primitives/pressable/code)
|
|
@@ -80,7 +78,7 @@ var Pressable = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
80
78
|
action: 'clicked',
|
|
81
79
|
componentName: componentName || 'Pressable',
|
|
82
80
|
packageName: "@atlaskit/primitives",
|
|
83
|
-
packageVersion: "6.
|
|
81
|
+
packageVersion: "6.2.0",
|
|
84
82
|
analyticsData: analyticsContext,
|
|
85
83
|
actionSubject: 'button'
|
|
86
84
|
});
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Hide = void 0;
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
|
+
var _xcss = require("../xcss/xcss");
|
|
8
9
|
var _buildMediaQueryCss = require("./build-media-query-css");
|
|
9
10
|
/** @jsx jsx */
|
|
10
11
|
|
|
@@ -27,8 +28,11 @@ var Hide = exports.Hide = function Hide(_ref) {
|
|
|
27
28
|
below = _ref.below,
|
|
28
29
|
children = _ref.children,
|
|
29
30
|
_ref$as = _ref.as,
|
|
30
|
-
AsElement = _ref$as === void 0 ? 'div' : _ref$as
|
|
31
|
+
AsElement = _ref$as === void 0 ? 'div' : _ref$as,
|
|
32
|
+
xcss = _ref.xcss;
|
|
33
|
+
var resolvedStyles = (0, _xcss.parseXcss)(xcss);
|
|
31
34
|
return (0, _react.jsx)(AsElement, {
|
|
32
|
-
|
|
35
|
+
className: resolvedStyles.static,
|
|
36
|
+
css: [above && hideAboveQueries[above], below && hideBelowQueries[below], resolvedStyles.emotion]
|
|
33
37
|
}, children);
|
|
34
38
|
};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Show = void 0;
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
|
+
var _xcss = require("../xcss/xcss");
|
|
8
9
|
var _buildMediaQueryCss = require("./build-media-query-css");
|
|
9
10
|
/** @jsx jsx */
|
|
10
11
|
|
|
@@ -30,8 +31,11 @@ var Show = exports.Show = function Show(_ref) {
|
|
|
30
31
|
below = _ref.below,
|
|
31
32
|
children = _ref.children,
|
|
32
33
|
_ref$as = _ref.as,
|
|
33
|
-
AsElement = _ref$as === void 0 ? 'div' : _ref$as
|
|
34
|
+
AsElement = _ref$as === void 0 ? 'div' : _ref$as,
|
|
35
|
+
xcss = _ref.xcss;
|
|
36
|
+
var resolvedStyles = (0, _xcss.parseXcss)(xcss);
|
|
34
37
|
return (0, _react.jsx)(AsElement, {
|
|
35
|
-
|
|
38
|
+
className: resolvedStyles.static,
|
|
39
|
+
css: [defaultHiddenStyles, above && showAboveQueries[above], below && showBelowQueries[below], resolvedStyles.emotion]
|
|
36
40
|
}, children);
|
|
37
41
|
};
|
|
@@ -497,7 +497,7 @@ var borderRadiusMap = exports.borderRadiusMap = {
|
|
|
497
497
|
|
|
498
498
|
/**
|
|
499
499
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
500
|
-
* @codegen <<SignedSource::
|
|
500
|
+
* @codegen <<SignedSource::01b50b6fc795db50002edbeb24634575>>
|
|
501
501
|
* @codegenId typography
|
|
502
502
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
503
503
|
* @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
|
|
@@ -517,8 +517,11 @@ var fontWeightMap = exports.fontWeightMap = {
|
|
|
517
517
|
semibold: "var(--ds-font-weight-semibold, 600)"
|
|
518
518
|
};
|
|
519
519
|
var fontFamilyMap = exports.fontFamilyMap = {
|
|
520
|
+
'font.family.body': "var(--ds-font-family-body, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
520
521
|
'font.family.brand.body': "var(--ds-font-family-brand-body, \"Charlie Text\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
521
|
-
'font.family.brand.heading': "var(--ds-font-family-brand-heading, \"Charlie Display\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
|
|
522
|
+
'font.family.brand.heading': "var(--ds-font-family-brand-heading, \"Charlie Display\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
523
|
+
'font.family.code': "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
|
|
524
|
+
'font.family.heading': "var(--ds-font-family-heading, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
|
|
522
525
|
};
|
|
523
526
|
|
|
524
527
|
/**
|
|
@@ -62,7 +62,7 @@ const Anchor = ({
|
|
|
62
62
|
action: 'clicked',
|
|
63
63
|
componentName: componentName || 'Anchor',
|
|
64
64
|
packageName: "@atlaskit/primitives",
|
|
65
|
-
packageVersion: "6.
|
|
65
|
+
packageVersion: "6.2.0",
|
|
66
66
|
analyticsData: analyticsContext,
|
|
67
67
|
actionSubject: 'link'
|
|
68
68
|
});
|
|
@@ -80,7 +80,7 @@ const Anchor = ({
|
|
|
80
80
|
*
|
|
81
81
|
* - a link component is set in the app provider
|
|
82
82
|
* - it's not an external link (starting with `http://` or `https://`)
|
|
83
|
-
* - it's not a non-HTTP-based link (e.g.
|
|
83
|
+
* - it's not a non-HTTP-based link (e.g. emails, phone numbers, hash links etc.).
|
|
84
84
|
*/
|
|
85
85
|
const isRouterLink = RouterLink && !isExternal && !isNonHttpBased;
|
|
86
86
|
const hrefObjectUsedWithoutRouterLink = RouterLink === undefined && typeof href === 'object';
|
|
@@ -28,9 +28,7 @@ const focusRingStyles = xcss({
|
|
|
28
28
|
/**
|
|
29
29
|
* __Pressable__
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* A Pressable is a primitive component that renders a `<button>`.
|
|
31
|
+
* A primitive for building custom buttons.
|
|
34
32
|
*
|
|
35
33
|
* - [Examples](https://atlassian.design/components/primitives/pressable/examples)
|
|
36
34
|
* - [Code](https://atlassian.design/components/primitives/pressable/code)
|
|
@@ -66,7 +64,7 @@ const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
66
64
|
action: 'clicked',
|
|
67
65
|
componentName: componentName || 'Pressable',
|
|
68
66
|
packageName: "@atlaskit/primitives",
|
|
69
|
-
packageVersion: "6.
|
|
67
|
+
packageVersion: "6.2.0",
|
|
70
68
|
analyticsData: analyticsContext,
|
|
71
69
|
actionSubject: 'button'
|
|
72
70
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
+
import { parseXcss } from '../xcss/xcss';
|
|
4
5
|
import { UNSAFE_buildAboveMediaQueryCSS, UNSAFE_buildBelowMediaQueryCSS } from './build-media-query-css';
|
|
5
6
|
const hideAboveQueries = UNSAFE_buildAboveMediaQueryCSS({
|
|
6
7
|
display: 'none'
|
|
@@ -20,9 +21,12 @@ export const Hide = ({
|
|
|
20
21
|
above,
|
|
21
22
|
below,
|
|
22
23
|
children,
|
|
23
|
-
as: AsElement = 'div'
|
|
24
|
+
as: AsElement = 'div',
|
|
25
|
+
xcss
|
|
24
26
|
}) => {
|
|
27
|
+
const resolvedStyles = parseXcss(xcss);
|
|
25
28
|
return jsx(AsElement, {
|
|
26
|
-
|
|
29
|
+
className: resolvedStyles.static,
|
|
30
|
+
css: [above && hideAboveQueries[above], below && hideBelowQueries[below], resolvedStyles.emotion]
|
|
27
31
|
}, children);
|
|
28
32
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { parseXcss } from '../xcss/xcss';
|
|
4
5
|
import { UNSAFE_buildAboveMediaQueryCSS, UNSAFE_buildBelowMediaQueryCSS } from './build-media-query-css';
|
|
5
6
|
const showAboveQueries = UNSAFE_buildAboveMediaQueryCSS({
|
|
6
7
|
display: 'revert'
|
|
@@ -23,9 +24,12 @@ export const Show = ({
|
|
|
23
24
|
above,
|
|
24
25
|
below,
|
|
25
26
|
children,
|
|
26
|
-
as: AsElement = 'div'
|
|
27
|
+
as: AsElement = 'div',
|
|
28
|
+
xcss
|
|
27
29
|
}) => {
|
|
30
|
+
const resolvedStyles = parseXcss(xcss);
|
|
28
31
|
return jsx(AsElement, {
|
|
29
|
-
|
|
32
|
+
className: resolvedStyles.static,
|
|
33
|
+
css: [defaultHiddenStyles, above && showAboveQueries[above], below && showBelowQueries[below], resolvedStyles.emotion]
|
|
30
34
|
}, children);
|
|
31
35
|
};
|