@atlaskit/primitives 1.4.4 → 1.6.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/constellation/heading/code.mdx +19 -0
  3. package/constellation/heading/examples.mdx +28 -0
  4. package/constellation/heading/usage.mdx +21 -0
  5. package/dist/cjs/components/box.js +1 -1
  6. package/dist/cjs/components/heading-context.js +44 -0
  7. package/dist/cjs/components/heading.js +95 -0
  8. package/dist/cjs/xcss/style-maps.partial.js +39 -6
  9. package/dist/es2019/components/box.js +2 -2
  10. package/dist/es2019/components/heading-context.js +35 -0
  11. package/dist/es2019/components/heading.js +87 -0
  12. package/dist/es2019/xcss/style-maps.partial.js +33 -5
  13. package/dist/esm/components/box.js +2 -2
  14. package/dist/esm/components/heading-context.js +34 -0
  15. package/dist/esm/components/heading.js +87 -0
  16. package/dist/esm/xcss/style-maps.partial.js +35 -5
  17. package/dist/types/components/heading-context.d.ts +31 -0
  18. package/dist/types/components/heading.d.ts +45 -0
  19. package/dist/types/components/internal/surface-provider.d.ts +2 -2
  20. package/dist/types/xcss/style-maps.partial.d.ts +34 -4
  21. package/dist/types-ts4.5/components/heading-context.d.ts +31 -0
  22. package/dist/types-ts4.5/components/heading.d.ts +45 -0
  23. package/dist/types-ts4.5/components/internal/surface-provider.d.ts +2 -2
  24. package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +34 -4
  25. package/extract-react-types/box-props.tsx +3 -1
  26. package/extract-react-types/heading-props.tsx +3 -0
  27. package/heading/package.json +15 -0
  28. package/heading-context/package.json +15 -0
  29. package/package.json +14 -2
  30. package/report.api.md +18 -1
  31. package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +34 -0
  32. package/scripts/__tests__/codegen.test.tsx +4 -0
  33. package/scripts/color-codegen-template.tsx +9 -0
  34. package/scripts/spacing-codegen-template.tsx +15 -0
  35. package/tmp/api-report-tmp.d.ts +18 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`9cd356f858a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9cd356f858a) - Negative space tokens can now be applied to margin properties via `xcss`.
8
+
9
+ ## 1.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`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.
14
+ - [`c2e55a9b782`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c2e55a9b782) - Adds surface detection support to the Box primitive:
15
+
16
+ - Enable a `Box` background colour to be set to the `utility.elevation.surface.current` token.
17
+ - 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`).
18
+
3
19
  ## 1.4.4
4
20
 
5
21
  ### 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.negativeSpaceMap = 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>>
@@ -32,7 +33,7 @@ exports.dimensionMap = dimensionMap;
32
33
 
33
34
  /**
34
35
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
35
- * @codegen <<SignedSource::8cc3cccc1c75ae85af885aaf8a1f69b8>>
36
+ * @codegen <<SignedSource::6a1c1c7a326eab1fd8f07e923e26f784>>
36
37
  * @codegenId spacing
37
38
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
38
39
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::298080e8024fb3eb37589721413e0156>>
@@ -54,16 +55,28 @@ var spaceMap = {
54
55
  'space.1000': "var(--ds-space-1000, 80px)"
55
56
  };
56
57
  exports.spaceMap = spaceMap;
58
+ var negativeSpaceMap = {
59
+ 'space.negative.025': "var(--ds-space-negative-025, -2px)",
60
+ 'space.negative.050': "var(--ds-space-negative-050, -4px)",
61
+ 'space.negative.075': "var(--ds-space-negative-075, -6px)",
62
+ 'space.negative.100': "var(--ds-space-negative-100, -8px)",
63
+ 'space.negative.150': "var(--ds-space-negative-150, -12px)",
64
+ 'space.negative.200': "var(--ds-space-negative-200, -16px)",
65
+ 'space.negative.250': "var(--ds-space-negative-250, -20px)",
66
+ 'space.negative.300': "var(--ds-space-negative-300, -24px)",
67
+ 'space.negative.400': "var(--ds-space-negative-400, -32px)"
68
+ };
69
+ exports.negativeSpaceMap = negativeSpaceMap;
57
70
  /**
58
71
  * @codegenEnd
59
72
  */
60
73
 
61
74
  /**
62
75
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
63
- * @codegen <<SignedSource::3f4d926ce14cda107d25c697f3a0c200>>
76
+ * @codegen <<SignedSource::3db44f53b728773bb3ba1473d4567724>>
64
77
  * @codegenId colors
65
78
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
66
- * @codegenParams ["border", "background", "shadow", "text", "fill"]
79
+ * @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
67
80
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::815ddd719715ae06521cad06e1921e40>>
68
81
  */
69
82
  var borderColorMap = {
@@ -286,7 +299,8 @@ var backgroundColorMap = {
286
299
  'elevation.surface.raised': "var(--ds-surface-raised, #FFFFFF)",
287
300
  'elevation.surface.raised.hovered': "var(--ds-surface-raised-hovered, #FAFBFC)",
288
301
  'elevation.surface.raised.pressed': "var(--ds-surface-raised-pressed, #F4F5F7)",
289
- 'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)"
302
+ 'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)",
303
+ 'utility.elevation.surface.current': "var(--ds-elevation-surface-current, #FFFFFF)"
290
304
  };
291
305
  exports.backgroundColorMap = backgroundColorMap;
292
306
  var shadowMap = {
@@ -360,6 +374,19 @@ var fillMap = {
360
374
  'color.icon.subtle': "var(--ds-icon-subtle, #6B778C)"
361
375
  };
362
376
  exports.fillMap = fillMap;
377
+ var surfaceColorMap = {
378
+ 'elevation.surface': "var(--ds-surface, #FFFFFF)",
379
+ 'elevation.surface.hovered': "var(--ds-surface-hovered, #FAFBFC)",
380
+ 'elevation.surface.pressed': "var(--ds-surface-pressed, #F4F5F7)",
381
+ 'elevation.surface.overlay': "var(--ds-surface-overlay, #FFFFFF)",
382
+ 'elevation.surface.overlay.hovered': "var(--ds-surface-overlay-hovered, #FAFBFC)",
383
+ 'elevation.surface.overlay.pressed': "var(--ds-surface-overlay-pressed, #F4F5F7)",
384
+ 'elevation.surface.raised': "var(--ds-surface-raised, #FFFFFF)",
385
+ 'elevation.surface.raised.hovered': "var(--ds-surface-raised-hovered, #FAFBFC)",
386
+ 'elevation.surface.raised.pressed': "var(--ds-surface-raised-pressed, #F4F5F7)",
387
+ 'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)"
388
+ };
389
+ exports.surfaceColorMap = surfaceColorMap;
363
390
  /**
364
391
  * @codegenEnd
365
392
  */
@@ -528,4 +555,10 @@ exports.headingTextStylesMap = headingTextStylesMap;
528
555
  var bodyTextStylesMap = getSerializedStylesMap('font', bodyTextMap);
529
556
  exports.bodyTextStylesMap = bodyTextStylesMap;
530
557
  var uiTextStylesMap = getSerializedStylesMap('font', uiTextMap);
531
- exports.uiTextStylesMap = uiTextStylesMap;
558
+ exports.uiTextStylesMap = uiTextStylesMap;
559
+ var surfaceColorStylesMap = getSerializedStylesMap(_tokens.CURRENT_SURFACE_CSS_VAR, surfaceColorMap);
560
+ exports.surfaceColorStylesMap = surfaceColorStylesMap;
561
+ var isSurfaceColorToken = function isSurfaceColorToken(color) {
562
+ return surfaceColorMap[color] !== undefined;
563
+ };
564
+ 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>>
@@ -22,7 +24,7 @@ export const dimensionMap = {
22
24
  */
23
25
  /**
24
26
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
25
- * @codegen <<SignedSource::8cc3cccc1c75ae85af885aaf8a1f69b8>>
27
+ * @codegen <<SignedSource::6a1c1c7a326eab1fd8f07e923e26f784>>
26
28
  * @codegenId spacing
27
29
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
28
30
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::298080e8024fb3eb37589721413e0156>>
@@ -43,15 +45,26 @@ export const spaceMap = {
43
45
  'space.800': "var(--ds-space-800, 64px)",
44
46
  'space.1000': "var(--ds-space-1000, 80px)"
45
47
  };
48
+ export const negativeSpaceMap = {
49
+ 'space.negative.025': "var(--ds-space-negative-025, -2px)",
50
+ 'space.negative.050': "var(--ds-space-negative-050, -4px)",
51
+ 'space.negative.075': "var(--ds-space-negative-075, -6px)",
52
+ 'space.negative.100': "var(--ds-space-negative-100, -8px)",
53
+ 'space.negative.150': "var(--ds-space-negative-150, -12px)",
54
+ 'space.negative.200': "var(--ds-space-negative-200, -16px)",
55
+ 'space.negative.250': "var(--ds-space-negative-250, -20px)",
56
+ 'space.negative.300': "var(--ds-space-negative-300, -24px)",
57
+ 'space.negative.400': "var(--ds-space-negative-400, -32px)"
58
+ };
46
59
  /**
47
60
  * @codegenEnd
48
61
  */
49
62
  /**
50
63
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
51
- * @codegen <<SignedSource::3f4d926ce14cda107d25c697f3a0c200>>
64
+ * @codegen <<SignedSource::3db44f53b728773bb3ba1473d4567724>>
52
65
  * @codegenId colors
53
66
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
54
- * @codegenParams ["border", "background", "shadow", "text", "fill"]
67
+ * @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
55
68
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::815ddd719715ae06521cad06e1921e40>>
56
69
  */
57
70
  export const borderColorMap = {
@@ -273,7 +286,8 @@ export const backgroundColorMap = {
273
286
  'elevation.surface.raised': "var(--ds-surface-raised, #FFFFFF)",
274
287
  'elevation.surface.raised.hovered': "var(--ds-surface-raised-hovered, #FAFBFC)",
275
288
  'elevation.surface.raised.pressed': "var(--ds-surface-raised-pressed, #F4F5F7)",
276
- 'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)"
289
+ 'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)",
290
+ 'utility.elevation.surface.current': "var(--ds-elevation-surface-current, #FFFFFF)"
277
291
  };
278
292
  export const shadowMap = {
279
293
  'elevation.shadow.overflow': "var(--ds-shadow-overflow, 0px 0px 8px #091e423f, 0px 0px 1px #091e424f)",
@@ -343,6 +357,18 @@ export const fillMap = {
343
357
  'color.icon.information': "var(--ds-icon-information, #0747A6)",
344
358
  'color.icon.subtle': "var(--ds-icon-subtle, #6B778C)"
345
359
  };
360
+ export const surfaceColorMap = {
361
+ 'elevation.surface': "var(--ds-surface, #FFFFFF)",
362
+ 'elevation.surface.hovered': "var(--ds-surface-hovered, #FAFBFC)",
363
+ 'elevation.surface.pressed': "var(--ds-surface-pressed, #F4F5F7)",
364
+ 'elevation.surface.overlay': "var(--ds-surface-overlay, #FFFFFF)",
365
+ 'elevation.surface.overlay.hovered': "var(--ds-surface-overlay-hovered, #FAFBFC)",
366
+ 'elevation.surface.overlay.pressed': "var(--ds-surface-overlay-pressed, #F4F5F7)",
367
+ 'elevation.surface.raised': "var(--ds-surface-raised, #FFFFFF)",
368
+ 'elevation.surface.raised.hovered': "var(--ds-surface-raised-hovered, #FAFBFC)",
369
+ 'elevation.surface.raised.pressed': "var(--ds-surface-raised-pressed, #F4F5F7)",
370
+ 'elevation.surface.sunken': "var(--ds-surface-sunken, #F4F5F7)"
371
+ };
346
372
  /**
347
373
  * @codegenEnd
348
374
  */
@@ -490,4 +516,6 @@ export const fontFamilyStylesMap = getSerializedStylesMap('fontFamily', fontFami
490
516
  export const lineHeightStylesMap = getSerializedStylesMap('lineHeight', lineHeightMap);
491
517
  export const headingTextStylesMap = getSerializedStylesMap('font', headingTextMap);
492
518
  export const bodyTextStylesMap = getSerializedStylesMap('font', bodyTextMap);
493
- export const uiTextStylesMap = getSerializedStylesMap('font', uiTextMap);
519
+ export const uiTextStylesMap = getSerializedStylesMap('font', uiTextMap);
520
+ export const surfaceColorStylesMap = getSerializedStylesMap(CURRENT_SURFACE_CSS_VAR, surfaceColorMap);
521
+ 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;