@atlaskit/primitives 6.5.0 → 7.0.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 +18 -0
- package/constellation/anchor/examples.mdx +8 -8
- package/constellation/anchor/usage.mdx +33 -22
- package/dist/cjs/components/anchor.js +1 -1
- package/dist/cjs/components/pressable.js +1 -1
- package/dist/cjs/xcss/xcss.js +1 -1
- package/dist/es2019/components/anchor.js +1 -1
- package/dist/es2019/components/pressable.js +1 -1
- package/dist/es2019/xcss/xcss.js +1 -1
- package/dist/esm/components/anchor.js +1 -1
- package/dist/esm/components/pressable.js +1 -1
- package/dist/esm/xcss/xcss.js +1 -1
- package/dist/types/xcss/xcss.d.ts +1 -1
- package/dist/types-ts4.5/xcss/xcss.d.ts +1 -1
- package/extract-react-types/anchor-props.tsx +6 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 7.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#108387](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/108387)
|
|
8
|
+
[`0f3b7b4c63c6d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0f3b7b4c63c6d) -
|
|
9
|
+
`xcss`: Restrict valid chained pseudo-selectors a limited subset:
|
|
10
|
+
|
|
11
|
+
- `:visited:active`
|
|
12
|
+
- `:active:visited`
|
|
13
|
+
- `:hover::before`
|
|
14
|
+
- `:hover::after`
|
|
15
|
+
- `:focus-visible::before`
|
|
16
|
+
- `:focus-visible::after`
|
|
17
|
+
|
|
18
|
+
Previously, any combination of two pseudo-selectors was allowed. This decision was made to improve
|
|
19
|
+
performance for TypeScript compilation and IDE type hinting.
|
|
20
|
+
|
|
3
21
|
## 6.5.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -22,21 +22,21 @@ import SectionMessage from '@atlaskit/section-message';
|
|
|
22
22
|
directoryName="primitives"
|
|
23
23
|
/>
|
|
24
24
|
|
|
25
|
-
Anchor is a primitive
|
|
25
|
+
Anchor is a primitive for building custom links with Atlassian Design System styling, routing support, and built-in event tracking. It renders an anchor `<a>` element.
|
|
26
26
|
|
|
27
|
-
Only use anchor when existing components such as [link](/components/link/examples) or [link button](/components/button/link-button/examples)
|
|
27
|
+
Only use anchor when existing components such as [link](/components/link/examples) or [link button](/components/button/link-button/examples) can't be customized to fit your needs.
|
|
28
28
|
|
|
29
29
|
## Default
|
|
30
30
|
|
|
31
|
-
Anchor is unstyled besides a default underline
|
|
31
|
+
Anchor is unstyled besides a default underline and consistent Atlassian Design System `:focus` styles.
|
|
32
|
+
|
|
33
|
+
If you are using the [CSS reset](/components/css-reset/examples), anchor will also inherit some global styles.
|
|
32
34
|
|
|
33
35
|
<Example Component={AnchorDefault} packageName="@atlaskit/primitives/anchor" />
|
|
34
36
|
|
|
35
37
|
## Basic styling with XCSS
|
|
36
38
|
|
|
37
|
-
Anchor can be styled using
|
|
38
|
-
|
|
39
|
-
For more information on XCSS, see the [XCSS documentation](/components/primitives/xcss).
|
|
39
|
+
Anchor can be styled further using the design system styling API, [XCSS](/components/primitives/xcss).
|
|
40
40
|
|
|
41
41
|
<Example Component={AnchorBasic} packageName="@atlaskit/primitives/anchor" />
|
|
42
42
|
|
|
@@ -48,7 +48,7 @@ Use a combination of XCSS and other primitives for more complex designs.
|
|
|
48
48
|
|
|
49
49
|
## HTML attributes
|
|
50
50
|
|
|
51
|
-
Anchor
|
|
51
|
+
Anchor can pass all valid [anchor HTML attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes), such as `rel` or `download`, to the underlying `<a>` element.
|
|
52
52
|
|
|
53
53
|
<Example
|
|
54
54
|
Component={AnchorHtmlAttributes}
|
|
@@ -57,7 +57,7 @@ Anchor passes through all valid HTML attributes to the underlying `<a>` element.
|
|
|
57
57
|
|
|
58
58
|
## Router links
|
|
59
59
|
|
|
60
|
-
Routing libraries often supply
|
|
60
|
+
Routing libraries often supply link components enhanced with routing support. You can configure this in the [AppProvider context](/components/app-provider/examples#router-links), and anchor will automatically use it.
|
|
61
61
|
|
|
62
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
63
|
|
|
@@ -6,28 +6,30 @@ order: 2
|
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Use an anchor to make elements that work like hyperlinks. Anchors can navigate to any linkable location such as a web page, a location on a page, a file download, or a `mailto` email address.
|
|
10
10
|
|
|
11
|
-
Anchor has consistent focus styles and analytics built in. It works with design tokens to make it easy to compose Atlassian-styled links that aren't possible using the [link component](/components/link/examples), [link buttons](/components/button/link-button/examples), or other existing design system components.
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
Anchor is based on the HTML `<a>` tag, but with Atlassian focus styles and analytics events built in. You can customize the anchor's appearance further using our styling APIs.
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
For example, an anchor could be used to make [a link card](/components/primitives/anchor/examples#advanced-styling) with a larger clickable area than a typical [link](/components/link/examples).
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
|
|
17
|
+
### Use links, link buttons, or other existing components where possible
|
|
18
|
+
|
|
19
|
+
Anchor is meant for custom elements and styles that aren't possible using other components. For standard links or buttons that navigate users to a new location, use [link](/components/link/examples) or [link button](/components/button/link-button/examples).
|
|
20
|
+
|
|
21
|
+
Using [existing components](/components) wherever possible makes Atlassian's UI more visually consistent, and these components are faster to use for most basic use cases.
|
|
18
22
|
|
|
19
23
|
## Accessibility
|
|
20
24
|
|
|
21
|
-
###
|
|
25
|
+
### Show what's clickable using underlines or other affordances
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
Anchors have an underline by default. This helps differentiate links from regular text, which is an accessibility requirement. Using color alone to differentiate links isn't accessible, especially if links are surrounded by other text.
|
|
24
28
|
|
|
25
|
-
Only remove underlines if the context surrounding the link makes it clear that it
|
|
29
|
+
Only remove underlines if the context surrounding the link makes it clear that it's interactive, such as in navigation or a card layout.
|
|
26
30
|
|
|
27
31
|
Also, don't underline text that isn't a link. This makes the text look clickable because it looks a link.
|
|
28
32
|
|
|
29
|
-
For more information see ['Understanding Use of Color (Level A)'](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html) and ['Failure of Success Criterion 1.4.1 due to creating links that are not visually evident without color vision'](https://www.w3.org/WAI/WCAG22/Techniques/failures/F73).
|
|
30
|
-
|
|
31
33
|
<!-- TODO: Add do/dont images once designed (if necessary?) -->
|
|
32
34
|
|
|
33
35
|
<DoDont type="do">
|
|
@@ -37,13 +39,27 @@ For more information see ['Understanding Use of Color (Level A)'](https://www.w3
|
|
|
37
39
|
|
|
38
40
|
<DoDont type="dont">Use underlined links in navigation.</DoDont>
|
|
39
41
|
|
|
42
|
+
For more information see ['Understanding Use of Color (Level A)'](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html) and ['Failure of Success Criterion 1.4.1 due to creating links that are not visually evident without color vision'](https://www.w3.org/WAI/WCAG22/Techniques/failures/F73).
|
|
43
|
+
|
|
44
|
+
### Use anchor for links and navigation, not on-page actions
|
|
45
|
+
|
|
46
|
+
Anchors are for navigation and URL changes, while buttons are for on-page actions such as form submissions or opening modals. These elements are treated differently by assistive technologies, so avoid using one in place of the other.
|
|
47
|
+
|
|
48
|
+
Don't use anchor to make custom actions rather than navigation elements. To build a custom action or button, use the [pressable primitive](/components/primitives/pressable/examples) instead.
|
|
49
|
+
|
|
50
|
+
More on [when to use links vs buttons](/components/button/usage#use-buttons-for-actions-and-links-for-navigation).
|
|
51
|
+
|
|
52
|
+
|
|
40
53
|
### Use descriptive link text that clarifies the purpose of the link
|
|
41
54
|
|
|
42
|
-
Don't link vague words or phrases like “here” or “learn more.” Make sure the linked text clearly describes the purpose of the link.
|
|
55
|
+
Don't link vague words or phrases like “here” or “learn more.” Make sure the linked text clearly describes the purpose of the link for assistive technologies.
|
|
43
56
|
|
|
57
|
+
See [link content guidelines](/components/primitives/anchor/usage#content-guidelines) for details and examples.
|
|
58
|
+
|
|
59
|
+
<!-- TODO: Crosslink updated link content guidance. Should be info in language and grammar and link component. (snippet time?) -->
|
|
44
60
|
<!-- TODO: Add some Do/Don't images as examples -->
|
|
45
61
|
|
|
46
|
-
<DoDont type="do">
|
|
62
|
+
<DoDont type="do">Link text that describes the purpose of the link.</DoDont>
|
|
47
63
|
|
|
48
64
|
<DoDont type="dont">Link vague words or phrases.</DoDont>
|
|
49
65
|
|
|
@@ -62,13 +78,6 @@ For more information see ['G200: Opening new windows and tabs from a link only w
|
|
|
62
78
|
|
|
63
79
|
Make link text size at least 12px. Smaller text is harder to read and interact with. If anchor is not used for text-based links, ensure the clickable area is at least 24 by 24 pixels for accessibility unless exempt from [Target Size (Minimum) (Level AA)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html).
|
|
64
80
|
|
|
65
|
-
## Best practices
|
|
66
|
-
|
|
67
|
-
### Don't confuse links and buttons
|
|
68
|
-
|
|
69
|
-
Anchors are for navigation and URL changes, while buttons are for on-page actions such as form submissions or opening modals. These elements are treated differently by assistive technologies, so avoid using one in place of the other.
|
|
70
|
-
|
|
71
|
-
More details on [when to use links and buttons](/components/button/usage#use-buttons-for-actions-and-links-for-navigation).
|
|
72
81
|
|
|
73
82
|
## Content guidelines
|
|
74
83
|
|
|
@@ -80,6 +89,8 @@ Try not to repeat the same link text over and over on a page. Make sure link tex
|
|
|
80
89
|
|
|
81
90
|
Always specify if a link triggers a download, and make the linked text clear about what exactly will be downloaded. Include file type and size as well.
|
|
82
91
|
|
|
92
|
+
<!-- TODO: add example of this -->
|
|
93
|
+
|
|
83
94
|
### Don't include unnecessary links
|
|
84
95
|
|
|
85
96
|
Using too many links can overwhelm other, more important information on a page.
|
|
@@ -106,6 +117,6 @@ These type of links typically follow general button or other label content rules
|
|
|
106
117
|
|
|
107
118
|
## Related
|
|
108
119
|
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
- Anchor is built on the same API as [box](/components/primitives/box/usage)
|
|
120
|
+
- Use existing components such as [link](/components/link/examples) or [link button](/components/button/link-button/examples) wherever possible.
|
|
121
|
+
- Use [pressable primitive for custom buttons](/components/primitives/button/usage).
|
|
122
|
+
- Anchor is built on the same API as [box](/components/primitives/box/usage).
|
|
@@ -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: "
|
|
79
|
+
packageVersion: "7.0.0",
|
|
80
80
|
analyticsData: analyticsContext,
|
|
81
81
|
actionSubject: 'link'
|
|
82
82
|
});
|
|
@@ -78,7 +78,7 @@ var Pressable = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
78
78
|
action: 'clicked',
|
|
79
79
|
componentName: componentName || 'Pressable',
|
|
80
80
|
packageName: "@atlaskit/primitives",
|
|
81
|
-
packageVersion: "
|
|
81
|
+
packageVersion: "7.0.0",
|
|
82
82
|
analyticsData: analyticsContext,
|
|
83
83
|
actionSubject: 'button'
|
|
84
84
|
});
|
package/dist/cjs/xcss/xcss.js
CHANGED
|
@@ -212,7 +212,7 @@ var parseXcss = exports.parseXcss = function parseXcss(args) {
|
|
|
212
212
|
|
|
213
213
|
// Media queries should not contain nested media queries
|
|
214
214
|
|
|
215
|
-
// Allow chained
|
|
215
|
+
// Allow only a specific subset of chained selectors to maintain workable TypeScript performance
|
|
216
216
|
|
|
217
217
|
// Pseudos should not contain nested pseudos, or media queries
|
|
218
218
|
|
|
@@ -64,7 +64,7 @@ const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
64
64
|
action: 'clicked',
|
|
65
65
|
componentName: componentName || 'Pressable',
|
|
66
66
|
packageName: "@atlaskit/primitives",
|
|
67
|
-
packageVersion: "
|
|
67
|
+
packageVersion: "7.0.0",
|
|
68
68
|
analyticsData: analyticsContext,
|
|
69
69
|
actionSubject: 'button'
|
|
70
70
|
});
|
package/dist/es2019/xcss/xcss.js
CHANGED
|
@@ -190,7 +190,7 @@ export const parseXcss = args => {
|
|
|
190
190
|
|
|
191
191
|
// Media queries should not contain nested media queries
|
|
192
192
|
|
|
193
|
-
// Allow chained
|
|
193
|
+
// Allow only a specific subset of chained selectors to maintain workable TypeScript performance
|
|
194
194
|
|
|
195
195
|
// Pseudos should not contain nested pseudos, or media queries
|
|
196
196
|
|
|
@@ -66,7 +66,7 @@ var Anchor = function Anchor(_ref, ref) {
|
|
|
66
66
|
action: 'clicked',
|
|
67
67
|
componentName: componentName || 'Anchor',
|
|
68
68
|
packageName: "@atlaskit/primitives",
|
|
69
|
-
packageVersion: "
|
|
69
|
+
packageVersion: "7.0.0",
|
|
70
70
|
analyticsData: analyticsContext,
|
|
71
71
|
actionSubject: 'link'
|
|
72
72
|
});
|
|
@@ -68,7 +68,7 @@ var Pressable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
68
68
|
action: 'clicked',
|
|
69
69
|
componentName: componentName || 'Pressable',
|
|
70
70
|
packageName: "@atlaskit/primitives",
|
|
71
|
-
packageVersion: "
|
|
71
|
+
packageVersion: "7.0.0",
|
|
72
72
|
analyticsData: analyticsContext,
|
|
73
73
|
actionSubject: 'button'
|
|
74
74
|
});
|
package/dist/esm/xcss/xcss.js
CHANGED
|
@@ -208,7 +208,7 @@ export var parseXcss = function parseXcss(args) {
|
|
|
208
208
|
|
|
209
209
|
// Media queries should not contain nested media queries
|
|
210
210
|
|
|
211
|
-
// Allow chained
|
|
211
|
+
// Allow only a specific subset of chained selectors to maintain workable TypeScript performance
|
|
212
212
|
|
|
213
213
|
// Pseudos should not contain nested pseudos, or media queries
|
|
214
214
|
|
|
@@ -1643,7 +1643,7 @@ type AllMedia = MediaQuery | '@media screen and (forced-colors: active), screen
|
|
|
1643
1643
|
type CSSMediaQueries = {
|
|
1644
1644
|
[MQ in AllMedia]?: Omit<SafeCSSObject, AllMedia>;
|
|
1645
1645
|
};
|
|
1646
|
-
type ChainedCSSPseudos =
|
|
1646
|
+
type ChainedCSSPseudos = ':visited:active' | ':active:visited' | ':hover::before' | ':hover::after' | ':focus-visible::before' | ':focus-visible::after';
|
|
1647
1647
|
type CSSPseudos = {
|
|
1648
1648
|
[Pseudo in CSS.Pseudos | ChainedCSSPseudos]?: Omit<SafeCSSObject, CSS.Pseudos | AllMedia>;
|
|
1649
1649
|
};
|
|
@@ -1643,7 +1643,7 @@ type AllMedia = MediaQuery | '@media screen and (forced-colors: active), screen
|
|
|
1643
1643
|
type CSSMediaQueries = {
|
|
1644
1644
|
[MQ in AllMedia]?: Omit<SafeCSSObject, AllMedia>;
|
|
1645
1645
|
};
|
|
1646
|
-
type ChainedCSSPseudos =
|
|
1646
|
+
type ChainedCSSPseudos = ':visited:active' | ':active:visited' | ':hover::before' | ':hover::after' | ':focus-visible::before' | ':focus-visible::after';
|
|
1647
1647
|
type CSSPseudos = {
|
|
1648
1648
|
[Pseudo in CSS.Pseudos | ChainedCSSPseudos]?: Omit<SafeCSSObject, CSS.Pseudos | AllMedia>;
|
|
1649
1649
|
};
|
|
@@ -35,7 +35,7 @@ export default function Anchor<
|
|
|
35
35
|
>(
|
|
36
36
|
_: {
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* The URL or link location, which can be provided as a string if a router link configuration is set in the [app provider](https://atlassian.design/components/app-provider/examples). This can be mapped to an underlying router link component. For advanced usage, an object can be passed. See [routing examples](https://atlassian.design/components/primitives/anchor/examples#router-links) for more information.
|
|
39
39
|
*/
|
|
40
40
|
href: string | RouterLinkConfig;
|
|
41
41
|
|
|
@@ -85,7 +85,7 @@ export default function Anchor<
|
|
|
85
85
|
paddingInlineEnd?: Space;
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
* Handler called on click. You can use the second argument to fire Atlaskit analytics events on custom channels. They could then be routed to GASv3 analytics. See
|
|
88
|
+
* Handler called on click. You can use the second argument to fire Atlaskit analytics events on custom channels. They could then be routed to GASv3 analytics. See examples for [firing Atlaskit analytics events](https://atlassian.design/components/primitives/anchor/examples#atlaskit-analytics) or [routing these to GASv3 analytics](https://atlassian.design/components/primitives/anchor/examples#gasv3-analytics).
|
|
89
89
|
*/
|
|
90
90
|
onClick?: (
|
|
91
91
|
e: React.MouseEvent<HTMLButtonElement>,
|
|
@@ -93,23 +93,22 @@ export default function Anchor<
|
|
|
93
93
|
) => void;
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
* An optional component name used to identify this component to Atlaskit analytics press listeners. This can be altered if a parent component's name is preferred rather than the default 'Anchor'. See [the
|
|
96
|
+
* An optional component name used to identify this component to Atlaskit analytics press listeners. This can be altered if a parent component's name is preferred rather than the default 'Anchor'. See [the Atlaskit analytics example](https://atlassian.design/components/primitives/anchor/examples#atlaskit-analytics) for more information.
|
|
97
97
|
*/
|
|
98
98
|
componentName?: string;
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* Additional information to be included in the `context` of Atlaskit analytics events that come from anchor. See [the
|
|
101
|
+
* Additional information to be included in the `context` of Atlaskit analytics events that come from anchor. See [the analytics example](https://atlassian.design/components/primitives/anchor/examples#atlaskit-analytics) for more information.
|
|
102
102
|
*/
|
|
103
103
|
analyticsContext?: Record<string, any>;
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* An optional name used to identify the anchor to interaction content listeners. By default, anchor fires React UFO (Unified Frontend Observability) press interactions for available listeners. This helps Atlassian measure performance and reliability. See [the
|
|
106
|
+
* An optional name used to identify the anchor to interaction content listeners. By default, anchor fires React UFO (Unified Frontend Observability) press interactions for available listeners. This helps Atlassian measure performance and reliability. See [the React UFO press example](https://atlassian.design/components/primitives/anchor/examples#react-ufo-press-interactions) for more information.
|
|
107
107
|
*/
|
|
108
108
|
interactionName?: string;
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
* A token alias for background color.
|
|
112
|
-
* [https://atlassian.design/components/tokens/all-tokens#color-background](https://atlassian.design/components/tokens/all-tokens#color-background)<br>
|
|
111
|
+
* A token alias for background color ([background color tokens](https://atlassian.design/components/components/tokens/all-tokens#color-background)).
|
|
113
112
|
* When the background color is set to a [surface token](/components/tokens/all-tokens#elevation-surface),
|
|
114
113
|
* the [current surface](/components/tokens/code#current-surface-color) CSS variable will also be set to this value in the Box styles.
|
|
115
114
|
*/
|