@atlaskit/primitives 1.4.4 → 1.5.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 +10 -0
- package/constellation/heading/code.mdx +19 -0
- package/constellation/heading/examples.mdx +28 -0
- package/constellation/heading/usage.mdx +21 -0
- package/dist/cjs/components/box.js +1 -1
- package/dist/cjs/components/heading-context.js +44 -0
- package/dist/cjs/components/heading.js +95 -0
- package/dist/cjs/xcss/style-maps.partial.js +26 -5
- package/dist/es2019/components/box.js +2 -2
- package/dist/es2019/components/heading-context.js +35 -0
- package/dist/es2019/components/heading.js +87 -0
- package/dist/es2019/xcss/style-maps.partial.js +21 -4
- package/dist/esm/components/box.js +2 -2
- package/dist/esm/components/heading-context.js +34 -0
- package/dist/esm/components/heading.js +87 -0
- package/dist/esm/xcss/style-maps.partial.js +23 -4
- package/dist/types/components/heading-context.d.ts +31 -0
- package/dist/types/components/heading.d.ts +45 -0
- package/dist/types/components/internal/surface-provider.d.ts +2 -2
- package/dist/types/xcss/style-maps.partial.d.ts +20 -2
- package/dist/types-ts4.5/components/heading-context.d.ts +31 -0
- package/dist/types-ts4.5/components/heading.d.ts +45 -0
- package/dist/types-ts4.5/components/internal/surface-provider.d.ts +2 -2
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +20 -2
- package/extract-react-types/box-props.tsx +3 -1
- package/extract-react-types/heading-props.tsx +3 -0
- package/heading/package.json +15 -0
- package/heading-context/package.json +15 -0
- package/package.json +14 -2
- package/report.api.md +1 -0
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +34 -0
- package/scripts/__tests__/codegen.test.tsx +4 -0
- package/scripts/color-codegen-template.tsx +9 -0
- package/tmp/api-report-tmp.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`fa6c592fdb2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa6c592fdb2) - Introduce `Heading` into package in immediate alpha state. This is more or less a port of `@atlaskit/heading`. Component is not yet stable and implementation is likely to change.
|
|
8
|
+
- [`c2e55a9b782`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c2e55a9b782) - Adds surface detection support to the Box primitive:
|
|
9
|
+
|
|
10
|
+
- Enable a `Box` background colour to be set to the `utility.elevation.surface.current` token.
|
|
11
|
+
- Internally set the current surface CSS variable value when the background color of a Box is set to a surface token (e.g. `elevation.surface.raised`).
|
|
12
|
+
|
|
3
13
|
## 1.4.4
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -0,0 +1,19 @@
|
|
|
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} />
|
|
@@ -0,0 +1,28 @@
|
|
|
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" />
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
|
|
@@ -60,7 +60,7 @@ var Box = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
60
60
|
ref: ref
|
|
61
61
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
62
62
|
}, safeHtmlAttributes, {
|
|
63
|
-
css: [baseStyles, backgroundColor && _styleMaps.backgroundColorStylesMap[backgroundColor], padding && _styleMaps.paddingStylesMap.padding[padding], paddingBlock && _styleMaps.paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && _styleMaps.paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && _styleMaps.paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && _styleMaps.paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && _styleMaps.paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && _styleMaps.paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
63
|
+
css: [baseStyles, backgroundColor && _styleMaps.backgroundColorStylesMap[backgroundColor], (0, _styleMaps.isSurfaceColorToken)(backgroundColor) && _styleMaps.surfaceColorStylesMap[backgroundColor], padding && _styleMaps.paddingStylesMap.padding[padding], paddingBlock && _styleMaps.paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && _styleMaps.paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && _styleMaps.paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && _styleMaps.paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && _styleMaps.paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && _styleMaps.paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
64
64
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
65
65
|
className],
|
|
66
66
|
"data-testid": testId
|
|
@@ -0,0 +1,44 @@
|
|
|
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;
|
|
@@ -0,0 +1,95 @@
|
|
|
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;
|
|
@@ -4,9 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.uiTextStylesMap = exports.uiTextMap = exports.textColorStylesMap = exports.textColorMap = exports.spaceStylesMap = exports.spaceMap = exports.shadowMap = exports.paddingStylesMap = exports.lineHeightStylesMap = exports.lineHeightMap = exports.layerMap = exports.headingTextStylesMap = exports.headingTextMap = exports.fontWeightStylesMap = exports.fontWeightMap = exports.fontSizeStylesMap = exports.fontSizeMap = exports.fontFamilyStylesMap = exports.fontFamilyMap = exports.fillMap = exports.dimensionMap = exports.borderWidthMap = exports.borderRadiusMap = exports.borderColorMap = exports.bodyTextStylesMap = exports.bodyTextMap = exports.backgroundColorStylesMap = exports.backgroundColorMap = void 0;
|
|
7
|
+
exports.uiTextStylesMap = exports.uiTextMap = exports.textColorStylesMap = exports.textColorMap = exports.surfaceColorStylesMap = exports.surfaceColorMap = exports.spaceStylesMap = exports.spaceMap = exports.shadowMap = exports.paddingStylesMap = exports.lineHeightStylesMap = exports.lineHeightMap = exports.layerMap = exports.isSurfaceColorToken = exports.headingTextStylesMap = exports.headingTextMap = exports.fontWeightStylesMap = exports.fontWeightMap = exports.fontSizeStylesMap = exports.fontSizeMap = exports.fontFamilyStylesMap = exports.fontFamilyMap = exports.fillMap = exports.dimensionMap = exports.borderWidthMap = exports.borderRadiusMap = exports.borderColorMap = exports.bodyTextStylesMap = exports.bodyTextMap = exports.backgroundColorStylesMap = exports.backgroundColorMap = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
|
+
var _tokens = require("@atlaskit/tokens");
|
|
10
11
|
/**
|
|
11
12
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
12
13
|
* @codegen <<SignedSource::7af6097e56f7fb03635b6f8aaf121b02>>
|
|
@@ -60,10 +61,10 @@ exports.spaceMap = spaceMap;
|
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
63
|
-
* @codegen <<SignedSource::
|
|
64
|
+
* @codegen <<SignedSource::3db44f53b728773bb3ba1473d4567724>>
|
|
64
65
|
* @codegenId colors
|
|
65
66
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
66
|
-
* @codegenParams ["border", "background", "shadow", "text", "fill"]
|
|
67
|
+
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
67
68
|
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::815ddd719715ae06521cad06e1921e40>>
|
|
68
69
|
*/
|
|
69
70
|
var borderColorMap = {
|
|
@@ -286,7 +287,8 @@ var backgroundColorMap = {
|
|
|
286
287
|
'elevation.surface.raised': "var(--ds-surface-raised, #FFFFFF)",
|
|
287
288
|
'elevation.surface.raised.hovered': "var(--ds-surface-raised-hovered, #FAFBFC)",
|
|
288
289
|
'elevation.surface.raised.pressed': "var(--ds-surface-raised-pressed, #F4F5F7)",
|
|
289
|
-
'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)"
|
|
290
|
+
'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)",
|
|
291
|
+
'utility.elevation.surface.current': "var(--ds-elevation-surface-current, #FFFFFF)"
|
|
290
292
|
};
|
|
291
293
|
exports.backgroundColorMap = backgroundColorMap;
|
|
292
294
|
var shadowMap = {
|
|
@@ -360,6 +362,19 @@ var fillMap = {
|
|
|
360
362
|
'color.icon.subtle': "var(--ds-icon-subtle, #6B778C)"
|
|
361
363
|
};
|
|
362
364
|
exports.fillMap = fillMap;
|
|
365
|
+
var surfaceColorMap = {
|
|
366
|
+
'elevation.surface': "var(--ds-surface, #FFFFFF)",
|
|
367
|
+
'elevation.surface.hovered': "var(--ds-surface-hovered, #FAFBFC)",
|
|
368
|
+
'elevation.surface.pressed': "var(--ds-surface-pressed, #F4F5F7)",
|
|
369
|
+
'elevation.surface.overlay': "var(--ds-surface-overlay, #FFFFFF)",
|
|
370
|
+
'elevation.surface.overlay.hovered': "var(--ds-surface-overlay-hovered, #FAFBFC)",
|
|
371
|
+
'elevation.surface.overlay.pressed': "var(--ds-surface-overlay-pressed, #F4F5F7)",
|
|
372
|
+
'elevation.surface.raised': "var(--ds-surface-raised, #FFFFFF)",
|
|
373
|
+
'elevation.surface.raised.hovered': "var(--ds-surface-raised-hovered, #FAFBFC)",
|
|
374
|
+
'elevation.surface.raised.pressed': "var(--ds-surface-raised-pressed, #F4F5F7)",
|
|
375
|
+
'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)"
|
|
376
|
+
};
|
|
377
|
+
exports.surfaceColorMap = surfaceColorMap;
|
|
363
378
|
/**
|
|
364
379
|
* @codegenEnd
|
|
365
380
|
*/
|
|
@@ -528,4 +543,10 @@ exports.headingTextStylesMap = headingTextStylesMap;
|
|
|
528
543
|
var bodyTextStylesMap = getSerializedStylesMap('font', bodyTextMap);
|
|
529
544
|
exports.bodyTextStylesMap = bodyTextStylesMap;
|
|
530
545
|
var uiTextStylesMap = getSerializedStylesMap('font', uiTextMap);
|
|
531
|
-
exports.uiTextStylesMap = uiTextStylesMap;
|
|
546
|
+
exports.uiTextStylesMap = uiTextStylesMap;
|
|
547
|
+
var surfaceColorStylesMap = getSerializedStylesMap(_tokens.CURRENT_SURFACE_CSS_VAR, surfaceColorMap);
|
|
548
|
+
exports.surfaceColorStylesMap = surfaceColorStylesMap;
|
|
549
|
+
var isSurfaceColorToken = function isSurfaceColorToken(color) {
|
|
550
|
+
return surfaceColorMap[color] !== undefined;
|
|
551
|
+
};
|
|
552
|
+
exports.isSurfaceColorToken = isSurfaceColorToken;
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
|
-
import { backgroundColorStylesMap, paddingStylesMap } from '../xcss/style-maps.partial';
|
|
5
|
+
import { backgroundColorStylesMap, isSurfaceColorToken, paddingStylesMap, surfaceColorStylesMap } from '../xcss/style-maps.partial';
|
|
6
6
|
import { parseXcss } from '../xcss/xcss';
|
|
7
7
|
|
|
8
8
|
// Can either Exclude or Extract - here we're excluding all SVG-related elements
|
|
@@ -52,7 +52,7 @@ export const Box = /*#__PURE__*/forwardRef(({
|
|
|
52
52
|
ref: ref
|
|
53
53
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
54
54
|
}, safeHtmlAttributes, {
|
|
55
|
-
css: [baseStyles, backgroundColor && backgroundColorStylesMap[backgroundColor], padding && paddingStylesMap.padding[padding], paddingBlock && paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
55
|
+
css: [baseStyles, backgroundColor && backgroundColorStylesMap[backgroundColor], isSurfaceColorToken(backgroundColor) && surfaceColorStylesMap[backgroundColor], padding && paddingStylesMap.padding[padding], paddingBlock && paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
56
56
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
57
57
|
className],
|
|
58
58
|
"data-testid": testId
|
|
@@ -0,0 +1,35 @@
|
|
|
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;
|
|
@@ -0,0 +1,87 @@
|
|
|
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,4 +1,6 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
+
import { CURRENT_SURFACE_CSS_VAR } from '@atlaskit/tokens';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
4
6
|
* @codegen <<SignedSource::7af6097e56f7fb03635b6f8aaf121b02>>
|
|
@@ -48,10 +50,10 @@ export const spaceMap = {
|
|
|
48
50
|
*/
|
|
49
51
|
/**
|
|
50
52
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
51
|
-
* @codegen <<SignedSource::
|
|
53
|
+
* @codegen <<SignedSource::3db44f53b728773bb3ba1473d4567724>>
|
|
52
54
|
* @codegenId colors
|
|
53
55
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
54
|
-
* @codegenParams ["border", "background", "shadow", "text", "fill"]
|
|
56
|
+
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
55
57
|
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::815ddd719715ae06521cad06e1921e40>>
|
|
56
58
|
*/
|
|
57
59
|
export const borderColorMap = {
|
|
@@ -273,7 +275,8 @@ export const backgroundColorMap = {
|
|
|
273
275
|
'elevation.surface.raised': "var(--ds-surface-raised, #FFFFFF)",
|
|
274
276
|
'elevation.surface.raised.hovered': "var(--ds-surface-raised-hovered, #FAFBFC)",
|
|
275
277
|
'elevation.surface.raised.pressed': "var(--ds-surface-raised-pressed, #F4F5F7)",
|
|
276
|
-
'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)"
|
|
278
|
+
'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)",
|
|
279
|
+
'utility.elevation.surface.current': "var(--ds-elevation-surface-current, #FFFFFF)"
|
|
277
280
|
};
|
|
278
281
|
export const shadowMap = {
|
|
279
282
|
'elevation.shadow.overflow': "var(--ds-shadow-overflow, 0px 0px 8px #091e423f, 0px 0px 1px #091e424f)",
|
|
@@ -343,6 +346,18 @@ export const fillMap = {
|
|
|
343
346
|
'color.icon.information': "var(--ds-icon-information, #0747A6)",
|
|
344
347
|
'color.icon.subtle': "var(--ds-icon-subtle, #6B778C)"
|
|
345
348
|
};
|
|
349
|
+
export const surfaceColorMap = {
|
|
350
|
+
'elevation.surface': "var(--ds-surface, #FFFFFF)",
|
|
351
|
+
'elevation.surface.hovered': "var(--ds-surface-hovered, #FAFBFC)",
|
|
352
|
+
'elevation.surface.pressed': "var(--ds-surface-pressed, #F4F5F7)",
|
|
353
|
+
'elevation.surface.overlay': "var(--ds-surface-overlay, #FFFFFF)",
|
|
354
|
+
'elevation.surface.overlay.hovered': "var(--ds-surface-overlay-hovered, #FAFBFC)",
|
|
355
|
+
'elevation.surface.overlay.pressed': "var(--ds-surface-overlay-pressed, #F4F5F7)",
|
|
356
|
+
'elevation.surface.raised': "var(--ds-surface-raised, #FFFFFF)",
|
|
357
|
+
'elevation.surface.raised.hovered': "var(--ds-surface-raised-hovered, #FAFBFC)",
|
|
358
|
+
'elevation.surface.raised.pressed': "var(--ds-surface-raised-pressed, #F4F5F7)",
|
|
359
|
+
'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)"
|
|
360
|
+
};
|
|
346
361
|
/**
|
|
347
362
|
* @codegenEnd
|
|
348
363
|
*/
|
|
@@ -490,4 +505,6 @@ export const fontFamilyStylesMap = getSerializedStylesMap('fontFamily', fontFami
|
|
|
490
505
|
export const lineHeightStylesMap = getSerializedStylesMap('lineHeight', lineHeightMap);
|
|
491
506
|
export const headingTextStylesMap = getSerializedStylesMap('font', headingTextMap);
|
|
492
507
|
export const bodyTextStylesMap = getSerializedStylesMap('font', bodyTextMap);
|
|
493
|
-
export const uiTextStylesMap = getSerializedStylesMap('font', uiTextMap);
|
|
508
|
+
export const uiTextStylesMap = getSerializedStylesMap('font', uiTextMap);
|
|
509
|
+
export const surfaceColorStylesMap = getSerializedStylesMap(CURRENT_SURFACE_CSS_VAR, surfaceColorMap);
|
|
510
|
+
export const isSurfaceColorToken = color => surfaceColorMap[color] !== undefined;
|
|
@@ -5,7 +5,7 @@ var _excluded = ["as", "children", "backgroundColor", "padding", "paddingBlock",
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import { forwardRef } from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
|
-
import { backgroundColorStylesMap, paddingStylesMap } from '../xcss/style-maps.partial';
|
|
8
|
+
import { backgroundColorStylesMap, isSurfaceColorToken, paddingStylesMap, surfaceColorStylesMap } from '../xcss/style-maps.partial';
|
|
9
9
|
import { parseXcss } from '../xcss/xcss';
|
|
10
10
|
|
|
11
11
|
// Can either Exclude or Extract - here we're excluding all SVG-related elements
|
|
@@ -53,7 +53,7 @@ export var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
53
53
|
ref: ref
|
|
54
54
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
55
55
|
}, safeHtmlAttributes, {
|
|
56
|
-
css: [baseStyles, backgroundColor && backgroundColorStylesMap[backgroundColor], padding && paddingStylesMap.padding[padding], paddingBlock && paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
56
|
+
css: [baseStyles, backgroundColor && backgroundColorStylesMap[backgroundColor], isSurfaceColorToken(backgroundColor) && surfaceColorStylesMap[backgroundColor], padding && paddingStylesMap.padding[padding], paddingBlock && paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
57
57
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
58
58
|
className],
|
|
59
59
|
"data-testid": testId
|
|
@@ -0,0 +1,34 @@
|
|
|
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;
|
|
@@ -0,0 +1,87 @@
|
|
|
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;
|