@atlaskit/primitives 1.6.0 → 1.6.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/CHANGELOG.md +96 -83
- package/constellation/bleed/code.mdx +1 -1
- package/constellation/box/code.mdx +1 -1
- package/constellation/box/examples.mdx +5 -1
- package/constellation/box/usage.mdx +3 -0
- package/constellation/flex/code.mdx +1 -1
- package/constellation/flex/examples.mdx +5 -3
- package/constellation/grid/code.mdx +1 -1
- package/constellation/grid/examples.mdx +4 -3
- package/constellation/inline/code.mdx +1 -1
- package/constellation/inline/examples.mdx +27 -10
- package/constellation/inline/usage.mdx +2 -0
- package/constellation/overview/index.mdx +8 -1
- package/constellation/responsive/01-show/code.mdx +1 -1
- package/constellation/responsive/01-show/examples.mdx +8 -3
- package/constellation/responsive/02-hide/code.mdx +1 -1
- package/constellation/responsive/02-hide/examples.mdx +8 -2
- package/constellation/responsive/03-breakpoints/examples.mdx +1 -1
- package/constellation/responsive/examples.mdx +9 -6
- package/constellation/stack/code.mdx +1 -1
- package/constellation/stack/examples.mdx +10 -4
- package/constellation/stack/usage.mdx +3 -0
- package/constellation/xcss/examples.mdx +0 -1
- package/constellation/xcss/migration.mdx +4 -6
- package/constellation/xcss/usage.mdx +20 -16
- package/dist/cjs/xcss/style-maps.partial.js +4 -3
- package/dist/es2019/xcss/style-maps.partial.js +4 -3
- package/dist/esm/xcss/style-maps.partial.js +4 -3
- package/dist/types/xcss/style-maps.partial.d.ts +3 -2
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +3 -2
- package/package.json +3 -14
- package/report.api.md +1 -0
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +1 -0
- package/scripts/typography-codegen-template.tsx +1 -1
- package/tmp/api-report-tmp.d.ts +1 -0
- package/constellation/heading/code.mdx +0 -19
- package/constellation/heading/examples.mdx +0 -28
- package/constellation/heading/usage.mdx +0 -21
- package/dist/cjs/components/heading-context.js +0 -44
- package/dist/cjs/components/heading.js +0 -95
- package/dist/es2019/components/heading-context.js +0 -35
- package/dist/es2019/components/heading.js +0 -87
- package/dist/esm/components/heading-context.js +0 -34
- package/dist/esm/components/heading.js +0 -87
- package/dist/types/components/heading-context.d.ts +0 -31
- package/dist/types/components/heading.d.ts +0 -45
- package/dist/types-ts4.5/components/heading-context.d.ts +0 -31
- package/dist/types-ts4.5/components/heading.d.ts +0 -45
- package/extract-react-types/heading-props.tsx +0 -3
- package/heading/package.json +0 -15
- package/heading-context/package.json +0 -15
|
@@ -62,11 +62,11 @@ export type NegativeSpace = keyof typeof negativeSpaceMap;
|
|
|
62
62
|
*/
|
|
63
63
|
/**
|
|
64
64
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
65
|
-
* @codegen <<SignedSource::
|
|
65
|
+
* @codegen <<SignedSource::2d67e9258c01e48d564a26a1e4400b94>>
|
|
66
66
|
* @codegenId colors
|
|
67
67
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
68
68
|
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
69
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
69
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f6a616f7ea03ec40c148fc83050d073b>>
|
|
70
70
|
*/
|
|
71
71
|
export declare const borderColorMap: {
|
|
72
72
|
readonly 'color.border': "var(--ds-border)";
|
|
@@ -336,6 +336,7 @@ export declare const textColorMap: {
|
|
|
336
336
|
readonly 'color.text.subtle': "var(--ds-text-subtle)";
|
|
337
337
|
readonly 'color.link': "var(--ds-link)";
|
|
338
338
|
readonly 'color.link.pressed': "var(--ds-link-pressed)";
|
|
339
|
+
readonly 'color.link.visited': "var(--ds-link-visited)";
|
|
339
340
|
};
|
|
340
341
|
export type TextColor = keyof typeof textColorMap;
|
|
341
342
|
export declare const fillMap: {
|
|
@@ -62,11 +62,11 @@ export type NegativeSpace = keyof typeof negativeSpaceMap;
|
|
|
62
62
|
*/
|
|
63
63
|
/**
|
|
64
64
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
65
|
-
* @codegen <<SignedSource::
|
|
65
|
+
* @codegen <<SignedSource::2d67e9258c01e48d564a26a1e4400b94>>
|
|
66
66
|
* @codegenId colors
|
|
67
67
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
68
68
|
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
69
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
69
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f6a616f7ea03ec40c148fc83050d073b>>
|
|
70
70
|
*/
|
|
71
71
|
export declare const borderColorMap: {
|
|
72
72
|
readonly 'color.border': "var(--ds-border)";
|
|
@@ -336,6 +336,7 @@ export declare const textColorMap: {
|
|
|
336
336
|
readonly 'color.text.subtle': "var(--ds-text-subtle)";
|
|
337
337
|
readonly 'color.link': "var(--ds-link)";
|
|
338
338
|
readonly 'color.link.pressed': "var(--ds-link-pressed)";
|
|
339
|
+
readonly 'color.link.visited': "var(--ds-link-visited)";
|
|
339
340
|
};
|
|
340
341
|
export type TextColor = keyof typeof textColorMap;
|
|
341
342
|
export declare const fillMap: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -108,15 +108,6 @@
|
|
|
108
108
|
"status": {
|
|
109
109
|
"type": "beta"
|
|
110
110
|
}
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"title": "Heading",
|
|
114
|
-
"folder": "heading",
|
|
115
|
-
"slug": "primitives/heading",
|
|
116
|
-
"id": "@atlaskit/primitives/heading",
|
|
117
|
-
"status": {
|
|
118
|
-
"type": "alpha"
|
|
119
|
-
}
|
|
120
111
|
}
|
|
121
112
|
]
|
|
122
113
|
}
|
|
@@ -125,7 +116,7 @@
|
|
|
125
116
|
"codegen-styles": "ts-node -r tsconfig-paths/register ./scripts/codegen-styles.tsx"
|
|
126
117
|
},
|
|
127
118
|
"dependencies": {
|
|
128
|
-
"@atlaskit/tokens": "^1.
|
|
119
|
+
"@atlaskit/tokens": "^1.25.0",
|
|
129
120
|
"@babel/runtime": "^7.0.0",
|
|
130
121
|
"@emotion/react": "^11.7.1",
|
|
131
122
|
"@emotion/serialize": "^1.1.0",
|
|
@@ -191,9 +182,7 @@
|
|
|
191
182
|
"./stack": "./src/components/stack.tsx",
|
|
192
183
|
"./inline": "./src/components/inline.tsx",
|
|
193
184
|
"./pressable": "./src/components/pressable.tsx",
|
|
194
|
-
"./heading": "./src/components/heading.tsx",
|
|
195
|
-
"./heading-context": "./src/components/heading-context.tsx",
|
|
196
185
|
"./responsive": "./src/responsive/index.tsx"
|
|
197
186
|
},
|
|
198
187
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
199
|
-
}
|
|
188
|
+
}
|
package/report.api.md
CHANGED
|
@@ -1081,6 +1081,7 @@ const textColorMap: {
|
|
|
1081
1081
|
readonly 'color.text.subtle': 'var(--ds-text-subtle)';
|
|
1082
1082
|
readonly 'color.link': 'var(--ds-link)';
|
|
1083
1083
|
readonly 'color.link.pressed': 'var(--ds-link-pressed)';
|
|
1084
|
+
readonly 'color.link.visited': 'var(--ds-link-visited)';
|
|
1084
1085
|
};
|
|
1085
1086
|
|
|
1086
1087
|
// @public (undocumented)
|
|
@@ -868,6 +868,7 @@ exports[`@atlaskit/primitives text styles are generated correctly 1`] = `
|
|
|
868
868
|
'color.text.subtle': token('color.text.subtle', '#42526E'),
|
|
869
869
|
'color.link': token('color.link', '#0052CC'),
|
|
870
870
|
'color.link.pressed': token('color.link.pressed', '#0747A6'),
|
|
871
|
+
'color.link.visited': token('color.link.visited', '#403294'),
|
|
871
872
|
} as const;
|
|
872
873
|
|
|
873
874
|
export type TextColor = keyof typeof textColorMap;
|
|
@@ -83,7 +83,7 @@ export const createTypographyStylesFromTemplate = (
|
|
|
83
83
|
export const ${objectName}Map = {
|
|
84
84
|
${activeTokens
|
|
85
85
|
.filter(filterFn)
|
|
86
|
-
.map(t => ({ ...t, name: t.name.
|
|
86
|
+
.map(t => ({ ...t, name: t.name.replace(/\.\[default\]/g, '') }))
|
|
87
87
|
.sort((a, b) => (a.name < b.name ? -1 : 1))
|
|
88
88
|
.map(token => {
|
|
89
89
|
return `
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -736,6 +736,7 @@ const textColorMap: {
|
|
|
736
736
|
readonly 'color.text.subtle': "var(--ds-text-subtle)";
|
|
737
737
|
readonly 'color.link': "var(--ds-link)";
|
|
738
738
|
readonly 'color.link.pressed': "var(--ds-link-pressed)";
|
|
739
|
+
readonly 'color.link.visited': "var(--ds-link-visited)";
|
|
739
740
|
};
|
|
740
741
|
|
|
741
742
|
// @public (undocumented)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Heading
|
|
3
|
-
description: A heading is a typography component used to display text in different sizes and formats.
|
|
4
|
-
order: 1
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
8
|
-
|
|
9
|
-
<CodeDocsHeader
|
|
10
|
-
name="@atlaskit/primitives"
|
|
11
|
-
repository="https://bitbucket.org/atlassian/atlassian-frontend-mirror"
|
|
12
|
-
directoryName="primitives"
|
|
13
|
-
/>
|
|
14
|
-
|
|
15
|
-
import ERTHeading from '!!extract-react-types-loader!../../extract-react-types/heading-props'
|
|
16
|
-
|
|
17
|
-
## Props
|
|
18
|
-
|
|
19
|
-
<PropsTable heading="" props={ERTHeading} />
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Heading
|
|
3
|
-
description: A heading is a typography component used to display text in different sizes and formats.
|
|
4
|
-
order: 0
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
import HeadingDefault from '../../examples/constellation/heading/heading-default';
|
|
8
|
-
import HeadingInverse from '../../examples/constellation/heading/heading-inverse';
|
|
9
|
-
|
|
10
|
-
## Basic
|
|
11
|
-
|
|
12
|
-
Implements the [Atlassian typography set](/foundations/typography/) as a component.
|
|
13
|
-
|
|
14
|
-
A selected `level` will affect the final HTML element rendered in the DOM.
|
|
15
|
-
It's important to note that the final DOM may be impacted by the parent heading level context
|
|
16
|
-
because of inferred accessibility level correction. Therefore, it is recommended to check the final
|
|
17
|
-
DOM to confirm the actual rendered HTML element.
|
|
18
|
-
|
|
19
|
-
The typography `level` can be configured to one of the following types.
|
|
20
|
-
|
|
21
|
-
<Example Component={HeadingDefault} packageName="@atlaskit/heading" />
|
|
22
|
-
|
|
23
|
-
## Inverse
|
|
24
|
-
|
|
25
|
-
Set `color` to change the text color of the heading. Use `color="inverse"` for headings placed on a dark
|
|
26
|
-
surface for better color contrast.
|
|
27
|
-
|
|
28
|
-
<Example Component={HeadingInverse} packageName="@atlaskit/heading" />
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Heading
|
|
3
|
-
description: A heading is a typography component used to display text in different sizes and formats.
|
|
4
|
-
order: 2
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
Use headings to create section and subsection titles on a page.
|
|
10
|
-
|
|
11
|
-
## Accessibility
|
|
12
|
-
|
|
13
|
-
Nest headings by their rank (or level).
|
|
14
|
-
|
|
15
|
-
The most important heading has the rank 1 (`<h1>`), the least important heading rank 6 (`<h6>`).
|
|
16
|
-
Headings with an equal or higher rank start a new section, headings with a lower rank start new subsections that are part of the higher ranked section.
|
|
17
|
-
There should **only be one rank 1 (`<h1>`) heading per page** consisting of the name or main purpose of the overall site/platform.
|
|
18
|
-
|
|
19
|
-
Skipping heading ranks can be confusing and should be avoided where possible: make sure that a `<h2>` is **not** followed directly by an `<h4>`, for example.
|
|
20
|
-
It is ok to skip ranks when closing subsections, for instance, a `<h2>` beginning a new section, can follow an `<h4>` as it closes the previous section.
|
|
21
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useHeadingElement = exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
-
// Allows support for heading levels 1-9 via aria-level
|
|
12
|
-
|
|
13
|
-
var HeadingContext = /*#__PURE__*/(0, _react.createContext)(0);
|
|
14
|
-
var useHeadingElement = function useHeadingElement() {
|
|
15
|
-
return (0, _react.useContext)(HeadingContext);
|
|
16
|
-
};
|
|
17
|
-
exports.useHeadingElement = useHeadingElement;
|
|
18
|
-
/**
|
|
19
|
-
* __Heading context__
|
|
20
|
-
*
|
|
21
|
-
* The HeadingContext
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```tsx
|
|
25
|
-
* // Will correctly infer the heading level
|
|
26
|
-
* <HeadingContext value={1}>
|
|
27
|
-
* <Heading>H1</Heading>
|
|
28
|
-
* <HeadingContext>
|
|
29
|
-
* <Heading>H2</Heading>
|
|
30
|
-
* </HeadingContext>
|
|
31
|
-
* </HeadingContext>
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
var HeadingContextProvider = function HeadingContextProvider(_ref) {
|
|
35
|
-
var children = _ref.children,
|
|
36
|
-
value = _ref.value;
|
|
37
|
-
var parentHeadingLevel = useHeadingElement();
|
|
38
|
-
var headingLevel = parentHeadingLevel + 1;
|
|
39
|
-
return /*#__PURE__*/_react.default.createElement(HeadingContext.Provider, {
|
|
40
|
-
value: value || headingLevel
|
|
41
|
-
}, children);
|
|
42
|
-
};
|
|
43
|
-
var _default = HeadingContextProvider;
|
|
44
|
-
exports.default = _default;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = require("@emotion/react");
|
|
8
|
-
var _headingContext = require("./heading-context");
|
|
9
|
-
/** @jsx jsx */
|
|
10
|
-
|
|
11
|
-
// https://atlassian.design/foundations/typography
|
|
12
|
-
var levelMap = {
|
|
13
|
-
xxl: 'h1',
|
|
14
|
-
xl: 'h2',
|
|
15
|
-
lg: 'h3',
|
|
16
|
-
md: 'h4',
|
|
17
|
-
sm: 'h5',
|
|
18
|
-
xs: 'h6',
|
|
19
|
-
xxs: 'div'
|
|
20
|
-
};
|
|
21
|
-
var headingResetStyles = (0, _react.css)({
|
|
22
|
-
color: "var(--ds-text, #172B4D)",
|
|
23
|
-
letterSpacing: 'normal',
|
|
24
|
-
marginBlock: 0,
|
|
25
|
-
textTransform: 'none'
|
|
26
|
-
});
|
|
27
|
-
var headingStylesMap = {
|
|
28
|
-
xxl: (0, _react.css)({
|
|
29
|
-
font: "var(--ds-font-heading-xxl, inherit)"
|
|
30
|
-
}),
|
|
31
|
-
xl: (0, _react.css)({
|
|
32
|
-
font: "var(--ds-font-heading-xl, inherit)"
|
|
33
|
-
}),
|
|
34
|
-
lg: (0, _react.css)({
|
|
35
|
-
font: "var(--ds-font-heading-lg, inherit)"
|
|
36
|
-
}),
|
|
37
|
-
md: (0, _react.css)({
|
|
38
|
-
font: "var(--ds-font-heading-md, inherit)"
|
|
39
|
-
}),
|
|
40
|
-
sm: (0, _react.css)({
|
|
41
|
-
font: "var(--ds-font-heading-sm, inherit)"
|
|
42
|
-
}),
|
|
43
|
-
xs: (0, _react.css)({
|
|
44
|
-
font: "var(--ds-font-heading-xs, inherit)"
|
|
45
|
-
}),
|
|
46
|
-
xxs: (0, _react.css)({
|
|
47
|
-
font: "var(--ds-font-heading-xxs, inherit)"
|
|
48
|
-
})
|
|
49
|
-
};
|
|
50
|
-
var inverseStyles = (0, _react.css)({
|
|
51
|
-
color: "var(--ds-text-inverse, #FFF)"
|
|
52
|
-
});
|
|
53
|
-
/**
|
|
54
|
-
* __Heading__
|
|
55
|
-
*
|
|
56
|
-
* A heading is a typography component used to display text in different sizes and formats.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
*
|
|
60
|
-
* ```jsx
|
|
61
|
-
* import Heading from '@atlaskit/heading';
|
|
62
|
-
*
|
|
63
|
-
* const HeadingXXL = () => (
|
|
64
|
-
* <Heading level="xxl">XXL</Heading>
|
|
65
|
-
* );
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
var Heading = function Heading(_ref) {
|
|
69
|
-
var children = _ref.children,
|
|
70
|
-
level = _ref.level,
|
|
71
|
-
id = _ref.id,
|
|
72
|
-
testId = _ref.testId,
|
|
73
|
-
as = _ref.as,
|
|
74
|
-
_ref$color = _ref.color,
|
|
75
|
-
color = _ref$color === void 0 ? 'default' : _ref$color;
|
|
76
|
-
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
|
|
77
|
-
throw new Error('`as` prop should be a string.');
|
|
78
|
-
}
|
|
79
|
-
var hLevel = (0, _headingContext.useHeadingElement)();
|
|
80
|
-
/**
|
|
81
|
-
* Order here is important, we for now apply
|
|
82
|
-
* 1. user choice
|
|
83
|
-
* 2. inferred a11y level
|
|
84
|
-
* 3. default final fallback
|
|
85
|
-
*/
|
|
86
|
-
var Markup = as || hLevel && (hLevel > 6 ? 'div' : "h".concat(hLevel)) || levelMap[level];
|
|
87
|
-
return (0, _react.jsx)(Markup, {
|
|
88
|
-
id: id,
|
|
89
|
-
"data-testid": testId,
|
|
90
|
-
role: Markup === 'div' ? 'heading' : undefined,
|
|
91
|
-
css: [headingResetStyles, level && headingStylesMap[level], color === 'inverse' && inverseStyles]
|
|
92
|
-
}, children);
|
|
93
|
-
};
|
|
94
|
-
var _default = Heading;
|
|
95
|
-
exports.default = _default;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
// Allows support for heading levels 1-9 via aria-level
|
|
4
|
-
|
|
5
|
-
const HeadingContext = /*#__PURE__*/createContext(0);
|
|
6
|
-
export const useHeadingElement = () => {
|
|
7
|
-
return useContext(HeadingContext);
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* __Heading context__
|
|
11
|
-
*
|
|
12
|
-
* The HeadingContext
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* // Will correctly infer the heading level
|
|
17
|
-
* <HeadingContext value={1}>
|
|
18
|
-
* <Heading>H1</Heading>
|
|
19
|
-
* <HeadingContext>
|
|
20
|
-
* <Heading>H2</Heading>
|
|
21
|
-
* </HeadingContext>
|
|
22
|
-
* </HeadingContext>
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
const HeadingContextProvider = ({
|
|
26
|
-
children,
|
|
27
|
-
value
|
|
28
|
-
}) => {
|
|
29
|
-
const parentHeadingLevel = useHeadingElement();
|
|
30
|
-
const headingLevel = parentHeadingLevel + 1;
|
|
31
|
-
return /*#__PURE__*/React.createElement(HeadingContext.Provider, {
|
|
32
|
-
value: value || headingLevel
|
|
33
|
-
}, children);
|
|
34
|
-
};
|
|
35
|
-
export default HeadingContextProvider;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { css, jsx } from '@emotion/react';
|
|
3
|
-
import { useHeadingElement } from './heading-context';
|
|
4
|
-
// https://atlassian.design/foundations/typography
|
|
5
|
-
const levelMap = {
|
|
6
|
-
xxl: 'h1',
|
|
7
|
-
xl: 'h2',
|
|
8
|
-
lg: 'h3',
|
|
9
|
-
md: 'h4',
|
|
10
|
-
sm: 'h5',
|
|
11
|
-
xs: 'h6',
|
|
12
|
-
xxs: 'div'
|
|
13
|
-
};
|
|
14
|
-
const headingResetStyles = css({
|
|
15
|
-
color: "var(--ds-text, #172B4D)",
|
|
16
|
-
letterSpacing: 'normal',
|
|
17
|
-
marginBlock: 0,
|
|
18
|
-
textTransform: 'none'
|
|
19
|
-
});
|
|
20
|
-
const headingStylesMap = {
|
|
21
|
-
xxl: css({
|
|
22
|
-
font: "var(--ds-font-heading-xxl, inherit)"
|
|
23
|
-
}),
|
|
24
|
-
xl: css({
|
|
25
|
-
font: "var(--ds-font-heading-xl, inherit)"
|
|
26
|
-
}),
|
|
27
|
-
lg: css({
|
|
28
|
-
font: "var(--ds-font-heading-lg, inherit)"
|
|
29
|
-
}),
|
|
30
|
-
md: css({
|
|
31
|
-
font: "var(--ds-font-heading-md, inherit)"
|
|
32
|
-
}),
|
|
33
|
-
sm: css({
|
|
34
|
-
font: "var(--ds-font-heading-sm, inherit)"
|
|
35
|
-
}),
|
|
36
|
-
xs: css({
|
|
37
|
-
font: "var(--ds-font-heading-xs, inherit)"
|
|
38
|
-
}),
|
|
39
|
-
xxs: css({
|
|
40
|
-
font: "var(--ds-font-heading-xxs, inherit)"
|
|
41
|
-
})
|
|
42
|
-
};
|
|
43
|
-
const inverseStyles = css({
|
|
44
|
-
color: "var(--ds-text-inverse, #FFF)"
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* __Heading__
|
|
48
|
-
*
|
|
49
|
-
* A heading is a typography component used to display text in different sizes and formats.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
*
|
|
53
|
-
* ```jsx
|
|
54
|
-
* import Heading from '@atlaskit/heading';
|
|
55
|
-
*
|
|
56
|
-
* const HeadingXXL = () => (
|
|
57
|
-
* <Heading level="xxl">XXL</Heading>
|
|
58
|
-
* );
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
const Heading = ({
|
|
62
|
-
children,
|
|
63
|
-
level,
|
|
64
|
-
id,
|
|
65
|
-
testId,
|
|
66
|
-
as,
|
|
67
|
-
color = 'default'
|
|
68
|
-
}) => {
|
|
69
|
-
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
|
|
70
|
-
throw new Error('`as` prop should be a string.');
|
|
71
|
-
}
|
|
72
|
-
const hLevel = useHeadingElement();
|
|
73
|
-
/**
|
|
74
|
-
* Order here is important, we for now apply
|
|
75
|
-
* 1. user choice
|
|
76
|
-
* 2. inferred a11y level
|
|
77
|
-
* 3. default final fallback
|
|
78
|
-
*/
|
|
79
|
-
const Markup = as || hLevel && (hLevel > 6 ? 'div' : `h${hLevel}`) || levelMap[level];
|
|
80
|
-
return jsx(Markup, {
|
|
81
|
-
id: id,
|
|
82
|
-
"data-testid": testId,
|
|
83
|
-
role: Markup === 'div' ? 'heading' : undefined,
|
|
84
|
-
css: [headingResetStyles, level && headingStylesMap[level], color === 'inverse' && inverseStyles]
|
|
85
|
-
}, children);
|
|
86
|
-
};
|
|
87
|
-
export default Heading;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
// Allows support for heading levels 1-9 via aria-level
|
|
4
|
-
|
|
5
|
-
var HeadingContext = /*#__PURE__*/createContext(0);
|
|
6
|
-
export var useHeadingElement = function useHeadingElement() {
|
|
7
|
-
return useContext(HeadingContext);
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* __Heading context__
|
|
11
|
-
*
|
|
12
|
-
* The HeadingContext
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* // Will correctly infer the heading level
|
|
17
|
-
* <HeadingContext value={1}>
|
|
18
|
-
* <Heading>H1</Heading>
|
|
19
|
-
* <HeadingContext>
|
|
20
|
-
* <Heading>H2</Heading>
|
|
21
|
-
* </HeadingContext>
|
|
22
|
-
* </HeadingContext>
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
var HeadingContextProvider = function HeadingContextProvider(_ref) {
|
|
26
|
-
var children = _ref.children,
|
|
27
|
-
value = _ref.value;
|
|
28
|
-
var parentHeadingLevel = useHeadingElement();
|
|
29
|
-
var headingLevel = parentHeadingLevel + 1;
|
|
30
|
-
return /*#__PURE__*/React.createElement(HeadingContext.Provider, {
|
|
31
|
-
value: value || headingLevel
|
|
32
|
-
}, children);
|
|
33
|
-
};
|
|
34
|
-
export default HeadingContextProvider;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { css, jsx } from '@emotion/react';
|
|
3
|
-
import { useHeadingElement } from './heading-context';
|
|
4
|
-
// https://atlassian.design/foundations/typography
|
|
5
|
-
var levelMap = {
|
|
6
|
-
xxl: 'h1',
|
|
7
|
-
xl: 'h2',
|
|
8
|
-
lg: 'h3',
|
|
9
|
-
md: 'h4',
|
|
10
|
-
sm: 'h5',
|
|
11
|
-
xs: 'h6',
|
|
12
|
-
xxs: 'div'
|
|
13
|
-
};
|
|
14
|
-
var headingResetStyles = css({
|
|
15
|
-
color: "var(--ds-text, #172B4D)",
|
|
16
|
-
letterSpacing: 'normal',
|
|
17
|
-
marginBlock: 0,
|
|
18
|
-
textTransform: 'none'
|
|
19
|
-
});
|
|
20
|
-
var headingStylesMap = {
|
|
21
|
-
xxl: css({
|
|
22
|
-
font: "var(--ds-font-heading-xxl, inherit)"
|
|
23
|
-
}),
|
|
24
|
-
xl: css({
|
|
25
|
-
font: "var(--ds-font-heading-xl, inherit)"
|
|
26
|
-
}),
|
|
27
|
-
lg: css({
|
|
28
|
-
font: "var(--ds-font-heading-lg, inherit)"
|
|
29
|
-
}),
|
|
30
|
-
md: css({
|
|
31
|
-
font: "var(--ds-font-heading-md, inherit)"
|
|
32
|
-
}),
|
|
33
|
-
sm: css({
|
|
34
|
-
font: "var(--ds-font-heading-sm, inherit)"
|
|
35
|
-
}),
|
|
36
|
-
xs: css({
|
|
37
|
-
font: "var(--ds-font-heading-xs, inherit)"
|
|
38
|
-
}),
|
|
39
|
-
xxs: css({
|
|
40
|
-
font: "var(--ds-font-heading-xxs, inherit)"
|
|
41
|
-
})
|
|
42
|
-
};
|
|
43
|
-
var inverseStyles = css({
|
|
44
|
-
color: "var(--ds-text-inverse, #FFF)"
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* __Heading__
|
|
48
|
-
*
|
|
49
|
-
* A heading is a typography component used to display text in different sizes and formats.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
*
|
|
53
|
-
* ```jsx
|
|
54
|
-
* import Heading from '@atlaskit/heading';
|
|
55
|
-
*
|
|
56
|
-
* const HeadingXXL = () => (
|
|
57
|
-
* <Heading level="xxl">XXL</Heading>
|
|
58
|
-
* );
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
var Heading = function Heading(_ref) {
|
|
62
|
-
var children = _ref.children,
|
|
63
|
-
level = _ref.level,
|
|
64
|
-
id = _ref.id,
|
|
65
|
-
testId = _ref.testId,
|
|
66
|
-
as = _ref.as,
|
|
67
|
-
_ref$color = _ref.color,
|
|
68
|
-
color = _ref$color === void 0 ? 'default' : _ref$color;
|
|
69
|
-
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
|
|
70
|
-
throw new Error('`as` prop should be a string.');
|
|
71
|
-
}
|
|
72
|
-
var hLevel = useHeadingElement();
|
|
73
|
-
/**
|
|
74
|
-
* Order here is important, we for now apply
|
|
75
|
-
* 1. user choice
|
|
76
|
-
* 2. inferred a11y level
|
|
77
|
-
* 3. default final fallback
|
|
78
|
-
*/
|
|
79
|
-
var Markup = as || hLevel && (hLevel > 6 ? 'div' : "h".concat(hLevel)) || levelMap[level];
|
|
80
|
-
return jsx(Markup, {
|
|
81
|
-
id: id,
|
|
82
|
-
"data-testid": testId,
|
|
83
|
-
role: Markup === 'div' ? 'heading' : undefined,
|
|
84
|
-
css: [headingResetStyles, level && headingStylesMap[level], color === 'inverse' && inverseStyles]
|
|
85
|
-
}, children);
|
|
86
|
-
};
|
|
87
|
-
export default Heading;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
2
|
-
type HeadingElement = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
3
|
-
export declare const useHeadingElement: () => HeadingElement;
|
|
4
|
-
export interface HeadingContextProps {
|
|
5
|
-
/**
|
|
6
|
-
* Optional - only apply this value if the intent is to reset the heading context outside the normal content flow, for example inside a `section`.
|
|
7
|
-
*/
|
|
8
|
-
value?: HeadingElement;
|
|
9
|
-
/**
|
|
10
|
-
* Semantic heirarchy of content below the heading context.
|
|
11
|
-
*/
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* __Heading context__
|
|
16
|
-
*
|
|
17
|
-
* The HeadingContext
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* // Will correctly infer the heading level
|
|
22
|
-
* <HeadingContext value={1}>
|
|
23
|
-
* <Heading>H1</Heading>
|
|
24
|
-
* <HeadingContext>
|
|
25
|
-
* <Heading>H2</Heading>
|
|
26
|
-
* </HeadingContext>
|
|
27
|
-
* </HeadingContext>
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
declare const HeadingContextProvider: FC<HeadingContextProps>;
|
|
31
|
-
export default HeadingContextProvider;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/** @jsx jsx */
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import { BasePrimitiveProps } from './types';
|
|
5
|
-
export type TypographyLevel = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs' | 'xxs';
|
|
6
|
-
type HeadingElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div';
|
|
7
|
-
export type HeadingProps = {
|
|
8
|
-
/**
|
|
9
|
-
* The heading text for the element.
|
|
10
|
-
*/
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* The HTML element to render.
|
|
14
|
-
*/
|
|
15
|
-
as?: HeadingElement;
|
|
16
|
-
/**
|
|
17
|
-
* The HTML id attribute.
|
|
18
|
-
*/
|
|
19
|
-
id?: string;
|
|
20
|
-
/**
|
|
21
|
-
* The level of the heading element.
|
|
22
|
-
*/
|
|
23
|
-
level: TypographyLevel;
|
|
24
|
-
/**
|
|
25
|
-
* The color of the heading text.
|
|
26
|
-
*/
|
|
27
|
-
color?: 'default' | 'inverse';
|
|
28
|
-
} & Pick<BasePrimitiveProps, 'testId'>;
|
|
29
|
-
/**
|
|
30
|
-
* __Heading__
|
|
31
|
-
*
|
|
32
|
-
* A heading is a typography component used to display text in different sizes and formats.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
*
|
|
36
|
-
* ```jsx
|
|
37
|
-
* import Heading from '@atlaskit/heading';
|
|
38
|
-
*
|
|
39
|
-
* const HeadingXXL = () => (
|
|
40
|
-
* <Heading level="xxl">XXL</Heading>
|
|
41
|
-
* );
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
declare const Heading: ({ children, level, id, testId, as, color, }: HeadingProps) => jsx.JSX.Element;
|
|
45
|
-
export default Heading;
|