@atlaskit/heading 2.2.0 → 2.3.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.
@@ -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.default = void 0;
7
+ exports.headingColorStylesMap = exports.default = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _react = require("@emotion/react");
10
+ var _primitives = require("@atlaskit/primitives");
10
11
  var _headingContext = require("./heading-context");
11
12
  /** @jsx jsx */
12
13
 
@@ -20,14 +21,22 @@ var sizeTagMap = {
20
21
  xxsmall: 'h6'
21
22
  };
22
23
  var headingResetStyles = (0, _react.css)({
23
- color: "var(--ds-text, #172B4D)",
24
24
  letterSpacing: 'normal',
25
25
  marginBlock: 0,
26
26
  textTransform: 'none'
27
27
  });
28
- var inverseStyles = (0, _react.css)({
29
- color: "var(--ds-text-inverse, #FFF)"
30
- });
28
+ var useColor = function useColor(colorProp) {
29
+ var surface = (0, _primitives.UNSAFE_useSurface)();
30
+
31
+ /**
32
+ * Where the color of the surface is inverted we always override the color
33
+ * as there is no valid choice that is not covered by the override.
34
+ */
35
+ if (_primitives.UNSAFE_inverseColorMap.hasOwnProperty(surface)) {
36
+ return _primitives.UNSAFE_inverseColorMap[surface];
37
+ }
38
+ return colorProp || 'color.text';
39
+ };
31
40
 
32
41
  /**
33
42
  * __Heading__
@@ -46,8 +55,7 @@ var Heading = function Heading(_ref) {
46
55
  id = _ref.id,
47
56
  testId = _ref.testId,
48
57
  as = _ref.as,
49
- _ref$color = _ref.color,
50
- color = _ref$color === void 0 ? 'default' : _ref$color;
58
+ colorProp = _ref.color;
51
59
  if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
52
60
  throw new Error('`as` prop should be a string.');
53
61
  }
@@ -60,18 +68,32 @@ var Heading = function Heading(_ref) {
60
68
  inferredElement = _useHeading2[1];
61
69
  var Component = as || inferredElement;
62
70
  var needsAriaRole = Component === 'div' && hLevel;
71
+ var color = useColor(colorProp);
63
72
  return (0, _react.jsx)(Component, {
64
73
  id: id,
65
74
  "data-testid": testId,
66
75
  role: needsAriaRole ? 'heading' : undefined,
67
76
  "aria-level": needsAriaRole ? hLevel : undefined,
68
- css: [headingResetStyles, size && headingSizeStylesMap[size], color === 'inverse' && inverseStyles]
77
+ css: [headingResetStyles, size && headingSizeStylesMap[size], headingColorStylesMap[color]]
69
78
  }, children);
70
79
  };
71
80
 
81
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css
82
+ var headingColorStylesMap = exports.headingColorStylesMap = {
83
+ 'color.text': (0, _react.css)({
84
+ color: "var(--ds-text, #172B4D)"
85
+ }),
86
+ 'color.text.inverse': (0, _react.css)({
87
+ color: "var(--ds-text-inverse, #FFFFFF)"
88
+ }),
89
+ 'color.text.warning.inverse': (0, _react.css)({
90
+ color: "var(--ds-text-warning-inverse, #172B4D)"
91
+ })
92
+ };
93
+
72
94
  /**
73
95
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
74
- * @codegen <<SignedSource::057c0fe2015c2071afe3d694c5afcc0e>>
96
+ * @codegen <<SignedSource::d7d7bb136aa9b7935c15f8e85d0916d7>>
75
97
  * @codegenId typography
76
98
  * @codegenCommand yarn workspace @atlaskit/heading codegen
77
99
  */
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ /* eslint-disable @atlaskit/design-system/no-deprecated-design-token-usage */
2
3
  /** @jsx jsx */
3
4
  import { css, jsx } from '@emotion/react';
4
5
  import { useHeading } from './heading-context';
@@ -142,7 +143,6 @@ const OldHeading = ({
142
143
  */
143
144
  const Heading = ({
144
145
  level,
145
- size,
146
146
  ...props
147
147
  }) => {
148
148
  return level ?
@@ -151,8 +151,6 @@ const Heading = ({
151
151
  level: level
152
152
  }, props)) :
153
153
  // eslint-disable-next-line jsx-a11y/heading-has-content, @repo/internal/react/no-unsafe-spread-props
154
- jsx(NewHeading, _extends({
155
- size: size
156
- }, props));
154
+ jsx(NewHeading, props);
157
155
  };
158
156
  export default Heading;
@@ -1,5 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { css, jsx } from '@emotion/react';
3
+ import { UNSAFE_inverseColorMap, UNSAFE_useSurface } from '@atlaskit/primitives';
3
4
  import { useHeading } from './heading-context';
4
5
  const sizeTagMap = {
5
6
  xxlarge: 'h1',
@@ -11,14 +12,22 @@ const sizeTagMap = {
11
12
  xxsmall: 'h6'
12
13
  };
13
14
  const headingResetStyles = css({
14
- color: "var(--ds-text, #172B4D)",
15
15
  letterSpacing: 'normal',
16
16
  marginBlock: 0,
17
17
  textTransform: 'none'
18
18
  });
19
- const inverseStyles = css({
20
- color: "var(--ds-text-inverse, #FFF)"
21
- });
19
+ const useColor = colorProp => {
20
+ const surface = UNSAFE_useSurface();
21
+
22
+ /**
23
+ * Where the color of the surface is inverted we always override the color
24
+ * as there is no valid choice that is not covered by the override.
25
+ */
26
+ if (UNSAFE_inverseColorMap.hasOwnProperty(surface)) {
27
+ return UNSAFE_inverseColorMap[surface];
28
+ }
29
+ return colorProp || 'color.text';
30
+ };
22
31
 
23
32
  /**
24
33
  * __Heading__
@@ -37,7 +46,7 @@ const Heading = ({
37
46
  id,
38
47
  testId,
39
48
  as,
40
- color = 'default'
49
+ color: colorProp
41
50
  }) => {
42
51
  if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
43
52
  throw new Error('`as` prop should be a string.');
@@ -48,18 +57,32 @@ const Heading = ({
48
57
  const [hLevel, inferredElement] = useHeading(sizeTagMap[size]);
49
58
  const Component = as || inferredElement;
50
59
  const needsAriaRole = Component === 'div' && hLevel;
60
+ const color = useColor(colorProp);
51
61
  return jsx(Component, {
52
62
  id: id,
53
63
  "data-testid": testId,
54
64
  role: needsAriaRole ? 'heading' : undefined,
55
65
  "aria-level": needsAriaRole ? hLevel : undefined,
56
- css: [headingResetStyles, size && headingSizeStylesMap[size], color === 'inverse' && inverseStyles]
66
+ css: [headingResetStyles, size && headingSizeStylesMap[size], headingColorStylesMap[color]]
57
67
  }, children);
58
68
  };
59
69
 
70
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css
71
+ export const headingColorStylesMap = {
72
+ 'color.text': css({
73
+ color: "var(--ds-text, #172B4D)"
74
+ }),
75
+ 'color.text.inverse': css({
76
+ color: "var(--ds-text-inverse, #FFFFFF)"
77
+ }),
78
+ 'color.text.warning.inverse': css({
79
+ color: "var(--ds-text-warning-inverse, #172B4D)"
80
+ })
81
+ };
82
+
60
83
  /**
61
84
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
62
- * @codegen <<SignedSource::057c0fe2015c2071afe3d694c5afcc0e>>
85
+ * @codegen <<SignedSource::d7d7bb136aa9b7935c15f8e85d0916d7>>
63
86
  * @codegenId typography
64
87
  * @codegenCommand yarn workspace @atlaskit/heading codegen
65
88
  */
@@ -1,7 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- var _excluded = ["level", "size"];
4
+ var _excluded = ["level"];
5
+ /* eslint-disable @atlaskit/design-system/no-deprecated-design-token-usage */
5
6
  /** @jsx jsx */
6
7
  import { css, jsx } from '@emotion/react';
7
8
  import { useHeading } from './heading-context';
@@ -148,7 +149,6 @@ var OldHeading = function OldHeading(_ref) {
148
149
  */
149
150
  var Heading = function Heading(_ref2) {
150
151
  var level = _ref2.level,
151
- size = _ref2.size,
152
152
  props = _objectWithoutProperties(_ref2, _excluded);
153
153
  return level ?
154
154
  // eslint-disable-next-line jsx-a11y/heading-has-content, @repo/internal/react/no-unsafe-spread-props
@@ -156,8 +156,6 @@ var Heading = function Heading(_ref2) {
156
156
  level: level
157
157
  }, props)) :
158
158
  // eslint-disable-next-line jsx-a11y/heading-has-content, @repo/internal/react/no-unsafe-spread-props
159
- jsx(NewHeading, _extends({
160
- size: size
161
- }, props));
159
+ jsx(NewHeading, props);
162
160
  };
163
161
  export default Heading;
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/react';
4
+ import { UNSAFE_inverseColorMap, UNSAFE_useSurface } from '@atlaskit/primitives';
4
5
  import { useHeading } from './heading-context';
5
6
  var sizeTagMap = {
6
7
  xxlarge: 'h1',
@@ -12,14 +13,22 @@ var sizeTagMap = {
12
13
  xxsmall: 'h6'
13
14
  };
14
15
  var headingResetStyles = css({
15
- color: "var(--ds-text, #172B4D)",
16
16
  letterSpacing: 'normal',
17
17
  marginBlock: 0,
18
18
  textTransform: 'none'
19
19
  });
20
- var inverseStyles = css({
21
- color: "var(--ds-text-inverse, #FFF)"
22
- });
20
+ var useColor = function useColor(colorProp) {
21
+ var surface = UNSAFE_useSurface();
22
+
23
+ /**
24
+ * Where the color of the surface is inverted we always override the color
25
+ * as there is no valid choice that is not covered by the override.
26
+ */
27
+ if (UNSAFE_inverseColorMap.hasOwnProperty(surface)) {
28
+ return UNSAFE_inverseColorMap[surface];
29
+ }
30
+ return colorProp || 'color.text';
31
+ };
23
32
 
24
33
  /**
25
34
  * __Heading__
@@ -38,8 +47,7 @@ var Heading = function Heading(_ref) {
38
47
  id = _ref.id,
39
48
  testId = _ref.testId,
40
49
  as = _ref.as,
41
- _ref$color = _ref.color,
42
- color = _ref$color === void 0 ? 'default' : _ref$color;
50
+ colorProp = _ref.color;
43
51
  if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
44
52
  throw new Error('`as` prop should be a string.');
45
53
  }
@@ -52,18 +60,32 @@ var Heading = function Heading(_ref) {
52
60
  inferredElement = _useHeading2[1];
53
61
  var Component = as || inferredElement;
54
62
  var needsAriaRole = Component === 'div' && hLevel;
63
+ var color = useColor(colorProp);
55
64
  return jsx(Component, {
56
65
  id: id,
57
66
  "data-testid": testId,
58
67
  role: needsAriaRole ? 'heading' : undefined,
59
68
  "aria-level": needsAriaRole ? hLevel : undefined,
60
- css: [headingResetStyles, size && headingSizeStylesMap[size], color === 'inverse' && inverseStyles]
69
+ css: [headingResetStyles, size && headingSizeStylesMap[size], headingColorStylesMap[color]]
61
70
  }, children);
62
71
  };
63
72
 
73
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css
74
+ export var headingColorStylesMap = {
75
+ 'color.text': css({
76
+ color: "var(--ds-text, #172B4D)"
77
+ }),
78
+ 'color.text.inverse': css({
79
+ color: "var(--ds-text-inverse, #FFFFFF)"
80
+ }),
81
+ 'color.text.warning.inverse': css({
82
+ color: "var(--ds-text-warning-inverse, #172B4D)"
83
+ })
84
+ };
85
+
64
86
  /**
65
87
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
66
- * @codegen <<SignedSource::057c0fe2015c2071afe3d694c5afcc0e>>
88
+ * @codegen <<SignedSource::d7d7bb136aa9b7935c15f8e85d0916d7>>
67
89
  * @codegenId typography
68
90
  * @codegenCommand yarn workspace @atlaskit/heading codegen
69
91
  */
@@ -20,5 +20,5 @@ import type { HeadingProps } from './types';
20
20
  * );
21
21
  * ```
22
22
  */
23
- declare const Heading: ({ level, size, ...props }: HeadingProps) => jsx.JSX.Element;
23
+ declare const Heading: ({ level, ...props }: HeadingProps) => jsx.JSX.Element;
24
24
  export default Heading;
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import type { HeadingProps } from './types';
2
+ import { jsx, type SerializedStyles } from '@emotion/react';
3
+ import type { HeadingColor, NewHeadingProps } from './types';
4
4
  /**
5
5
  * __Heading__
6
6
  *
@@ -12,21 +12,22 @@ import type { HeadingProps } from './types';
12
12
  * <Heading size="xxlarge">Page title</Heading>
13
13
  * ```
14
14
  */
15
- declare const Heading: ({ children, size, id, testId, as, color, }: HeadingProps) => jsx.JSX.Element;
15
+ declare const Heading: ({ children, size, id, testId, as, color: colorProp, }: NewHeadingProps) => jsx.JSX.Element;
16
+ export declare const headingColorStylesMap: Record<HeadingColor, SerializedStyles>;
16
17
  /**
17
18
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
18
- * @codegen <<SignedSource::057c0fe2015c2071afe3d694c5afcc0e>>
19
+ * @codegen <<SignedSource::d7d7bb136aa9b7935c15f8e85d0916d7>>
19
20
  * @codegenId typography
20
21
  * @codegenCommand yarn workspace @atlaskit/heading codegen
21
22
  */
22
23
  declare const headingSizeStylesMap: {
23
- xxlarge: import("@emotion/react").SerializedStyles;
24
- xlarge: import("@emotion/react").SerializedStyles;
25
- large: import("@emotion/react").SerializedStyles;
26
- medium: import("@emotion/react").SerializedStyles;
27
- small: import("@emotion/react").SerializedStyles;
28
- xsmall: import("@emotion/react").SerializedStyles;
29
- xxsmall: import("@emotion/react").SerializedStyles;
24
+ xxlarge: SerializedStyles;
25
+ xlarge: SerializedStyles;
26
+ large: SerializedStyles;
27
+ medium: SerializedStyles;
28
+ small: SerializedStyles;
29
+ xsmall: SerializedStyles;
30
+ xxsmall: SerializedStyles;
30
31
  };
31
32
  export type HeadingSize = keyof typeof headingSizeStylesMap;
32
33
  /**
@@ -1,6 +1,6 @@
1
- import { ReactNode } from 'react';
2
- import { HeadingSize } from './heading.partial';
3
- export type HeadingProps = {
1
+ import { type ReactNode } from 'react';
2
+ import { type HeadingSize } from './heading.partial';
3
+ type HeadingPropsBase = {
4
4
  /**
5
5
  * A `testId` prop is provided for specified elements, which is a unique
6
6
  * string that appears as a data attribute `data-testid` in the rendered code,
@@ -19,12 +19,13 @@ export type HeadingProps = {
19
19
  * Allows the component to be rendered as the specified DOM element, overriding a default element set by `level` prop.
20
20
  */
21
21
  as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div' | 'span';
22
+ };
23
+ export type OldHeadingProps = HeadingPropsBase & {
22
24
  /**
23
25
  * Text color of the heading. Use `"inverse"` option for a light text color over a dark background.
24
26
  * Defaults to `"default"`.
25
27
  */
26
28
  color?: 'inverse' | 'default';
27
- } & ({
28
29
  /**
29
30
  * @private
30
31
  * @deprecated Use `size` prop instead.
@@ -52,8 +53,15 @@ export type HeadingProps = {
52
53
  * Heading size. Use instead of the deprecated `level` prop.
53
54
  */
54
55
  size?: never;
55
- } | {
56
- level?: never;
56
+ };
57
+ export type HeadingColor = 'color.text' | 'color.text.inverse' | 'color.text.warning.inverse';
58
+ export type NewHeadingProps = HeadingPropsBase & {
59
+ /**
60
+ * Token representing text color with a built-in fallback value.
61
+ * Will apply inverse text color automatically if placed within a Box with bold background color.
62
+ * Defaults to `color.text`.
63
+ */
64
+ color?: HeadingColor;
57
65
  /**
58
66
  * Heading size. This value is detached from the specific heading level applied to allow for more flexibility.
59
67
  * Use instead of the deprecated `level` prop.
@@ -61,4 +69,7 @@ export type HeadingProps = {
61
69
  * This prop will only work if the typography tokens theme is applied on the page.
62
70
  */
63
71
  size: HeadingSize;
64
- });
72
+ level?: never;
73
+ };
74
+ export type HeadingProps = OldHeadingProps | NewHeadingProps;
75
+ export {};
@@ -20,5 +20,5 @@ import type { HeadingProps } from './types';
20
20
  * );
21
21
  * ```
22
22
  */
23
- declare const Heading: ({ level, size, ...props }: HeadingProps) => jsx.JSX.Element;
23
+ declare const Heading: ({ level, ...props }: HeadingProps) => jsx.JSX.Element;
24
24
  export default Heading;
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import type { HeadingProps } from './types';
2
+ import { jsx, type SerializedStyles } from '@emotion/react';
3
+ import type { HeadingColor, NewHeadingProps } from './types';
4
4
  /**
5
5
  * __Heading__
6
6
  *
@@ -12,21 +12,22 @@ import type { HeadingProps } from './types';
12
12
  * <Heading size="xxlarge">Page title</Heading>
13
13
  * ```
14
14
  */
15
- declare const Heading: ({ children, size, id, testId, as, color, }: HeadingProps) => jsx.JSX.Element;
15
+ declare const Heading: ({ children, size, id, testId, as, color: colorProp, }: NewHeadingProps) => jsx.JSX.Element;
16
+ export declare const headingColorStylesMap: Record<HeadingColor, SerializedStyles>;
16
17
  /**
17
18
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
18
- * @codegen <<SignedSource::057c0fe2015c2071afe3d694c5afcc0e>>
19
+ * @codegen <<SignedSource::d7d7bb136aa9b7935c15f8e85d0916d7>>
19
20
  * @codegenId typography
20
21
  * @codegenCommand yarn workspace @atlaskit/heading codegen
21
22
  */
22
23
  declare const headingSizeStylesMap: {
23
- xxlarge: import("@emotion/react").SerializedStyles;
24
- xlarge: import("@emotion/react").SerializedStyles;
25
- large: import("@emotion/react").SerializedStyles;
26
- medium: import("@emotion/react").SerializedStyles;
27
- small: import("@emotion/react").SerializedStyles;
28
- xsmall: import("@emotion/react").SerializedStyles;
29
- xxsmall: import("@emotion/react").SerializedStyles;
24
+ xxlarge: SerializedStyles;
25
+ xlarge: SerializedStyles;
26
+ large: SerializedStyles;
27
+ medium: SerializedStyles;
28
+ small: SerializedStyles;
29
+ xsmall: SerializedStyles;
30
+ xxsmall: SerializedStyles;
30
31
  };
31
32
  export type HeadingSize = keyof typeof headingSizeStylesMap;
32
33
  /**
@@ -1,6 +1,6 @@
1
- import { ReactNode } from 'react';
2
- import { HeadingSize } from './heading.partial';
3
- export type HeadingProps = {
1
+ import { type ReactNode } from 'react';
2
+ import { type HeadingSize } from './heading.partial';
3
+ type HeadingPropsBase = {
4
4
  /**
5
5
  * A `testId` prop is provided for specified elements, which is a unique
6
6
  * string that appears as a data attribute `data-testid` in the rendered code,
@@ -19,12 +19,13 @@ export type HeadingProps = {
19
19
  * Allows the component to be rendered as the specified DOM element, overriding a default element set by `level` prop.
20
20
  */
21
21
  as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div' | 'span';
22
+ };
23
+ export type OldHeadingProps = HeadingPropsBase & {
22
24
  /**
23
25
  * Text color of the heading. Use `"inverse"` option for a light text color over a dark background.
24
26
  * Defaults to `"default"`.
25
27
  */
26
28
  color?: 'inverse' | 'default';
27
- } & ({
28
29
  /**
29
30
  * @private
30
31
  * @deprecated Use `size` prop instead.
@@ -52,8 +53,15 @@ export type HeadingProps = {
52
53
  * Heading size. Use instead of the deprecated `level` prop.
53
54
  */
54
55
  size?: never;
55
- } | {
56
- level?: never;
56
+ };
57
+ export type HeadingColor = 'color.text' | 'color.text.inverse' | 'color.text.warning.inverse';
58
+ export type NewHeadingProps = HeadingPropsBase & {
59
+ /**
60
+ * Token representing text color with a built-in fallback value.
61
+ * Will apply inverse text color automatically if placed within a Box with bold background color.
62
+ * Defaults to `color.text`.
63
+ */
64
+ color?: HeadingColor;
57
65
  /**
58
66
  * Heading size. This value is detached from the specific heading level applied to allow for more flexibility.
59
67
  * Use instead of the deprecated `level` prop.
@@ -61,4 +69,7 @@ export type HeadingProps = {
61
69
  * This prop will only work if the typography tokens theme is applied on the page.
62
70
  */
63
71
  size: HeadingSize;
64
- });
72
+ level?: never;
73
+ };
74
+ export type HeadingProps = OldHeadingProps | NewHeadingProps;
75
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/heading",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "A heading is a typography component used to display text in different sizes and formats.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,7 +33,8 @@
33
33
  "codegen": "ts-node ./scripts/codegen.tsx"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/tokens": "^1.43.0",
36
+ "@atlaskit/primitives": "^6.0.0",
37
+ "@atlaskit/tokens": "^1.45.0",
37
38
  "@babel/runtime": "^7.0.0",
38
39
  "@emotion/react": "^11.7.1"
39
40
  },
@@ -42,14 +43,15 @@
42
43
  },
43
44
  "devDependencies": {
44
45
  "@af/accessibility-testing": "*",
46
+ "@af/formatting": "*",
45
47
  "@atlaskit/ds-lib": "^2.3.0",
46
48
  "@atlaskit/ssr": "*",
49
+ "@atlaskit/toggle": "^13.1.0",
47
50
  "@atlaskit/visual-regression": "*",
48
51
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
49
52
  "@atlassian/codegen": "^0.1.0",
50
53
  "@testing-library/react": "^12.1.5",
51
54
  "jscodeshift": "^0.13.0",
52
- "prettier": "^2.8.0",
53
55
  "react-dom": "^16.8.0",
54
56
  "ts-node": "^10.9.1",
55
57
  "typescript": "~5.4.2"
@@ -1,17 +1,15 @@
1
1
  import { writeFileSync } from 'fs';
2
2
  import { join } from 'path';
3
3
 
4
- import prettier from 'prettier';
5
- import parserTypeScript from 'prettier/parser-typescript';
6
-
4
+ import format from '@af/formatting/sync';
7
5
  // eslint-disable-next-line import/order
8
6
  import { createPartialSignedArtifact } from '@atlassian/codegen';
9
7
 
10
8
  // eslint-disable-next-line import/order
11
9
  import { typographyAdg3 as tokens } from '@atlaskit/tokens/tokens-raw';
12
10
 
13
- const constructTokenFunctionCall = (tokenName: string, fallback: string) => {
14
- return `token('${tokenName}', '${fallback}')`;
11
+ const constructTokenFunctionCall = (tokenName: string) => {
12
+ return `token('${tokenName}')`;
15
13
  };
16
14
 
17
15
  const headingTokens = tokens
@@ -24,7 +22,7 @@ const removeVerbosity = (name: string): string => {
24
22
 
25
23
  export const createTypographyStylesFromTemplate = () => {
26
24
  return (
27
- prettier.format(
25
+ format(
28
26
  `
29
27
  const headingSizeStylesMap = {
30
28
  ${headingTokens
@@ -32,20 +30,12 @@ const headingSizeStylesMap = {
32
30
  return `
33
31
  '${removeVerbosity(
34
32
  token.name,
35
- )}': css({ font: ${constructTokenFunctionCall(
36
- token.cleanName,
37
- token.value,
38
- )} })
33
+ )}': css({ font: ${constructTokenFunctionCall(token.cleanName)} })
39
34
  `.trim();
40
35
  })
41
36
  .join(',\n\t')}
42
37
  };`,
43
- {
44
- singleQuote: true,
45
- trailingComma: 'all',
46
- parser: 'typescript',
47
- plugins: [parserTypeScript],
48
- },
38
+ 'typescript',
49
39
  ) + `\nexport type HeadingSize = keyof typeof headingSizeStylesMap;\n`
50
40
  );
51
41
  };
@@ -1,80 +0,0 @@
1
- jest.autoMockOff();
2
-
3
- import transformer from '../1.6.0-level-to-size';
4
-
5
- import { check } from './_framework';
6
-
7
- check({
8
- transformer,
9
- it: 'should replace level with size only on Heading component',
10
- original: `
11
- import Heading from '@atlaskit/heading';
12
-
13
- function App() {
14
- return <>
15
- <Heading level="h700" as="h3">hello</Heading>
16
- <SomethingElse level="h700">still here</SomethingElse>
17
- </>;
18
- }
19
- `,
20
- expected: `
21
- import Heading from '@atlaskit/heading';
22
-
23
- function App() {
24
- return <>
25
- <Heading size="large" as="h3">hello</Heading>
26
- <SomethingElse level="h700">still here</SomethingElse>
27
- </>;
28
- }
29
- `,
30
- });
31
-
32
- check({
33
- transformer,
34
- it: 'should do nothing if level is h200 or h100',
35
- original: `
36
- import Heading from '@atlaskit/heading';
37
-
38
- function App() {
39
- return <>
40
- <Heading level="h300">hello</Heading>
41
- <Heading level="h200">hello</Heading>
42
- <Heading level="h100">hello</Heading>
43
- </>;
44
- }
45
- `,
46
- expected: `
47
- import Heading from '@atlaskit/heading';
48
-
49
- function App() {
50
- return <>
51
- <Heading size="xxsmall">hello</Heading>
52
- <Heading level="h200">hello</Heading>
53
- <Heading level="h100">hello</Heading>
54
- </>;
55
- }
56
- `,
57
- });
58
-
59
- check({
60
- transformer,
61
- it: 'should do nothing if size already exists',
62
- original: `
63
- import Heading from '@atlaskit/heading';
64
-
65
- function App() {
66
- return <>
67
- <Heading size="large">hello</Heading>
68
- </>;
69
- }
70
- `,
71
- expected: `
72
- import Heading from '@atlaskit/heading';
73
-
74
- function App() {
75
- return <>
76
- <Heading size="large">hello</Heading>
77
- </>;
78
- }
79
- `,
80
- });