@atlaskit/heading 1.3.7 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/report.api.md CHANGED
@@ -15,43 +15,68 @@
15
15
  <!--SECTION START: Main Entry Types-->
16
16
 
17
17
  ```ts
18
- import { FC } from 'react';
18
+ import { jsx } from '@emotion/react';
19
19
  import { ReactNode } from 'react';
20
+ import { SerializedStyles } from '@emotion/react';
21
+
22
+ // @public (undocumented)
23
+ const _default: ({ level, variant, ...props }: HeadingProps) => jsx.JSX.Element;
24
+ export default _default;
20
25
 
21
26
  // @public
22
- const Heading: FC<HeadingProps>;
23
- export default Heading;
27
+ export const HeadingContextProvider: ({
28
+ children,
29
+ value,
30
+ }: HeadingLevelContextProps) => JSX.Element;
31
+
32
+ // @public (undocumented)
33
+ type HeadingElement = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
24
34
 
25
35
  // @public (undocumented)
26
- interface HeadingContextProps {
27
- // (undocumented)
36
+ interface HeadingLevelContextProps {
28
37
  children: ReactNode;
29
38
  value?: HeadingElement;
30
39
  }
31
40
 
32
- // @public
33
- export const HeadingContextProvider: FC<HeadingContextProps>;
34
-
35
- // @public (undocumented)
36
- type HeadingElement = 1 | 2 | 3 | 4 | 5 | 6;
37
-
38
41
  // @public (undocumented)
39
42
  export type HeadingProps = {
40
43
  testId?: string;
41
44
  children: ReactNode;
42
- level:
43
- | 'h100'
44
- | 'h200'
45
- | 'h300'
46
- | 'h400'
47
- | 'h500'
48
- | 'h600'
49
- | 'h700'
50
- | 'h800'
51
- | 'h900';
52
45
  id?: string;
53
46
  as?: 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';
54
47
  color?: 'default' | 'inverse';
48
+ } & (
49
+ | {
50
+ level?:
51
+ | 'h100'
52
+ | 'h200'
53
+ | 'h300'
54
+ | 'h400'
55
+ | 'h500'
56
+ | 'h600'
57
+ | 'h700'
58
+ | 'h800'
59
+ | 'h900';
60
+ variant?: never;
61
+ }
62
+ | {
63
+ level?: never;
64
+ variant?: HeadingVariant;
65
+ }
66
+ );
67
+
68
+ // @public (undocumented)
69
+ type HeadingVariant = keyof typeof headingVariantStylesMap;
70
+
71
+ // @public
72
+ const headingVariantStylesMap: {
73
+ large: SerializedStyles;
74
+ medium: SerializedStyles;
75
+ small: SerializedStyles;
76
+ xlarge: SerializedStyles;
77
+ xsmall: SerializedStyles;
78
+ xxlarge: SerializedStyles;
79
+ xxsmall: SerializedStyles;
55
80
  };
56
81
 
57
82
  // (No @packageDocumentation comment for this package)
@@ -0,0 +1,66 @@
1
+ import { writeFileSync } from 'fs';
2
+ import { join } from 'path';
3
+
4
+ import prettier from 'prettier';
5
+ import parserTypeScript from 'prettier/parser-typescript';
6
+
7
+ // eslint-disable-next-line import/order
8
+ import { createPartialSignedArtifact } from '@atlassian/codegen';
9
+
10
+ // eslint-disable-next-line import/order
11
+ import { typography as tokens } from '@atlaskit/tokens/tokens-raw';
12
+
13
+ const constructTokenFunctionCall = (tokenName: string, fallback: string) => {
14
+ return `token('${tokenName}', '${fallback}')`;
15
+ };
16
+
17
+ const headingTokens = tokens
18
+ .filter(t => t.attributes.group === 'typography')
19
+ .filter(t => t.cleanName.includes('heading'));
20
+
21
+ const removeVerbosity = (name: string): string => {
22
+ return name.replace('font.heading.', '');
23
+ };
24
+
25
+ export const createTypographyStylesFromTemplate = () => {
26
+ return (
27
+ prettier.format(
28
+ `
29
+ const headingVariantStylesMap = {
30
+ ${headingTokens
31
+ .sort((a, b) => (a.name < b.name ? -1 : 1))
32
+ .map(token => {
33
+ return `
34
+ '${removeVerbosity(
35
+ token.name,
36
+ )}': css({ font: ${constructTokenFunctionCall(
37
+ token.cleanName,
38
+ token.value,
39
+ )} })
40
+ `.trim();
41
+ })
42
+ .join(',\n\t')}
43
+ };`,
44
+ {
45
+ singleQuote: true,
46
+ trailingComma: 'all',
47
+ parser: 'typescript',
48
+ plugins: [parserTypeScript],
49
+ },
50
+ ) + `\nexport type HeadingVariant = keyof typeof headingVariantStylesMap;\n`
51
+ );
52
+ };
53
+
54
+ const targetPath = join(__dirname, '../', 'src', 'heading.partial.tsx');
55
+
56
+ writeFileSync(
57
+ join(__dirname, '../src/heading.partial.tsx'),
58
+ createPartialSignedArtifact(
59
+ createTypographyStylesFromTemplate(),
60
+ 'yarn workspace @atlaskit/heading codegen',
61
+ {
62
+ id: 'typography',
63
+ absoluteFilePath: targetPath,
64
+ },
65
+ ),
66
+ );
@@ -0,0 +1,58 @@
1
+ ## API Report File for "@atlaskit/heading"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { jsx } from '@emotion/react';
8
+ import { ReactNode } from 'react';
9
+ import { SerializedStyles } from '@emotion/react';
10
+
11
+ // @public (undocumented)
12
+ const _default: ({ level, variant, ...props }: HeadingProps) => jsx.JSX.Element;
13
+ export default _default;
14
+
15
+ // @public
16
+ export const HeadingContextProvider: ({ children, value, }: HeadingLevelContextProps) => JSX.Element;
17
+
18
+ // @public (undocumented)
19
+ type HeadingElement = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
20
+
21
+ // @public (undocumented)
22
+ interface HeadingLevelContextProps {
23
+ children: ReactNode;
24
+ value?: HeadingElement;
25
+ }
26
+
27
+ // @public (undocumented)
28
+ export type HeadingProps = {
29
+ testId?: string;
30
+ children: ReactNode;
31
+ id?: string;
32
+ as?: 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';
33
+ color?: 'default' | 'inverse';
34
+ } & ({
35
+ level?: 'h100' | 'h200' | 'h300' | 'h400' | 'h500' | 'h600' | 'h700' | 'h800' | 'h900';
36
+ variant?: never;
37
+ } | {
38
+ level?: never;
39
+ variant?: HeadingVariant;
40
+ });
41
+
42
+ // @public (undocumented)
43
+ type HeadingVariant = keyof typeof headingVariantStylesMap;
44
+
45
+ // @public
46
+ const headingVariantStylesMap: {
47
+ large: SerializedStyles;
48
+ medium: SerializedStyles;
49
+ small: SerializedStyles;
50
+ xlarge: SerializedStyles;
51
+ xsmall: SerializedStyles;
52
+ xxlarge: SerializedStyles;
53
+ xxsmall: SerializedStyles;
54
+ };
55
+
56
+ // (No @packageDocumentation comment for this package)
57
+
58
+ ```
package/dist/cjs/utils.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.lh = void 0;
7
- var lh = function lh(sizePx, lineHeightPx) {
8
- return lineHeightPx / sizePx;
9
- };
10
- exports.lh = lh;
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/heading",
3
- "version": "1.3.7",
4
- "sideEffects": false
5
- }
@@ -1 +0,0 @@
1
- export const lh = (sizePx, lineHeightPx) => lineHeightPx / sizePx;
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/heading",
3
- "version": "1.3.7",
4
- "sideEffects": false
5
- }
package/dist/esm/utils.js DELETED
@@ -1,3 +0,0 @@
1
- export var lh = function lh(sizePx, lineHeightPx) {
2
- return lineHeightPx / sizePx;
3
- };
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/heading",
3
- "version": "1.3.7",
4
- "sideEffects": false
5
- }
@@ -1 +0,0 @@
1
- export declare const lh: (sizePx: number, lineHeightPx: number) => number;
@@ -1 +0,0 @@
1
- export declare const lh: (sizePx: number, lineHeightPx: number) => number;