@atlaskit/heading 1.3.7 → 1.4.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 +39 -27
- package/dist/cjs/heading-context.js +14 -7
- package/dist/cjs/heading.js +25 -13
- package/dist/cjs/heading.temp.js +105 -0
- package/dist/es2019/heading-context.js +15 -7
- package/dist/es2019/heading.js +23 -13
- package/dist/es2019/heading.temp.js +98 -0
- package/dist/esm/heading-context.js +15 -7
- package/dist/esm/heading.js +24 -13
- package/dist/esm/heading.temp.js +98 -0
- package/dist/types/heading-context.d.ts +14 -7
- package/dist/types/heading.d.ts +3 -18
- package/dist/types/heading.temp.d.ts +38 -0
- package/dist/types/types.d.ts +40 -24
- package/dist/types-ts4.5/heading-context.d.ts +14 -7
- package/dist/types-ts4.5/heading.d.ts +3 -18
- package/dist/types-ts4.5/heading.temp.d.ts +38 -0
- package/dist/types-ts4.5/types.d.ts +40 -24
- package/package.json +33 -25
- package/report.api.md +46 -21
- package/scripts/codegen.tsx +66 -0
- package/tmp/api-report-tmp.d.ts +58 -0
- package/dist/cjs/utils.js +0 -10
- package/dist/cjs/version.json +0 -5
- package/dist/es2019/utils.js +0 -1
- package/dist/es2019/version.json +0 -5
- package/dist/esm/utils.js +0 -3
- package/dist/esm/version.json +0 -5
- package/dist/types/utils.d.ts +0 -1
- package/dist/types-ts4.5/utils.d.ts +0 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import React, { createContext, useContext } from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// Allows support for heading levels 1-9 via aria-level
|
|
4
|
+
|
|
5
|
+
var HeadingLevelContext = /*#__PURE__*/createContext(0);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* @returns The current heading level context.
|
|
10
|
+
*/
|
|
3
11
|
export var useHeadingElement = function useHeadingElement() {
|
|
4
|
-
return
|
|
12
|
+
return useContext(HeadingLevelContext);
|
|
5
13
|
};
|
|
6
14
|
/**
|
|
7
|
-
* __Heading
|
|
15
|
+
* __Heading level provider__
|
|
8
16
|
*
|
|
9
|
-
* The
|
|
17
|
+
* The Heading level provider injectes the heading level to all `Heading` components below it in the component tree.
|
|
10
18
|
*
|
|
11
19
|
* @example
|
|
12
20
|
* ```tsx
|
|
@@ -19,13 +27,13 @@ export var useHeadingElement = function useHeadingElement() {
|
|
|
19
27
|
* </HeadingContext>
|
|
20
28
|
* ```
|
|
21
29
|
*/
|
|
22
|
-
var
|
|
30
|
+
var HeadingLevelContextProvider = function HeadingLevelContextProvider(_ref) {
|
|
23
31
|
var children = _ref.children,
|
|
24
32
|
value = _ref.value;
|
|
25
33
|
var parentHeadingLevel = useHeadingElement();
|
|
26
34
|
var headingLevel = parentHeadingLevel + 1;
|
|
27
|
-
return /*#__PURE__*/React.createElement(
|
|
35
|
+
return /*#__PURE__*/React.createElement(HeadingLevelContext.Provider, {
|
|
28
36
|
value: value || headingLevel
|
|
29
37
|
}, children);
|
|
30
38
|
};
|
|
31
|
-
export default
|
|
39
|
+
export default HeadingLevelContextProvider;
|
package/dist/esm/heading.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["level", "variant"];
|
|
1
4
|
/** @jsx jsx */
|
|
2
|
-
|
|
3
5
|
import { css, jsx } from '@emotion/react';
|
|
4
6
|
import { useHeadingElement } from './heading-context';
|
|
7
|
+
import NewHeading from './heading.temp';
|
|
5
8
|
// https://atlassian.design/foundations/typography
|
|
6
9
|
var levelMap = {
|
|
7
10
|
h900: 'h1',
|
|
@@ -16,9 +19,8 @@ var levelMap = {
|
|
|
16
19
|
h100: 'div'
|
|
17
20
|
};
|
|
18
21
|
var headingResetStyles = css({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
color: "var(--ds-text, #172B4D)"
|
|
22
|
+
color: "var(--ds-text, #172B4D)",
|
|
23
|
+
marginBlock: "var(--ds-space-0, 0px)"
|
|
22
24
|
});
|
|
23
25
|
var h900Styles = css({
|
|
24
26
|
fontSize: "var(--ds-font-size-600, 35px)",
|
|
@@ -115,17 +117,26 @@ var Heading = function Heading(_ref) {
|
|
|
115
117
|
* 2. inferred a11y level
|
|
116
118
|
* 3. default final fallback
|
|
117
119
|
*/
|
|
118
|
-
var Markup = as || hLevel && "h".concat(hLevel) || levelMap[level];
|
|
120
|
+
var Markup = as || hLevel && (hLevel > 6 ? 'div' : "h".concat(hLevel)) || levelMap[level];
|
|
119
121
|
var isSubtleHeading = level === 'h200' || level === 'h100';
|
|
120
122
|
return jsx(Markup, {
|
|
121
123
|
id: id,
|
|
122
|
-
"data-testid": testId
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
,
|
|
126
|
-
css: [headingResetStyles,
|
|
127
|
-
// This can be refactored when @compiled supports style maps
|
|
128
|
-
level === 'h100' && h100Styles, level === 'h200' && h200Styles, level === 'h300' && h300Styles, level === 'h400' && h400Styles, level === 'h500' && h500Styles, level === 'h600' && h600Styles, level === 'h700' && h700Styles, level === 'h800' && h800Styles, level === 'h900' && h900Styles, color === 'inverse' && inverseStyles, color === 'default' && isSubtleHeading && subtlestStyles]
|
|
124
|
+
"data-testid": testId,
|
|
125
|
+
role: Markup === 'div' ? 'heading' : undefined,
|
|
126
|
+
css: [headingResetStyles, level === 'h100' && h100Styles, level === 'h200' && h200Styles, level === 'h300' && h300Styles, level === 'h400' && h400Styles, level === 'h500' && h500Styles, level === 'h600' && h600Styles, level === 'h700' && h700Styles, level === 'h800' && h800Styles, level === 'h900' && h900Styles, color === 'inverse' && inverseStyles, color === 'default' && isSubtleHeading && subtlestStyles]
|
|
129
127
|
}, children);
|
|
130
128
|
};
|
|
131
|
-
export default
|
|
129
|
+
export default (function (_ref2) {
|
|
130
|
+
var level = _ref2.level,
|
|
131
|
+
variant = _ref2.variant,
|
|
132
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
133
|
+
return level ?
|
|
134
|
+
// eslint-disable-next-line jsx-a11y/heading-has-content
|
|
135
|
+
jsx(Heading, _extends({
|
|
136
|
+
level: level
|
|
137
|
+
}, props)) :
|
|
138
|
+
// eslint-disable-next-line jsx-a11y/heading-has-content
|
|
139
|
+
jsx(NewHeading, _extends({
|
|
140
|
+
variant: variant
|
|
141
|
+
}, props));
|
|
142
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
xxlarge: 'h1',
|
|
7
|
+
xlarge: 'h2',
|
|
8
|
+
large: 'h3',
|
|
9
|
+
medium: 'h4',
|
|
10
|
+
small: 'h5',
|
|
11
|
+
xsmall: 'h6',
|
|
12
|
+
xxsmall: 'div'
|
|
13
|
+
};
|
|
14
|
+
var headingResetStyles = css({
|
|
15
|
+
color: "var(--ds-text, #172B4D)",
|
|
16
|
+
letterSpacing: 'normal',
|
|
17
|
+
marginBlock: 0,
|
|
18
|
+
textTransform: 'none'
|
|
19
|
+
});
|
|
20
|
+
var inverseStyles = css({
|
|
21
|
+
color: "var(--ds-text-inverse, #FFF)"
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* __Heading__
|
|
26
|
+
*
|
|
27
|
+
* A heading is a typography component used to display text in different sizes and formats.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
*
|
|
31
|
+
* ```jsx
|
|
32
|
+
* import Heading from '@atlaskit/heading';
|
|
33
|
+
*
|
|
34
|
+
* const HeadingXXL = () => (
|
|
35
|
+
* <Heading level="xxlarge">XXL</Heading>
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
var Heading = function Heading(_ref) {
|
|
40
|
+
var children = _ref.children,
|
|
41
|
+
variant = _ref.variant,
|
|
42
|
+
id = _ref.id,
|
|
43
|
+
testId = _ref.testId,
|
|
44
|
+
as = _ref.as,
|
|
45
|
+
_ref$color = _ref.color,
|
|
46
|
+
color = _ref$color === void 0 ? 'default' : _ref$color;
|
|
47
|
+
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
|
|
48
|
+
throw new Error('`as` prop should be a string.');
|
|
49
|
+
}
|
|
50
|
+
var hLevel = useHeadingElement();
|
|
51
|
+
/**
|
|
52
|
+
* Order here is important, we for now apply
|
|
53
|
+
* 1. user choice
|
|
54
|
+
* 2. inferred a11y level
|
|
55
|
+
* 3. default final fallback
|
|
56
|
+
*/
|
|
57
|
+
var Markup = as || hLevel && (hLevel > 6 ? 'div' : "h".concat(hLevel)) || levelMap[variant];
|
|
58
|
+
return jsx(Markup, {
|
|
59
|
+
id: id,
|
|
60
|
+
"data-testid": testId,
|
|
61
|
+
role: Markup === 'div' ? 'heading' : undefined,
|
|
62
|
+
css: [headingResetStyles, variant && headingVariantStylesMap[variant], color === 'inverse' && inverseStyles]
|
|
63
|
+
}, children);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @codegenStart
|
|
68
|
+
* @codegenId typography
|
|
69
|
+
* @codegenCommand yarn workspace @atlaskit/heading codegen
|
|
70
|
+
*/
|
|
71
|
+
var headingVariantStylesMap = {
|
|
72
|
+
large: css({
|
|
73
|
+
font: "var(--ds-font-heading-lg, normal 500 24px/28px var(--ds-font-family-heading))"
|
|
74
|
+
}),
|
|
75
|
+
medium: css({
|
|
76
|
+
font: "var(--ds-font-heading-md, normal 500 20px/24px var(--ds-font-family-heading))"
|
|
77
|
+
}),
|
|
78
|
+
small: css({
|
|
79
|
+
font: "var(--ds-font-heading-sm, normal 600 16px/20px var(--ds-font-family-heading))"
|
|
80
|
+
}),
|
|
81
|
+
xlarge: css({
|
|
82
|
+
font: "var(--ds-font-heading-xl, normal 600 29px/32px var(--ds-font-family-heading))"
|
|
83
|
+
}),
|
|
84
|
+
xsmall: css({
|
|
85
|
+
font: "var(--ds-font-heading-xs, normal 600 14px/16px var(--ds-font-family-heading))"
|
|
86
|
+
}),
|
|
87
|
+
xxlarge: css({
|
|
88
|
+
font: "var(--ds-font-heading-xxl, normal 500 35px/40px var(--ds-font-family-heading))"
|
|
89
|
+
}),
|
|
90
|
+
xxsmall: css({
|
|
91
|
+
font: "var(--ds-font-heading-xxs, normal 600 12px/16px var(--ds-font-family-heading))"
|
|
92
|
+
})
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* @codegenEnd
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
export default Heading;
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type HeadingElement = 1 | 2 | 3 | 4 | 5 | 6;
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type HeadingElement = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* @returns The current heading level context.
|
|
6
|
+
*/
|
|
3
7
|
export declare const useHeadingElement: () => HeadingElement;
|
|
4
|
-
export interface
|
|
8
|
+
export interface HeadingLevelContextProps {
|
|
5
9
|
/**
|
|
6
10
|
* 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
11
|
*/
|
|
8
12
|
value?: HeadingElement;
|
|
13
|
+
/**
|
|
14
|
+
* Semantic heirarchy of content below the heading context.
|
|
15
|
+
*/
|
|
9
16
|
children: ReactNode;
|
|
10
17
|
}
|
|
11
18
|
/**
|
|
12
|
-
* __Heading
|
|
19
|
+
* __Heading level provider__
|
|
13
20
|
*
|
|
14
|
-
* The
|
|
21
|
+
* The Heading level provider injectes the heading level to all `Heading` components below it in the component tree.
|
|
15
22
|
*
|
|
16
23
|
* @example
|
|
17
24
|
* ```tsx
|
|
@@ -24,5 +31,5 @@ export interface HeadingContextProps {
|
|
|
24
31
|
* </HeadingContext>
|
|
25
32
|
* ```
|
|
26
33
|
*/
|
|
27
|
-
declare const
|
|
28
|
-
export default
|
|
34
|
+
declare const HeadingLevelContextProvider: ({ children, value, }: HeadingLevelContextProps) => JSX.Element;
|
|
35
|
+
export default HeadingLevelContextProvider;
|
package/dist/types/heading.d.ts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import {
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
3
|
import type { HeadingProps } from './types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* A heading is a typography component used to display text in different sizes and formats.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
*
|
|
11
|
-
* ```jsx
|
|
12
|
-
* import Heading from '@atlaskit/heading';
|
|
13
|
-
*
|
|
14
|
-
* const H100 = () => (
|
|
15
|
-
* <Heading level="h100">h100</Heading>
|
|
16
|
-
* );
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare const Heading: FC<HeadingProps>;
|
|
20
|
-
export default Heading;
|
|
4
|
+
declare const _default: ({ level, variant, ...props }: HeadingProps) => jsx.JSX.Element;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import type { HeadingProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* __Heading__
|
|
6
|
+
*
|
|
7
|
+
* A heading is a typography component used to display text in different sizes and formats.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```jsx
|
|
12
|
+
* import Heading from '@atlaskit/heading';
|
|
13
|
+
*
|
|
14
|
+
* const HeadingXXL = () => (
|
|
15
|
+
* <Heading level="xxlarge">XXL</Heading>
|
|
16
|
+
* );
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const Heading: ({ children, variant, id, testId, as, color, }: HeadingProps) => jsx.JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* @codegenStart
|
|
22
|
+
* @codegenId typography
|
|
23
|
+
* @codegenCommand yarn workspace @atlaskit/heading codegen
|
|
24
|
+
*/
|
|
25
|
+
declare const headingVariantStylesMap: {
|
|
26
|
+
large: import("@emotion/react").SerializedStyles;
|
|
27
|
+
medium: import("@emotion/react").SerializedStyles;
|
|
28
|
+
small: import("@emotion/react").SerializedStyles;
|
|
29
|
+
xlarge: import("@emotion/react").SerializedStyles;
|
|
30
|
+
xsmall: import("@emotion/react").SerializedStyles;
|
|
31
|
+
xxlarge: import("@emotion/react").SerializedStyles;
|
|
32
|
+
xxsmall: import("@emotion/react").SerializedStyles;
|
|
33
|
+
};
|
|
34
|
+
export type HeadingVariant = keyof typeof headingVariantStylesMap;
|
|
35
|
+
/**
|
|
36
|
+
* @codegenEnd
|
|
37
|
+
*/
|
|
38
|
+
export default Heading;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { HeadingVariant } from './heading.temp';
|
|
2
3
|
export type HeadingProps = {
|
|
3
4
|
/**
|
|
4
5
|
* A `testId` prop is provided for specified elements, which is a unique
|
|
@@ -10,29 +11,6 @@ export type HeadingProps = {
|
|
|
10
11
|
* The text of the heading.
|
|
11
12
|
*/
|
|
12
13
|
children: ReactNode;
|
|
13
|
-
/**
|
|
14
|
-
The headling level as defined by the Atlasian Design [typography foundations](/foundations/typography/).
|
|
15
|
-
|
|
16
|
-
The `level` prop affects the actual HTML element rendered in the DOM:
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
const levelMap = {
|
|
20
|
-
h900: 'h1',
|
|
21
|
-
h800: 'h1',
|
|
22
|
-
h700: 'h2',
|
|
23
|
-
h600: 'h3',
|
|
24
|
-
h500: 'h4',
|
|
25
|
-
h400: 'h5',
|
|
26
|
-
h300: 'h6',
|
|
27
|
-
h200: 'div',
|
|
28
|
-
h100: 'div',
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
It's important to note that the final DOM may be impacted by the parent heading level context because of inferred accessibility level correction.
|
|
33
|
-
Therefore, it is recommended to check the final DOM to confirm the actual rendered HTML element.
|
|
34
|
-
*/
|
|
35
|
-
level: 'h900' | 'h800' | 'h700' | 'h600' | 'h500' | 'h400' | 'h300' | 'h200' | 'h100';
|
|
36
14
|
/**
|
|
37
15
|
* Unique identifier for the heading DOM element.
|
|
38
16
|
*/
|
|
@@ -46,4 +24,42 @@ export type HeadingProps = {
|
|
|
46
24
|
* Defaults to `"default"`.
|
|
47
25
|
*/
|
|
48
26
|
color?: 'inverse' | 'default';
|
|
49
|
-
}
|
|
27
|
+
} & ({
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
* @deprecated Use `variant` prop instead.
|
|
31
|
+
* The headling level as defined by the Atlasian Design [typography foundations](/foundations/typography/). The `level` prop affects the actual HTML element rendered in the DOM:
|
|
32
|
+
* @example
|
|
33
|
+
* ```js
|
|
34
|
+
* const levelMap = {
|
|
35
|
+
* h900: 'h1',
|
|
36
|
+
* h800: 'h1',
|
|
37
|
+
* h700: 'h2',
|
|
38
|
+
* h600: 'h3',
|
|
39
|
+
* h500: 'h4',
|
|
40
|
+
* h400: 'h5',
|
|
41
|
+
* h300: 'h6',
|
|
42
|
+
* h200: 'div',
|
|
43
|
+
* h100: 'div',
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* It's important to note that the final DOM may be impacted by the parent heading level context because of inferred accessibility level correction.
|
|
48
|
+
* Therefore, it is recommended to check the final DOM to confirm the actual rendered HTML element.
|
|
49
|
+
*/
|
|
50
|
+
level?: 'h900' | 'h800' | 'h700' | 'h600' | 'h500' | 'h400' | 'h300' | 'h200' | 'h100';
|
|
51
|
+
/**
|
|
52
|
+
* Heading style variant. This style is detached from the specific heading level applied to allow for more flexibility.
|
|
53
|
+
* Use instead of the deprecated `level` prop.
|
|
54
|
+
*/
|
|
55
|
+
variant?: never;
|
|
56
|
+
} | {
|
|
57
|
+
level?: never;
|
|
58
|
+
/**
|
|
59
|
+
* Heading style variant. This style is detached from the specific heading level applied to allow for more flexibility.
|
|
60
|
+
* Use instead of the deprecated `level` prop.
|
|
61
|
+
*
|
|
62
|
+
* This prop will only work if the typography theme is applied.
|
|
63
|
+
*/
|
|
64
|
+
variant?: HeadingVariant;
|
|
65
|
+
});
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type HeadingElement = 1 | 2 | 3 | 4 | 5 | 6;
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type HeadingElement = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* @returns The current heading level context.
|
|
6
|
+
*/
|
|
3
7
|
export declare const useHeadingElement: () => HeadingElement;
|
|
4
|
-
export interface
|
|
8
|
+
export interface HeadingLevelContextProps {
|
|
5
9
|
/**
|
|
6
10
|
* 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
11
|
*/
|
|
8
12
|
value?: HeadingElement;
|
|
13
|
+
/**
|
|
14
|
+
* Semantic heirarchy of content below the heading context.
|
|
15
|
+
*/
|
|
9
16
|
children: ReactNode;
|
|
10
17
|
}
|
|
11
18
|
/**
|
|
12
|
-
* __Heading
|
|
19
|
+
* __Heading level provider__
|
|
13
20
|
*
|
|
14
|
-
* The
|
|
21
|
+
* The Heading level provider injectes the heading level to all `Heading` components below it in the component tree.
|
|
15
22
|
*
|
|
16
23
|
* @example
|
|
17
24
|
* ```tsx
|
|
@@ -24,5 +31,5 @@ export interface HeadingContextProps {
|
|
|
24
31
|
* </HeadingContext>
|
|
25
32
|
* ```
|
|
26
33
|
*/
|
|
27
|
-
declare const
|
|
28
|
-
export default
|
|
34
|
+
declare const HeadingLevelContextProvider: ({ children, value, }: HeadingLevelContextProps) => JSX.Element;
|
|
35
|
+
export default HeadingLevelContextProvider;
|
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import {
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
3
|
import type { HeadingProps } from './types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* A heading is a typography component used to display text in different sizes and formats.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
*
|
|
11
|
-
* ```jsx
|
|
12
|
-
* import Heading from '@atlaskit/heading';
|
|
13
|
-
*
|
|
14
|
-
* const H100 = () => (
|
|
15
|
-
* <Heading level="h100">h100</Heading>
|
|
16
|
-
* );
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare const Heading: FC<HeadingProps>;
|
|
20
|
-
export default Heading;
|
|
4
|
+
declare const _default: ({ level, variant, ...props }: HeadingProps) => jsx.JSX.Element;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import type { HeadingProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* __Heading__
|
|
6
|
+
*
|
|
7
|
+
* A heading is a typography component used to display text in different sizes and formats.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```jsx
|
|
12
|
+
* import Heading from '@atlaskit/heading';
|
|
13
|
+
*
|
|
14
|
+
* const HeadingXXL = () => (
|
|
15
|
+
* <Heading level="xxlarge">XXL</Heading>
|
|
16
|
+
* );
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const Heading: ({ children, variant, id, testId, as, color, }: HeadingProps) => jsx.JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* @codegenStart
|
|
22
|
+
* @codegenId typography
|
|
23
|
+
* @codegenCommand yarn workspace @atlaskit/heading codegen
|
|
24
|
+
*/
|
|
25
|
+
declare const headingVariantStylesMap: {
|
|
26
|
+
large: import("@emotion/react").SerializedStyles;
|
|
27
|
+
medium: import("@emotion/react").SerializedStyles;
|
|
28
|
+
small: import("@emotion/react").SerializedStyles;
|
|
29
|
+
xlarge: import("@emotion/react").SerializedStyles;
|
|
30
|
+
xsmall: import("@emotion/react").SerializedStyles;
|
|
31
|
+
xxlarge: import("@emotion/react").SerializedStyles;
|
|
32
|
+
xxsmall: import("@emotion/react").SerializedStyles;
|
|
33
|
+
};
|
|
34
|
+
export type HeadingVariant = keyof typeof headingVariantStylesMap;
|
|
35
|
+
/**
|
|
36
|
+
* @codegenEnd
|
|
37
|
+
*/
|
|
38
|
+
export default Heading;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { HeadingVariant } from './heading.temp';
|
|
2
3
|
export type HeadingProps = {
|
|
3
4
|
/**
|
|
4
5
|
* A `testId` prop is provided for specified elements, which is a unique
|
|
@@ -10,29 +11,6 @@ export type HeadingProps = {
|
|
|
10
11
|
* The text of the heading.
|
|
11
12
|
*/
|
|
12
13
|
children: ReactNode;
|
|
13
|
-
/**
|
|
14
|
-
The headling level as defined by the Atlasian Design [typography foundations](/foundations/typography/).
|
|
15
|
-
|
|
16
|
-
The `level` prop affects the actual HTML element rendered in the DOM:
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
const levelMap = {
|
|
20
|
-
h900: 'h1',
|
|
21
|
-
h800: 'h1',
|
|
22
|
-
h700: 'h2',
|
|
23
|
-
h600: 'h3',
|
|
24
|
-
h500: 'h4',
|
|
25
|
-
h400: 'h5',
|
|
26
|
-
h300: 'h6',
|
|
27
|
-
h200: 'div',
|
|
28
|
-
h100: 'div',
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
It's important to note that the final DOM may be impacted by the parent heading level context because of inferred accessibility level correction.
|
|
33
|
-
Therefore, it is recommended to check the final DOM to confirm the actual rendered HTML element.
|
|
34
|
-
*/
|
|
35
|
-
level: 'h900' | 'h800' | 'h700' | 'h600' | 'h500' | 'h400' | 'h300' | 'h200' | 'h100';
|
|
36
14
|
/**
|
|
37
15
|
* Unique identifier for the heading DOM element.
|
|
38
16
|
*/
|
|
@@ -46,4 +24,42 @@ export type HeadingProps = {
|
|
|
46
24
|
* Defaults to `"default"`.
|
|
47
25
|
*/
|
|
48
26
|
color?: 'inverse' | 'default';
|
|
49
|
-
}
|
|
27
|
+
} & ({
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
* @deprecated Use `variant` prop instead.
|
|
31
|
+
* The headling level as defined by the Atlasian Design [typography foundations](/foundations/typography/). The `level` prop affects the actual HTML element rendered in the DOM:
|
|
32
|
+
* @example
|
|
33
|
+
* ```js
|
|
34
|
+
* const levelMap = {
|
|
35
|
+
* h900: 'h1',
|
|
36
|
+
* h800: 'h1',
|
|
37
|
+
* h700: 'h2',
|
|
38
|
+
* h600: 'h3',
|
|
39
|
+
* h500: 'h4',
|
|
40
|
+
* h400: 'h5',
|
|
41
|
+
* h300: 'h6',
|
|
42
|
+
* h200: 'div',
|
|
43
|
+
* h100: 'div',
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* It's important to note that the final DOM may be impacted by the parent heading level context because of inferred accessibility level correction.
|
|
48
|
+
* Therefore, it is recommended to check the final DOM to confirm the actual rendered HTML element.
|
|
49
|
+
*/
|
|
50
|
+
level?: 'h900' | 'h800' | 'h700' | 'h600' | 'h500' | 'h400' | 'h300' | 'h200' | 'h100';
|
|
51
|
+
/**
|
|
52
|
+
* Heading style variant. This style is detached from the specific heading level applied to allow for more flexibility.
|
|
53
|
+
* Use instead of the deprecated `level` prop.
|
|
54
|
+
*/
|
|
55
|
+
variant?: never;
|
|
56
|
+
} | {
|
|
57
|
+
level?: never;
|
|
58
|
+
/**
|
|
59
|
+
* Heading style variant. This style is detached from the specific heading level applied to allow for more flexibility.
|
|
60
|
+
* Use instead of the deprecated `level` prop.
|
|
61
|
+
*
|
|
62
|
+
* This prop will only work if the typography theme is applied.
|
|
63
|
+
*/
|
|
64
|
+
variant?: HeadingVariant;
|
|
65
|
+
});
|
package/package.json
CHANGED
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/heading",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A heading is a typography component used to display text in different sizes and formats.",
|
|
5
|
-
"author": "Atlassian Pty Ltd",
|
|
6
|
-
"license": "Apache-2.0",
|
|
7
5
|
"publishConfig": {
|
|
8
6
|
"registry": "https://registry.npmjs.org/"
|
|
9
7
|
},
|
|
8
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
9
|
+
"author": "Atlassian Pty Ltd",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"main": "dist/cjs/index.js",
|
|
12
|
+
"module": "dist/esm/index.js",
|
|
13
|
+
"module:es2019": "dist/es2019/index.js",
|
|
14
|
+
"types": "dist/types/index.d.ts",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"atlaskit:src": "src/index.tsx",
|
|
10
17
|
"atlassian": {
|
|
11
18
|
"team": "Design System Team",
|
|
19
|
+
"productPushConsumption": [
|
|
20
|
+
"jira"
|
|
21
|
+
],
|
|
12
22
|
"releaseModel": "continuous",
|
|
13
23
|
"website": {
|
|
14
24
|
"name": "Heading",
|
|
15
25
|
"category": "Components",
|
|
16
26
|
"status": {
|
|
17
|
-
"type": "beta"
|
|
27
|
+
"type": "closed-beta"
|
|
18
28
|
}
|
|
19
29
|
}
|
|
20
30
|
},
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"module": "dist/esm/index.js",
|
|
24
|
-
"module:es2019": "dist/es2019/index.js",
|
|
25
|
-
"types": "dist/types/index.d.ts",
|
|
26
|
-
"typesVersions": {
|
|
27
|
-
">=4.5 <4.9": {
|
|
28
|
-
"*": [
|
|
29
|
-
"dist/types-ts4.5/*",
|
|
30
|
-
"dist/types-ts4.5/index.d.ts"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"sideEffects": false,
|
|
35
|
-
"atlaskit:src": "src/index.tsx",
|
|
36
|
-
"af:exports": {
|
|
37
|
-
".": "./src/index.tsx"
|
|
31
|
+
"scripts": {
|
|
32
|
+
"codegen": "ts-node ./scripts/codegen.tsx"
|
|
38
33
|
},
|
|
39
34
|
"dependencies": {
|
|
40
|
-
"@atlaskit/tokens": "^1.
|
|
35
|
+
"@atlaskit/tokens": "^1.25.0",
|
|
41
36
|
"@babel/runtime": "^7.0.0",
|
|
42
37
|
"@emotion/react": "^11.7.1"
|
|
43
38
|
},
|
|
@@ -50,10 +45,12 @@
|
|
|
50
45
|
"@atlaskit/ssr": "*",
|
|
51
46
|
"@atlaskit/visual-regression": "*",
|
|
52
47
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
48
|
+
"@atlassian/codegen": "^0.1.0",
|
|
53
49
|
"@testing-library/react": "^12.1.5",
|
|
50
|
+
"prettier": "^2.8.0",
|
|
54
51
|
"react-dom": "^16.8.0",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
52
|
+
"ts-node": "^10.9.1",
|
|
53
|
+
"typescript": "~4.9.5"
|
|
57
54
|
},
|
|
58
55
|
"techstack": {
|
|
59
56
|
"@atlassian/frontend": {
|
|
@@ -75,6 +72,17 @@
|
|
|
75
72
|
"deprecation": "no-deprecated-imports"
|
|
76
73
|
}
|
|
77
74
|
},
|
|
75
|
+
"typesVersions": {
|
|
76
|
+
">=4.5 <4.9": {
|
|
77
|
+
"*": [
|
|
78
|
+
"dist/types-ts4.5/*",
|
|
79
|
+
"dist/types-ts4.5/index.d.ts"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"af:exports": {
|
|
84
|
+
".": "./src/index.tsx"
|
|
85
|
+
},
|
|
78
86
|
"homepage": "https://atlassian.design/components/heading/",
|
|
79
87
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
80
|
-
}
|
|
88
|
+
}
|