@atlaskit/primitives 14.8.4 → 14.9.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 (48) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/constellation/anchor/examples.mdx +4 -4
  3. package/constellation/box/examples.mdx +7 -7
  4. package/constellation/box/usage.mdx +2 -2
  5. package/constellation/inline/examples.mdx +1 -1
  6. package/constellation/inline/usage.mdx +18 -4
  7. package/constellation/overview/index.mdx +1 -1
  8. package/constellation/pressable/examples.mdx +4 -4
  9. package/constellation/responsive/examples.mdx +18 -25
  10. package/constellation/stack/usage.mdx +1 -1
  11. package/constellation/text/examples.mdx +2 -2
  12. package/dist/cjs/compiled/components/metric-text.compiled.css +10 -0
  13. package/dist/cjs/compiled/components/metric-text.js +55 -0
  14. package/dist/cjs/compiled/index.js +7 -0
  15. package/dist/cjs/components/metric-text.js +66 -0
  16. package/dist/cjs/index.js +7 -0
  17. package/dist/cjs/xcss/style-maps.partial.js +14 -5
  18. package/dist/es2019/compiled/components/metric-text.compiled.css +10 -0
  19. package/dist/es2019/compiled/components/metric-text.js +46 -0
  20. package/dist/es2019/compiled/index.js +1 -0
  21. package/dist/es2019/components/metric-text.js +58 -0
  22. package/dist/es2019/index.js +1 -0
  23. package/dist/es2019/xcss/style-maps.partial.js +13 -4
  24. package/dist/esm/compiled/components/metric-text.compiled.css +10 -0
  25. package/dist/esm/compiled/components/metric-text.js +46 -0
  26. package/dist/esm/compiled/index.js +1 -0
  27. package/dist/esm/components/metric-text.js +58 -0
  28. package/dist/esm/index.js +1 -0
  29. package/dist/esm/xcss/style-maps.partial.js +13 -4
  30. package/dist/types/compiled/components/metric-text.d.ts +46 -0
  31. package/dist/types/compiled/components/stack.d.ts +1 -1
  32. package/dist/types/compiled/components/types.d.ts +1 -0
  33. package/dist/types/compiled/index.d.ts +1 -0
  34. package/dist/types/components/metric-text.d.ts +53 -0
  35. package/dist/types/index.d.ts +2 -0
  36. package/dist/types/xcss/style-maps.partial.d.ts +14 -2
  37. package/dist/types/xcss/xcss.d.ts +4 -1
  38. package/dist/types-ts4.5/compiled/components/metric-text.d.ts +49 -0
  39. package/dist/types-ts4.5/compiled/components/stack.d.ts +1 -1
  40. package/dist/types-ts4.5/compiled/components/types.d.ts +1 -0
  41. package/dist/types-ts4.5/compiled/index.d.ts +1 -0
  42. package/dist/types-ts4.5/components/metric-text.d.ts +56 -0
  43. package/dist/types-ts4.5/index.d.ts +2 -0
  44. package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +14 -2
  45. package/dist/types-ts4.5/xcss/xcss.d.ts +4 -1
  46. package/package.json +10 -9
  47. package/scripts/text-codegen-template.tsx +13 -4
  48. package/scripts/typography-codegen-template.tsx +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 14.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#172429](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/172429)
8
+ [`324162357eb4d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/324162357eb4d) -
9
+ Added MetricText component which provides a convenient way to consume new metric typography tokens
10
+ for charts and other numerical components. Made metric tokens available in xcss via the font
11
+ shorthand property.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 14.8.4
4
18
 
5
19
  ### Patch Changes
@@ -54,16 +54,16 @@ global styles.
54
54
 
55
55
  <Example Component={AnchorDefault} packageName="@atlaskit/primitives/anchor" />
56
56
 
57
- ## Basic styling with XCSS
57
+ ## Basic styling
58
58
 
59
- Anchor can be styled further using the design system styling API,
60
- [XCSS](/components/primitives/xcss).
59
+ Anchor can be styled further using the design system styling API using
60
+ [cssMap](/components/css/examples).
61
61
 
62
62
  <Example Component={AnchorBasic} packageName="@atlaskit/primitives/anchor" />
63
63
 
64
64
  ## Advanced styling
65
65
 
66
- Use a combination of XCSS and other primitives for more complex designs.
66
+ Use a combination of cssMap and other primitives for more complex designs.
67
67
 
68
68
  <Example Component={AnchorStyled} packageName="@atlaskit/primitives/anchor" />
69
69
 
@@ -23,7 +23,7 @@ import { CodeDocsHeader } from '@af/design-system-docs-ui';
23
23
 
24
24
  Box is a general-purpose container that allows for controlled use of design tokens. Use the given
25
25
  props to configure display behavior and styling that aligns with the Atlassian Design System. Use
26
- [XCSS](/components/primitives/xcss/usage) to style primitive components safely with tokens.
26
+ [cssMap](/components/css/overview#cssmap) to style primitive components safely with tokens.
27
27
 
28
28
  <Example Component={BoxBasic} packageName="@atlaskit/primitives/box" />
29
29
 
@@ -47,20 +47,20 @@ list of color tokens, visit the [token list](/components/tokens/all-tokens).
47
47
 
48
48
  <Example Component={BoxBackgroundColor} packageName="@atlaskit/primitives/box" />
49
49
 
50
- ## XCSS
50
+ ## Styling
51
51
 
52
- Box exposes an `xcss` prop. This prop accepts `xcss` function calls that contain a subset of
53
- permitted styles. When used with `Box`, `xcss` accepts most CSS properties, and when a token exists,
54
- the rule accepts that token as a value.
52
+ Box exposes an `xcss` prop. This prop accepts `cssMap` function calls from our CSS-in-JS library
53
+ [@atlaskit/css](/components/css/overview#cssmap) which contains a subset of permitted styles.
55
54
 
56
- For more information on XCSS, see the dedicated [XCSS documentation](/components/primitives/xcss).
55
+ For more information on cssMap, see the dedicated
56
+ [CSS library documentation](/components/css/overview#cssmap).
57
57
 
58
58
  <Example Component={BoxXcss} packageName="@atlaskit/primitives/box" />
59
59
 
60
60
  ## Conditional styles
61
61
 
62
62
  To achieve conditional styles, we suggest composing conditional styles via the `props.xcss` API
63
- rather than applying conditional behaviour to individual props.
63
+ rather than applying conditional behavior to individual props.
64
64
 
65
65
  <Example Component={BoxConditional} packageName="@atlaskit/primitives/box" />
66
66
 
@@ -27,7 +27,7 @@ custom buttons, or [anchor](/components/primitives/anchor/usage) to build custom
27
27
  ## Styling
28
28
 
29
29
  Display behavior is set by using the available props or using
30
- [XCSS](/components/primitives/xcss/usage). Makers can make design decisions for box by setting:
30
+ [cssMap](/components/css/overview#cssmap). Makers can make design decisions for box by setting:
31
31
 
32
32
  - `padding`
33
33
  - `paddingInline`
@@ -44,4 +44,4 @@ Display behavior is set by using the available props or using
44
44
  - [Manage vertical layout using a stack component](/components/primitives/stack/usage)
45
45
  - [Build custom buttons using a pressable component](/components/primitives/pressable/usage)
46
46
  - [Build custom links using an anchor component](/components/primitives/anchor/usage)
47
- - [Use design tokens in code with XCSS](/components/primitives/XCSS/usage)
47
+ - [Use design tokens in code with cssMap](/components/css/overview#cssmap)
@@ -60,7 +60,7 @@ In situations where tabbing order changes based on different breakpoints, then w
60
60
  different orderings of content.
61
61
 
62
62
  For non-tabbable content that needs to be reversed, `flex-direction: row-reverse` is supported in
63
- XCSS. However, please be aware that we may lint against this in the future.
63
+ via the `xcss` prop. However, please be aware that we may lint against this in the future.
64
64
 
65
65
  ## Alignment
66
66
 
@@ -53,9 +53,23 @@ the list items and set the font size to zero to get the same visual results whil
53
53
  semantics across browsers and assistive technologies.
54
54
 
55
55
  ```tsx
56
- <Box as="li" xcss={xcss({ '::marker': { fontSize: 0 } })}>
57
- Example
58
- </Box>
56
+ const recommendedStyles = cssMap({
57
+ list: {
58
+ '&::marker': {
59
+ fontSize: '0',
60
+ },
61
+ },
62
+ });
63
+
64
+ export default function Example() {
65
+ return (
66
+ <Inline as="ul">
67
+ <li css={recommendedStyles.list}>Item 1</li>
68
+ <li css={recommendedStyles.list}>Item 2</li>
69
+ <li css={recommendedStyles.list}>Item 3</li>
70
+ </Inline>
71
+ );
72
+ }
59
73
  ```
60
74
 
61
75
  Alternatively, if you do need to use `list-style-type: none` you can add add `role="list"` to the
@@ -65,4 +79,4 @@ Alternatively, if you do need to use `list-style-type: none` you can add add `ro
65
79
 
66
80
  - [Use box for a generic container with access to design tokens](/components/primitives/box/usage)
67
81
  - [Manage vertical layout using a stack component](/components/primitives/stack/usage)
68
- - [Use design tokens in code with XCSS](/components/primitives/XCSS/usage)
82
+ - [Use design tokens in code with cssMap](/components/css/overview#cssmap)
@@ -99,4 +99,4 @@ and vertical `Stack` components.
99
99
  - [Flex](/components/primitives/flex/examples)
100
100
  - [Pressable](/components/primitives/pressable/examples)
101
101
  - [Anchor](/components/primitives/anchor/examples)
102
- - [xcss](/components/primitives/xcss/usage)
102
+ - [cssMap](/components/css/overview#cssmap)
@@ -33,10 +33,10 @@ Pressable is unstyled by default, aside from basic focus styles.
33
33
 
34
34
  <Example Component={PressableDefault} packageName="@atlaskit/primitives/pressable" />
35
35
 
36
- ## Basic styling with XCSS
36
+ ## Basic styling
37
37
 
38
38
  Pressable can be styled further using the design system styling API,
39
- [XCSS](/components/primitives/xcss).
39
+ [cssMap](/components/css/overview#cssmap).
40
40
 
41
41
  Make sure styling indicates the interaction state using `:hover` and `:active` pseudo-classes.
42
42
 
@@ -44,7 +44,7 @@ Make sure styling indicates the interaction state using `:hover` and `:active` p
44
44
 
45
45
  ## Advanced styling
46
46
 
47
- Use a combination of XCSS and other primitives for more complex designs.
47
+ Use a combination of `cssMap` and other primitives for more complex designs.
48
48
 
49
49
  <Example
50
50
  Component={PressableStyled}
@@ -55,7 +55,7 @@ Use a combination of XCSS and other primitives for more complex designs.
55
55
  ## Disabled
56
56
 
57
57
  You can disable pressable buttons with the `isDisabled` prop. Disabled styles should be applied and
58
- defined conditionally using XCSS.
58
+ defined conditionally using `cssMap`.
59
59
 
60
60
  Disabled buttons can cause accessibility issues (disabled elements are not in the tab order) so
61
61
  wherever possible, avoid using `isDisabled`. Instead, use validation or other techniques to show
@@ -4,12 +4,6 @@ description: Responsive helpers and primitives to build responsive UIs.
4
4
  order: 1
5
5
  ---
6
6
 
7
- import CSSExample from '../../examples/constellation/responsive/css';
8
- import XCSSExample from '../../examples/constellation/responsive/xcss';
9
- import ShowExample from '../../examples/constellation/responsive/show';
10
- import HideExample from '../../examples/constellation/responsive/hide';
11
- import ShowHideExample from '../../examples/constellation/responsive/show-hide';
12
-
13
7
  import { CodeDocsHeader } from '@af/design-system-docs-ui';
14
8
 
15
9
  <CodeDocsHeader
@@ -18,26 +12,25 @@ import { CodeDocsHeader } from '@af/design-system-docs-ui';
18
12
  directoryName="primitives"
19
13
  />
20
14
 
21
- ## Responsive `css` or `xcss`
22
-
23
- Utilize our media queries exposed in `css`, `styled`, or `xcss` as computed keys to build responsive
24
- UIs. Learn more about these media query exports in [usage](/components/primitives/responsive/usage).
25
-
26
- ### Using with `xcss`
27
-
28
- Please use `xcss` whenever possible to ensure consistency and safety with style overrides. Read more
29
- at [xcss](/components/primitives/xcss)
30
-
31
- <Example Component={XCSSExample} packageName="@atlaskit/primitives/responsive" />
32
-
33
- ### Using with `css`
15
+ ## Media queries
34
16
 
35
- <Example Component={CSSExample} packageName="@atlaskit/primitives/responsive" />
17
+ Media queries can be applied directly in your styles. As you type `@media`, you'll get IntelliSense
18
+ support showing all the allowed media queries from the Atlassian Design System. For a complete list
19
+ of available breakpoints and media queries, see the
20
+ [breakpoints documentation](/components/primitives/responsive/breakpoints).
36
21
 
37
- ## Responsive primitives
22
+ ### Using with `cssMap`
38
23
 
39
- Consider these shortcuts to writing your own custom media queries. Composing with our primitives
40
- will be far quicker and consistent to implement, but may result in excess DOM nodes.
24
+ ```jsx
25
+ import { cssMap } from '@atlaskit/css';
41
26
 
42
- - [Show](/components/primitives/responsive/show)
43
- - [Hide](/components/primitives/responsive/hide)
27
+ const styles = cssMap({
28
+ // Start typing '@media' to see available media queries
29
+ '@media (min-width: 48rem)': {
30
+ color: token('color.text'),
31
+ },
32
+ '@media (min-width: 64rem)': {
33
+ color: token('color.text.accent.blue'),
34
+ },
35
+ });
36
+ ```
@@ -40,4 +40,4 @@ These props customize the spacing and styling of any child elements:
40
40
 
41
41
  - [Use box for a generic container with access to design tokens](/components/primitives/box/usage)
42
42
  - [Manage horizontal layout using an inline component](/components/primitives/inline/usage)
43
- - [Use design tokens in code with XCSS](/components/primitives/XCSS/usage)
43
+ - [Use design tokens in code with cssMap](/components/css/overview#cssmap)
@@ -91,7 +91,7 @@ However if truncation cannot be avoided, for example when displaying user-genera
91
91
 
92
92
  ## Customization
93
93
 
94
- A restricted set of styles can be customized using the `xcss` prop. This is only available in the
95
- Compiled version of Text.
94
+ A restricted set of styles can be customized using the `xcss` prop, using
95
+ [cssMap](/components/css/overview#cssmap).
96
96
 
97
97
  <Example Component={TextCustomization} packageName="@atlaskit/primitives" />
@@ -0,0 +1,10 @@
1
+ ._11c81lu7{font:var(--ds-font-metric-medium,normal 653 24px/28px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
2
+ ._11c81r7r{font:var(--ds-font-metric-large,normal 653 28px/2pc ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
3
+ ._11c8h56o{font:var(--ds-font-metric-small,normal 653 1pc/20px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
4
+ ._18u0idpf{margin-left:0}
5
+ ._19pkidpf{margin-top:0}
6
+ ._2hwxidpf{margin-right:0}
7
+ ._otyridpf{margin-bottom:0}
8
+ ._y3gn1h6o{text-align:center}
9
+ ._y3gnh9n0{text-align:end}
10
+ ._y3gnv2br{text-align:start}
@@ -0,0 +1,55 @@
1
+ /* metric-text.tsx generated by @compiled/babel-plugin v0.36.1 */
2
+ "use strict";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.default = void 0;
10
+ require("./metric-text.compiled.css");
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var React = _react;
13
+ var _runtime = require("@compiled/react/runtime");
14
+ var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
+ var asAllowlist = ['span', 'div'];
17
+ var styles = {
18
+ root: "_19pkidpf _2hwxidpf _otyridpf _18u0idpf",
19
+ 'textAlign.center': "_y3gn1h6o",
20
+ 'textAlign.end': "_y3gnh9n0",
21
+ 'textAlign.start': "_y3gnv2br"
22
+ };
23
+ var fontSizeMap = {
24
+ small: "_11c8h56o",
25
+ medium: "_11c81lu7",
26
+ large: "_11c81r7r"
27
+ };
28
+
29
+ /**
30
+ * __MetricText__
31
+ *
32
+ * MetricText is a primitive component that has the Atlassian Design System's design guidelines baked in.
33
+ * It is designed for use specifically with displaying metrics and is not to be used for headings or general UI text.
34
+ * It renders a `span` by default.
35
+ *
36
+ * @internal
37
+ */
38
+ var MetricText = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
39
+ var _ref$as = _ref.as,
40
+ Component = _ref$as === void 0 ? 'span' : _ref$as,
41
+ align = _ref.align,
42
+ testId = _ref.testId,
43
+ id = _ref.id,
44
+ size = _ref.size,
45
+ children = _ref.children;
46
+ (0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: MetricText received an invalid \"as\" value of \"".concat(Component, "\""));
47
+ var component = /*#__PURE__*/React.createElement(Component, {
48
+ ref: ref,
49
+ "data-testid": testId,
50
+ id: id,
51
+ className: (0, _runtime.ax)([styles.root, size && fontSizeMap[size], align && styles["textAlign.".concat(align)]])
52
+ }, children);
53
+ return component;
54
+ });
55
+ var _default = exports.default = MetricText;
@@ -52,6 +52,12 @@ Object.defineProperty(exports, "Inline", {
52
52
  return _inline.default;
53
53
  }
54
54
  });
55
+ Object.defineProperty(exports, "MetricText", {
56
+ enumerable: true,
57
+ get: function get() {
58
+ return _metricText.default;
59
+ }
60
+ });
55
61
  Object.defineProperty(exports, "Pressable", {
56
62
  enumerable: true,
57
63
  get: function get() {
@@ -101,6 +107,7 @@ var _flex = _interopRequireDefault(require("./components/flex"));
101
107
  var _grid = _interopRequireDefault(require("./components/grid"));
102
108
  var _bleed = _interopRequireDefault(require("./components/bleed"));
103
109
  var _text = _interopRequireDefault(require("./components/text"));
110
+ var _metricText = _interopRequireDefault(require("./components/metric-text"));
104
111
  var _pressable = _interopRequireDefault(require("./components/pressable"));
105
112
  var _anchor = _interopRequireDefault(require("./components/anchor"));
106
113
  var _responsive = require("./responsive");
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = require("react");
9
+ var _react2 = require("@emotion/react");
10
+ var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
11
+ var _styleMaps = require("../xcss/style-maps.partial");
12
+ /**
13
+ * @jsxRuntime classic
14
+ * @jsx jsx
15
+ */
16
+
17
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
18
+
19
+ var asAllowlist = ['span', 'div'];
20
+ // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
21
+ // Long term we should remove those instances from the reset - it should be a reset to 0.
22
+ // For now, at least we know <MetricText> will be unaffected by this.
23
+ var resetStyles = (0, _react2.css)({
24
+ margin: 0
25
+ });
26
+ var textAlignMap = {
27
+ center: (0, _react2.css)({
28
+ textAlign: 'center'
29
+ }),
30
+ end: (0, _react2.css)({
31
+ textAlign: 'end'
32
+ }),
33
+ start: (0, _react2.css)({
34
+ textAlign: 'start'
35
+ })
36
+ };
37
+
38
+ /**
39
+ * __MetricText__
40
+ *
41
+ * MetricText is a primitive component that has the Atlassian Design System's design guidelines baked in.
42
+ * It is designed for use specifically with displaying metrics and is not to be used for headings or general UI text.
43
+ * It renders a `span` by default.
44
+ *
45
+ * @internal
46
+ */
47
+ var MetricText = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
48
+ var _ref$as = _ref.as,
49
+ Component = _ref$as === void 0 ? 'span' : _ref$as,
50
+ align = _ref.align,
51
+ testId = _ref.testId,
52
+ id = _ref.id,
53
+ size = _ref.size,
54
+ children = _ref.children;
55
+ (0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: MetricText received an invalid \"as\" value of \"".concat(Component, "\""));
56
+ var component = (0, _react2.jsx)(Component, {
57
+ ref: ref,
58
+ css: [resetStyles,
59
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
60
+ size && _styleMaps.metricTextSizeStylesMap[size], align && textAlignMap[align]],
61
+ "data-testid": testId,
62
+ id: id
63
+ }, children);
64
+ return component;
65
+ });
66
+ var _default = exports.default = MetricText;
package/dist/cjs/index.js CHANGED
@@ -40,6 +40,12 @@ Object.defineProperty(exports, "Inline", {
40
40
  return _inline.default;
41
41
  }
42
42
  });
43
+ Object.defineProperty(exports, "MetricText", {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _metricText.default;
47
+ }
48
+ });
43
49
  Object.defineProperty(exports, "Pressable", {
44
50
  enumerable: true,
45
51
  get: function get() {
@@ -108,6 +114,7 @@ var _flex = _interopRequireDefault(require("./components/flex"));
108
114
  var _grid = _interopRequireDefault(require("./components/grid"));
109
115
  var _bleed = _interopRequireDefault(require("./components/bleed"));
110
116
  var _text = _interopRequireDefault(require("./components/text"));
117
+ var _metricText = _interopRequireDefault(require("./components/metric-text"));
111
118
  var _pressable = _interopRequireDefault(require("./components/pressable"));
112
119
  var _anchor = _interopRequireDefault(require("./components/anchor"));
113
120
  var _responsive = require("./responsive");
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.textWeightStylesMap = exports.textWeightMap = exports.textSizeStylesMap = exports.textSizeMap = exports.textColorStylesMap = exports.textColorMap = exports.surfaceColorStylesMap = exports.surfaceColorMap = exports.spaceStylesMap = exports.shadowMap = exports.positiveSpaceMap = exports.paddingStylesMap = exports.opacityMap = exports.negativeSpaceMap = exports.layerMap = exports.isSurfaceColorToken = exports.inverseColorMap = exports.getSerializedStylesMap = exports.fontWeightStylesMap = exports.fontWeightMap = exports.fontStylesMap = exports.fontMap = exports.fontFamilyStylesMap = exports.fontFamilyMap = exports.fillMap = exports.dimensionMap = exports.borderWidthMap = exports.borderRadiusMap = exports.borderColorMap = exports.backgroundColorStylesMap = exports.backgroundColorMap = exports.allSpaceMap = void 0;
7
+ exports.textWeightStylesMap = exports.textWeightMap = exports.textSizeStylesMap = exports.textSizeMap = exports.textColorStylesMap = exports.textColorMap = exports.surfaceColorStylesMap = exports.surfaceColorMap = exports.spaceStylesMap = exports.shadowMap = exports.positiveSpaceMap = exports.paddingStylesMap = exports.opacityMap = exports.negativeSpaceMap = exports.metricTextSizeStylesMap = exports.metricTextSizeMap = exports.layerMap = exports.isSurfaceColorToken = exports.inverseColorMap = exports.getSerializedStylesMap = exports.fontWeightStylesMap = exports.fontWeightMap = exports.fontStylesMap = exports.fontMap = exports.fontFamilyStylesMap = exports.fontFamilyMap = exports.fillMap = exports.dimensionMap = exports.borderWidthMap = exports.borderRadiusMap = exports.borderColorMap = exports.backgroundColorStylesMap = exports.backgroundColorMap = exports.allSpaceMap = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("@emotion/react");
10
10
  var _tokens = require("@atlaskit/tokens");
@@ -501,7 +501,7 @@ var borderRadiusMap = exports.borderRadiusMap = {
501
501
 
502
502
  /**
503
503
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
504
- * @codegen <<SignedSource::b2a06338babbfbea48ed2205e34084fc>>
504
+ * @codegen <<SignedSource::2c0cffbebdab4e28fe2b45925623e523>>
505
505
  * @codegenId typography
506
506
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
507
507
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -520,7 +520,10 @@ var fontMap = exports.fontMap = {
520
520
  'font.heading.xlarge': "var(--ds-font-heading-xlarge, normal 600 29px/32px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
521
521
  'font.heading.xsmall': "var(--ds-font-heading-xsmall, normal 600 14px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
522
522
  'font.heading.xxlarge': "var(--ds-font-heading-xxlarge, normal 500 35px/40px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
523
- 'font.heading.xxsmall': "var(--ds-font-heading-xxsmall, normal 600 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)"
523
+ 'font.heading.xxsmall': "var(--ds-font-heading-xxsmall, normal 600 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
524
+ 'font.metric.large': "var(--ds-font-metric-large, normal 653 28px/32px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
525
+ 'font.metric.medium': "var(--ds-font-metric-medium, normal 653 24px/28px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
526
+ 'font.metric.small': "var(--ds-font-metric-small, normal 653 16px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)"
524
527
  };
525
528
  var fontWeightMap = exports.fontWeightMap = {
526
529
  'font.weight.bold': "var(--ds-font-weight-bold, 700)",
@@ -541,7 +544,7 @@ var fontFamilyMap = exports.fontFamilyMap = {
541
544
 
542
545
  /**
543
546
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
544
- * @codegen <<SignedSource::159df661d29a2805a17ab6f52e842350>>
547
+ * @codegen <<SignedSource::c207cc4caf0794de5f13707a9c28451f>>
545
548
  * @codegenId text
546
549
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
547
550
  * @codegenDependency ../../../primitives/scripts/codegen-file-templates/dimensions.tsx <<SignedSource::cc9b3f12104c6ede803da6a42daac0b0>>
@@ -559,6 +562,11 @@ var textWeightMap = exports.textWeightMap = {
559
562
  regular: "var(--ds-font-weight-regular, 400)",
560
563
  semibold: "var(--ds-font-weight-semibold, 600)"
561
564
  };
565
+ var metricTextSizeMap = exports.metricTextSizeMap = {
566
+ large: "var(--ds-font-metric-large, normal 653 28px/32px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
567
+ medium: "var(--ds-font-metric-medium, normal 653 24px/28px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
568
+ small: "var(--ds-font-metric-small, normal 653 16px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)"
569
+ };
562
570
 
563
571
  /**
564
572
  * @codegenEnd
@@ -597,4 +605,5 @@ var textWeightStylesMap = exports.textWeightStylesMap = getSerializedStylesMap('
597
605
  var surfaceColorStylesMap = exports.surfaceColorStylesMap = getSerializedStylesMap(_tokens.CURRENT_SURFACE_CSS_VAR, surfaceColorMap);
598
606
  var isSurfaceColorToken = exports.isSurfaceColorToken = function isSurfaceColorToken(color) {
599
607
  return surfaceColorMap[color] !== undefined;
600
- };
608
+ };
609
+ var metricTextSizeStylesMap = exports.metricTextSizeStylesMap = getSerializedStylesMap('font', metricTextSizeMap);
@@ -0,0 +1,10 @@
1
+ ._11c81lu7{font:var(--ds-font-metric-medium,normal 653 24px/28px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
2
+ ._11c81r7r{font:var(--ds-font-metric-large,normal 653 28px/2pc ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
3
+ ._11c8h56o{font:var(--ds-font-metric-small,normal 653 1pc/20px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
4
+ ._18u0idpf{margin-left:0}
5
+ ._19pkidpf{margin-top:0}
6
+ ._2hwxidpf{margin-right:0}
7
+ ._otyridpf{margin-bottom:0}
8
+ ._y3gn1h6o{text-align:center}
9
+ ._y3gnh9n0{text-align:end}
10
+ ._y3gnv2br{text-align:start}
@@ -0,0 +1,46 @@
1
+ /* metric-text.tsx generated by @compiled/babel-plugin v0.36.1 */
2
+ import "./metric-text.compiled.css";
3
+ import * as React from 'react';
4
+ import { ax, ix } from "@compiled/react/runtime";
5
+ import { forwardRef } from 'react';
6
+ import invariant from 'tiny-invariant';
7
+ const asAllowlist = ['span', 'div'];
8
+ const styles = {
9
+ root: "_19pkidpf _2hwxidpf _otyridpf _18u0idpf",
10
+ 'textAlign.center': "_y3gn1h6o",
11
+ 'textAlign.end': "_y3gnh9n0",
12
+ 'textAlign.start': "_y3gnv2br"
13
+ };
14
+ const fontSizeMap = {
15
+ small: "_11c8h56o",
16
+ medium: "_11c81lu7",
17
+ large: "_11c81r7r"
18
+ };
19
+
20
+ /**
21
+ * __MetricText__
22
+ *
23
+ * MetricText is a primitive component that has the Atlassian Design System's design guidelines baked in.
24
+ * It is designed for use specifically with displaying metrics and is not to be used for headings or general UI text.
25
+ * It renders a `span` by default.
26
+ *
27
+ * @internal
28
+ */
29
+ const MetricText = /*#__PURE__*/forwardRef(({
30
+ as: Component = 'span',
31
+ align,
32
+ testId,
33
+ id,
34
+ size,
35
+ children
36
+ }, ref) => {
37
+ invariant(asAllowlist.includes(Component), `@atlaskit/primitives: MetricText received an invalid "as" value of "${Component}"`);
38
+ const component = /*#__PURE__*/React.createElement(Component, {
39
+ ref: ref,
40
+ "data-testid": testId,
41
+ id: id,
42
+ className: ax([styles.root, size && fontSizeMap[size], align && styles[`textAlign.${align}`]])
43
+ }, children);
44
+ return component;
45
+ });
46
+ export default MetricText;
@@ -5,6 +5,7 @@ export { default as Flex } from './components/flex';
5
5
  export { default as Grid } from './components/grid';
6
6
  export { default as Bleed } from './components/bleed';
7
7
  export { default as Text } from './components/text';
8
+ export { default as MetricText } from './components/metric-text';
8
9
  export { default as Pressable } from './components/pressable';
9
10
  export { default as Anchor } from './components/anchor';
10
11
  export { media, UNSAFE_useMediaQuery, Show, Hide } from './responsive';
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { forwardRef } from 'react';
6
+
7
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
+ import { css, jsx } from '@emotion/react';
9
+ import invariant from 'tiny-invariant';
10
+ import { metricTextSizeStylesMap } from '../xcss/style-maps.partial';
11
+ const asAllowlist = ['span', 'div'];
12
+ // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
13
+ // Long term we should remove those instances from the reset - it should be a reset to 0.
14
+ // For now, at least we know <MetricText> will be unaffected by this.
15
+ const resetStyles = css({
16
+ margin: 0
17
+ });
18
+ const textAlignMap = {
19
+ center: css({
20
+ textAlign: 'center'
21
+ }),
22
+ end: css({
23
+ textAlign: 'end'
24
+ }),
25
+ start: css({
26
+ textAlign: 'start'
27
+ })
28
+ };
29
+
30
+ /**
31
+ * __MetricText__
32
+ *
33
+ * MetricText is a primitive component that has the Atlassian Design System's design guidelines baked in.
34
+ * It is designed for use specifically with displaying metrics and is not to be used for headings or general UI text.
35
+ * It renders a `span` by default.
36
+ *
37
+ * @internal
38
+ */
39
+ const MetricText = /*#__PURE__*/forwardRef(({
40
+ as: Component = 'span',
41
+ align,
42
+ testId,
43
+ id,
44
+ size,
45
+ children
46
+ }, ref) => {
47
+ invariant(asAllowlist.includes(Component), `@atlaskit/primitives: MetricText received an invalid "as" value of "${Component}"`);
48
+ const component = jsx(Component, {
49
+ ref: ref,
50
+ css: [resetStyles,
51
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
52
+ size && metricTextSizeStylesMap[size], align && textAlignMap[align]],
53
+ "data-testid": testId,
54
+ id: id
55
+ }, children);
56
+ return component;
57
+ });
58
+ export default MetricText;
@@ -6,6 +6,7 @@ export { default as Flex } from './components/flex';
6
6
  export { default as Grid } from './components/grid';
7
7
  export { default as Bleed } from './components/bleed';
8
8
  export { default as Text } from './components/text';
9
+ export { default as MetricText } from './components/metric-text';
9
10
  export { default as Pressable } from './components/pressable';
10
11
  export { default as Anchor } from './components/anchor';
11
12
  export { media, UNSAFE_media, UNSAFE_BREAKPOINTS_CONFIG } from './responsive';