@atlaskit/primitives 0.6.0 → 0.7.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 (62) hide show
  1. package/.eslintrc.js +3 -0
  2. package/CHANGELOG.md +8 -0
  3. package/dist/cjs/components/box.js +3 -40
  4. package/dist/cjs/components/inline.partial.js +1 -0
  5. package/dist/cjs/components/internal/base-box.js +61 -0
  6. package/dist/cjs/components/stack.partial.js +1 -0
  7. package/dist/cjs/internal/style-maps.partial.js +370 -0
  8. package/dist/cjs/internal/xcss.js +17 -7
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/components/box.js +1 -37
  11. package/dist/es2019/components/inline.partial.js +1 -0
  12. package/dist/es2019/components/internal/base-box.js +52 -0
  13. package/dist/es2019/components/stack.partial.js +1 -0
  14. package/dist/es2019/internal/style-maps.partial.js +341 -0
  15. package/dist/es2019/internal/xcss.js +13 -7
  16. package/dist/es2019/version.json +1 -1
  17. package/dist/esm/components/box.js +2 -40
  18. package/dist/esm/components/inline.partial.js +1 -0
  19. package/dist/esm/components/internal/base-box.js +53 -0
  20. package/dist/esm/components/stack.partial.js +1 -0
  21. package/dist/esm/internal/style-maps.partial.js +340 -0
  22. package/dist/esm/internal/xcss.js +17 -7
  23. package/dist/esm/version.json +1 -1
  24. package/dist/types/components/box.d.ts +1 -1
  25. package/dist/types/components/internal/base-box.d.ts +83 -0
  26. package/dist/types/components/types.d.ts +1 -1
  27. package/dist/types/internal/style-maps.partial.d.ts +396 -0
  28. package/dist/types/internal/xcss.d.ts +5 -5
  29. package/package.json +2 -1
  30. package/report.api.md +206 -327
  31. package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +313 -363
  32. package/scripts/border-codegen-template.tsx +79 -0
  33. package/scripts/codegen-file-templates/align-self.tsx +9 -0
  34. package/scripts/codegen-file-templates/border-style.tsx +6 -0
  35. package/scripts/codegen-file-templates/dimensions.tsx +17 -0
  36. package/scripts/codegen-file-templates/display.tsx +6 -0
  37. package/scripts/codegen-file-templates/flex-grow.tsx +6 -0
  38. package/scripts/codegen-file-templates/flex-shrink.tsx +6 -0
  39. package/scripts/codegen-file-templates/flex.tsx +5 -0
  40. package/scripts/codegen-file-templates/layer.tsx +13 -0
  41. package/scripts/codegen-file-templates/overflow.tsx +20 -0
  42. package/scripts/codegen-file-templates/position.tsx +8 -0
  43. package/scripts/codegen-styles.tsx +80 -120
  44. package/scripts/color-codegen-template.tsx +9 -19
  45. package/scripts/misc-codegen-template.tsx +20 -40
  46. package/scripts/spacing-codegen-template.tsx +5 -12
  47. package/scripts/utils.tsx +15 -4
  48. package/tmp/api-report-tmp.d.ts +201 -326
  49. package/dist/cjs/components/internal/base-box.partial.js +0 -825
  50. package/dist/cjs/internal/color-map.js +0 -42
  51. package/dist/cjs/internal/style-maps.js +0 -130
  52. package/dist/es2019/components/internal/base-box.partial.js +0 -842
  53. package/dist/es2019/internal/color-map.js +0 -35
  54. package/dist/es2019/internal/style-maps.js +0 -117
  55. package/dist/esm/components/internal/base-box.partial.js +0 -820
  56. package/dist/esm/internal/color-map.js +0 -35
  57. package/dist/esm/internal/style-maps.js +0 -117
  58. package/dist/types/components/internal/base-box.partial.d.ts +0 -521
  59. package/dist/types/internal/color-map.d.ts +0 -36
  60. package/dist/types/internal/style-maps.d.ts +0 -151
  61. package/scripts/color-map-template.tsx +0 -52
  62. package/scripts/dimension-codegen-template.tsx +0 -75
@@ -0,0 +1,79 @@
1
+ import prettier from 'prettier';
2
+ import parserTypeScript from 'prettier/parser-typescript';
3
+
4
+ // eslint-disable-next-line @atlassian/tangerine/import/entry-points
5
+ import tokens from '@atlaskit/tokens/src/artifacts/tokens-raw/atlassian-shape';
6
+
7
+ import { capitalize, constructTokenFunctionCall } from './utils';
8
+
9
+ type Token = {
10
+ token: string;
11
+ fallback: string;
12
+ isDeprecated: boolean;
13
+ };
14
+
15
+ const tokenStyles = {
16
+ width: {
17
+ objectName: 'borderWidth',
18
+ filterPrefix: 'border.width.',
19
+ renamePrefix: 'border.',
20
+ cssProperty: 'borderWidth',
21
+ filterFn: <T extends Token>(t: T) =>
22
+ t.token.startsWith(tokenStyles.width.filterPrefix),
23
+ },
24
+ radius: {
25
+ objectName: 'borderRadius',
26
+ filterPrefix: 'border.radius.',
27
+ renamePrefix: 'border.',
28
+ cssProperty: 'borderRadius',
29
+ filterFn: <T extends Token>(t: T) =>
30
+ t.token.startsWith(tokenStyles.radius.filterPrefix),
31
+ },
32
+ } as const;
33
+
34
+ const activeTokens = tokens
35
+ .filter(t => t.attributes.state !== 'deleted')
36
+ .map(
37
+ (t): Token => ({
38
+ token: t.name,
39
+ fallback: t.value as string,
40
+ isDeprecated: t.attributes.state === 'deprecated',
41
+ }),
42
+ );
43
+
44
+ export const createBorderStylesFromTemplate = (
45
+ property: keyof typeof tokenStyles,
46
+ ) => {
47
+ if (!tokenStyles[property]) {
48
+ throw new Error(`[codegen] Unknown option found "${property}"`);
49
+ }
50
+
51
+ const { filterFn, renamePrefix, objectName } = tokenStyles[property];
52
+
53
+ return (
54
+ prettier.format(
55
+ `
56
+ export const ${objectName}Map = {
57
+ ${activeTokens
58
+ .filter(filterFn)
59
+ .map(t => {
60
+ const propName = t.token.replace(renamePrefix, '');
61
+ return `
62
+ ${t.isDeprecated ? '// @deprecated' : ''}
63
+ '${propName}': ${constructTokenFunctionCall(
64
+ t.token,
65
+ t.fallback,
66
+ )}`.trim();
67
+ })
68
+ .join(',\n\t')}
69
+ } as const;`,
70
+ {
71
+ singleQuote: true,
72
+ parser: 'typescript',
73
+ trailingComma: 'all',
74
+ plugins: [parserTypeScript],
75
+ },
76
+ ) +
77
+ `\nexport type ${capitalize(objectName)} = keyof typeof ${objectName}Map;\n`
78
+ );
79
+ };
@@ -0,0 +1,9 @@
1
+ export const alignSelfMap = {
2
+ center: 'center',
3
+ start: 'start',
4
+ stretch: 'stretch',
5
+ end: 'end',
6
+ baseline: 'baseline',
7
+ } as const;
8
+
9
+ export type AlignSelf = keyof typeof alignSelfMap;
@@ -0,0 +1,6 @@
1
+ export const borderStyleMap = {
2
+ none: 'none',
3
+ solid: 'solid',
4
+ } as const;
5
+
6
+ export type BorderStyle = keyof typeof borderStyleMap;
@@ -0,0 +1,17 @@
1
+ export const dimensionMap = {
2
+ '100%': '100%',
3
+ 'size.100': '16px',
4
+ 'size.200': '24px',
5
+ 'size.300': '32px',
6
+ 'size.400': '40px',
7
+ 'size.500': '48px',
8
+ 'size.600': '96px',
9
+ 'size.1000': '192px',
10
+ } as const;
11
+
12
+ export type Width = keyof typeof dimensionMap;
13
+ export type Height = keyof typeof dimensionMap;
14
+ export type MinWidth = keyof typeof dimensionMap;
15
+ export type MaxWidth = keyof typeof dimensionMap;
16
+ export type MinHeight = keyof typeof dimensionMap;
17
+ export type MaxHeight = keyof typeof dimensionMap;
@@ -0,0 +1,6 @@
1
+ export type Display =
2
+ | 'flex'
3
+ | 'block'
4
+ | 'inline'
5
+ | 'inline-block'
6
+ | 'inline-flex';
@@ -0,0 +1,6 @@
1
+ export const flexGrowMap = {
2
+ '0': 0,
3
+ '1': 1,
4
+ } as const;
5
+
6
+ export type FlexGrow = keyof typeof flexGrowMap;
@@ -0,0 +1,6 @@
1
+ export const flexShrinkMap = {
2
+ '0': 0,
3
+ '1': 1,
4
+ } as const;
5
+
6
+ export type FlexShrink = keyof typeof flexShrinkMap;
@@ -0,0 +1,5 @@
1
+ export const flexMap = {
2
+ '1': 1,
3
+ } as const;
4
+
5
+ export type Flex = keyof typeof flexMap;
@@ -0,0 +1,13 @@
1
+ export const layerMap = {
2
+ card: 100,
3
+ navigation: 200,
4
+ dialog: 300,
5
+ layer: 400,
6
+ blanket: 500,
7
+ modal: 510,
8
+ flag: 600,
9
+ spotlight: 700,
10
+ tooltip: 800,
11
+ } as const;
12
+
13
+ export type Layer = keyof typeof layerMap;
@@ -0,0 +1,20 @@
1
+ export const overflowMap = {
2
+ auto: 'auto',
3
+ hidden: 'hidden',
4
+ } as const;
5
+
6
+ export type Overflow = keyof typeof overflowMap;
7
+
8
+ export const overflowInlineMap = {
9
+ auto: 'auto',
10
+ hidden: 'hidden',
11
+ } as const;
12
+
13
+ export type OverflowInline = keyof typeof overflowInlineMap;
14
+
15
+ export const overflowBlockMap = {
16
+ auto: 'auto',
17
+ hidden: 'hidden',
18
+ } as const;
19
+
20
+ export type OverflowBlock = keyof typeof overflowBlockMap;
@@ -0,0 +1,8 @@
1
+ export const positionMap = {
2
+ absolute: 'absolute',
3
+ fixed: 'fixed',
4
+ relative: 'relative',
5
+ static: 'static',
6
+ } as const;
7
+
8
+ export type Position = keyof typeof positionMap;
@@ -1,139 +1,99 @@
1
1
  /* eslint-disable no-console */
2
- import { writeFile } from 'fs/promises';
2
+ import { readdirSync, writeFileSync } from 'fs';
3
3
  import { join } from 'path';
4
4
 
5
- import { createPartialSignedArtifact, createSignedArtifact } from '@af/codegen';
5
+ import { createPartialSignedArtifact } from '@af/codegen';
6
6
 
7
+ import { createBorderStylesFromTemplate } from './border-codegen-template';
7
8
  import { createColorStylesFromTemplate } from './color-codegen-template';
8
- import { createColorMapTemplate } from './color-map-template';
9
- import { createDimensionStylesFromTemplate } from './dimension-codegen-template';
10
- import { createStylesFromTemplate } from './misc-codegen-template';
9
+ import { createStylesFromFileTemplate } from './misc-codegen-template';
11
10
  import { createSpacingStylesFromTemplate } from './spacing-codegen-template';
12
11
 
13
- const colorMapOutputFolder = join(__dirname, '../', 'src', 'internal');
14
12
  const colorTokensDependencyPath = require.resolve(
15
13
  '../../tokens/src/artifacts/tokens-raw/atlassian-light',
16
14
  );
17
15
  const spacingTokensDependencyPath = require.resolve(
18
16
  '../../tokens/src/artifacts/tokens-raw/atlassian-spacing',
19
17
  );
18
+ const shapeTokensDependencyPath = require.resolve(
19
+ '../../tokens/src/artifacts/tokens-raw/atlassian-shape',
20
+ );
21
+ const templateFiles = readdirSync(join(__dirname, 'codegen-file-templates'), {
22
+ withFileTypes: true,
23
+ })
24
+ .filter(item => !item.isDirectory())
25
+ .map(item => join(__dirname, 'codegen-file-templates', item.name));
20
26
 
21
- const primitivesFileNames = {
22
- 'internal-box': 'base-box.partial.tsx',
23
- box: 'box.tsx',
24
- inline: 'inline.partial.tsx',
25
- stack: 'stack.partial.tsx',
26
- };
27
-
28
- writeFile(
29
- join(colorMapOutputFolder, 'color-map.tsx'),
30
- createSignedArtifact(createColorMapTemplate(), 'yarn codegen-styles', {
31
- description:
32
- 'The color map is used to map a background color token to a matching text color that will meet contrast.',
33
- dependencies: [colorTokensDependencyPath],
34
- outputFolder: colorMapOutputFolder,
35
- }),
36
- ).then(() => console.log(join(colorMapOutputFolder, 'color-map.tsx')));
37
-
38
- // generate colors
39
- Promise.all(
40
- [{ target: primitivesFileNames['internal-box'] }].map(({ target }) => {
41
- const targetPath = join(
42
- __dirname,
43
- '../',
44
- 'src',
45
- 'components',
46
- 'internal',
47
- target,
48
- );
49
-
50
- const source = createPartialSignedArtifact(
51
- options => options.map(createColorStylesFromTemplate).join('\n'),
52
- 'yarn codegen-styles',
53
- {
54
- id: 'colors',
55
- absoluteFilePath: targetPath,
56
- dependencies: [colorTokensDependencyPath],
57
- },
58
- );
59
-
60
- return writeFile(targetPath, source).then(() =>
61
- console.log(`${targetPath} written!`),
62
- );
63
- }),
64
- )
65
- .then(() => {
66
- // generate spacing values
67
- return Promise.all(
68
- [
69
- { path: ['internal', primitivesFileNames['internal-box']] },
70
- { path: [primitivesFileNames.inline] },
71
- { path: [primitivesFileNames.stack] },
72
- ].map(({ path }) => {
73
- const targetPath = join(__dirname, '../', 'src', 'components', ...path);
74
-
75
- const source = createPartialSignedArtifact(
76
- options => options.map(createSpacingStylesFromTemplate).join('\n'),
77
- 'yarn codegen-styles',
78
- {
79
- id: 'spacing',
80
- absoluteFilePath: targetPath,
81
- dependencies: [spacingTokensDependencyPath],
82
- },
83
- );
84
-
85
- return writeFile(targetPath, source).then(() =>
86
- console.log(`${targetPath} written!`),
87
- );
88
- }),
89
- );
90
- })
91
- .then(() => {
92
- // generate other values
93
- return Promise.all(
94
- [{ path: ['internal', primitivesFileNames['internal-box']] }].map(
95
- ({ path }) => {
96
- const targetPath = join(
97
- __dirname,
98
- '../',
99
- 'src',
100
- 'components',
101
- ...path,
102
- );
103
-
104
- const source = createPartialSignedArtifact(
105
- options => options.map(createStylesFromTemplate).join('\n'),
106
- 'yarn codegen-styles',
107
- { id: 'misc', absoluteFilePath: targetPath },
108
- );
27
+ new Promise(() => {
28
+ const targetPath = join(
29
+ __dirname,
30
+ '../',
31
+ 'src',
32
+ 'internal',
33
+ 'style-maps.partial.tsx',
34
+ );
109
35
 
110
- return writeFile(targetPath, source).then(() =>
111
- console.log(`${targetPath} written!`),
112
- );
36
+ const sourceFns = [
37
+ // width, height, minWidth, maxWidth, minHeight, maxHeight
38
+ () =>
39
+ createPartialSignedArtifact(
40
+ options => options.map(createStylesFromFileTemplate).join('\n'),
41
+ 'yarn codegen-styles',
42
+ {
43
+ id: 'dimensions',
44
+ absoluteFilePath: targetPath,
45
+ dependencies: templateFiles.filter(v => v.includes('dimensions')),
113
46
  },
114
47
  ),
115
- );
116
- })
117
- .then(() => {
118
- const targetPath = join(
119
- __dirname,
120
- '../',
121
- 'src',
122
- 'components',
123
- 'internal',
124
- primitivesFileNames['internal-box'],
125
- );
126
-
127
- const source = createPartialSignedArtifact(
128
- options => options.map(createDimensionStylesFromTemplate).join('\n'),
129
- 'yarn codegen-styles',
130
- {
131
- id: 'dimensions',
132
- absoluteFilePath: targetPath,
133
- },
134
- );
48
+ // padding, paddingBlock, paddingBlockStart, paddingBlockEnd, paddingInline, paddingInlineStart, paddingInlineEnd, gap, rowGap
49
+ () =>
50
+ createPartialSignedArtifact(
51
+ options => options.map(createSpacingStylesFromTemplate).join('\n'),
52
+ 'yarn codegen-styles',
53
+ {
54
+ id: 'spacing',
55
+ absoluteFilePath: targetPath,
56
+ dependencies: [spacingTokensDependencyPath],
57
+ },
58
+ ),
59
+ // text color, background-color, border-color, shadow
60
+ () =>
61
+ createPartialSignedArtifact(
62
+ options => options.map(createColorStylesFromTemplate).join('\n'),
63
+ 'yarn codegen-styles',
64
+ {
65
+ id: 'colors',
66
+ absoluteFilePath: targetPath,
67
+ dependencies: [colorTokensDependencyPath],
68
+ },
69
+ ),
70
+ // border-width, border-radius
71
+ () =>
72
+ createPartialSignedArtifact(
73
+ options => options.map(createBorderStylesFromTemplate).join('\n'),
74
+ 'yarn codegen-styles',
75
+ {
76
+ id: 'border',
77
+ absoluteFilePath: targetPath,
78
+ dependencies: [shapeTokensDependencyPath],
79
+ },
80
+ ),
81
+ // align-self, border-color, border-radius, border-style, border-width, display, flex-grow, flex-shrink, flex, layer, overflow, position',
82
+ () =>
83
+ createPartialSignedArtifact(
84
+ options => options.map(createStylesFromFileTemplate).join('\n'),
85
+ 'yarn codegen-styles',
86
+ {
87
+ id: 'misc',
88
+ absoluteFilePath: targetPath,
89
+ dependencies: templateFiles,
90
+ },
91
+ ),
92
+ ];
135
93
 
136
- return writeFile(targetPath, source).then(() =>
137
- console.log(`${targetPath} written!`),
138
- );
94
+ sourceFns.forEach(sourceFn => {
95
+ writeFileSync(targetPath, sourceFn());
139
96
  });
97
+
98
+ console.log(`${targetPath} written!`);
99
+ });
@@ -8,18 +8,13 @@ import tokens from '@atlaskit/tokens/src/artifacts/tokens-raw/atlassian-light';
8
8
 
9
9
  import {
10
10
  capitalize,
11
- compose,
12
- isHovered,
13
- isPressed,
14
- not,
15
- pick,
16
- ShadowDefintion,
17
- tokenToStyle,
11
+ constructTokenFunctionCall,
12
+ ShadowDefinition,
18
13
  } from './utils';
19
14
 
20
15
  type Token = {
21
16
  token: string;
22
- fallback: string | ShadowDefintion;
17
+ fallback: string | ShadowDefinition;
23
18
  isDeprecated: boolean;
24
19
  };
25
20
 
@@ -61,18 +56,14 @@ const bothTokens = tokens.map((t, i) => [t, legacyTokens[i]]);
61
56
 
62
57
  const activeTokens = bothTokens
63
58
  .filter(([t]) => t.attributes.state !== 'deleted')
64
- .map(t => {
65
- return t;
66
- })
59
+ .map(t => t)
67
60
  .map(
68
61
  ([t, legacy]): Token => ({
69
62
  token: t.name,
70
- fallback: legacy.value as string | ShadowDefintion,
63
+ fallback: legacy.value as string | ShadowDefinition,
71
64
  isDeprecated: t.attributes.state === 'deprecated',
72
65
  }),
73
- )
74
- .filter(compose(pick('token'), not(isPressed)))
75
- .filter(compose(pick('token'), not(isHovered)));
66
+ );
76
67
 
77
68
  export const createColorStylesFromTemplate = (
78
69
  colorProperty: keyof typeof tokenStyles,
@@ -81,13 +72,12 @@ export const createColorStylesFromTemplate = (
81
72
  throw new Error(`[codegen] Unknown option found "${colorProperty}"`);
82
73
  }
83
74
 
84
- const { prefix, cssProperty, filterFn, objectName } =
85
- tokenStyles[colorProperty];
75
+ const { prefix, filterFn, objectName } = tokenStyles[colorProperty];
86
76
 
87
77
  return (
88
78
  prettier.format(
89
79
  `
90
- const ${objectName}Map = {
80
+ export const ${objectName}Map = {
91
81
  ${activeTokens
92
82
  .filter(filterFn)
93
83
  // @ts-ignore
@@ -97,7 +87,7 @@ const ${objectName}Map = {
97
87
  const propName = t.token.replace(prefix, '');
98
88
  return `
99
89
  ${t.isDeprecated ? '// @deprecated' : ''}
100
- '${propName}': ${tokenToStyle(cssProperty, t.token, t.fallback)}
90
+ '${propName}': ${constructTokenFunctionCall(t.token, t.fallback)}
101
91
  `.trim();
102
92
  })
103
93
  .join(',\n\t')}
@@ -1,43 +1,23 @@
1
- import prettier from 'prettier';
2
- import parserTypeScript from 'prettier/parser-typescript';
1
+ import { readFileSync } from 'fs';
2
+ import { join } from 'path';
3
3
 
4
- import { Layer } from '../src/constants';
5
-
6
- const styleProperties: Record<'layer', Record<Layer, number>> = {
7
- layer: {
8
- card: 100,
9
- navigation: 200,
10
- dialog: 300,
11
- layer: 400,
12
- blanket: 500,
13
- modal: 510,
14
- flag: 600,
15
- spotlight: 700,
16
- tooltip: 800,
17
- },
18
- };
19
-
20
- export const createStylesFromTemplate = (
21
- property: keyof typeof styleProperties,
4
+ export const createStylesFromFileTemplate = (
5
+ property:
6
+ | 'align-self'
7
+ | 'border-color'
8
+ | 'border-radius'
9
+ | 'border-style'
10
+ | 'border-width'
11
+ | 'dimensions'
12
+ | 'display'
13
+ | 'flex-grow'
14
+ | 'flex-shrink'
15
+ | 'flex'
16
+ | 'layer'
17
+ | 'overflow'
18
+ | 'position',
22
19
  ) => {
23
- if (!styleProperties[property]) {
24
- throw new Error(`[codegen] Unknown option found "${property}"`);
25
- }
26
-
27
- return prettier.format(
28
- `
29
- const ${property}Map = {
30
- ${Object.keys(styleProperties[property])
31
- .map(key => {
32
- return `'${key}': css({ zIndex: LAYERS['${key}'] })`;
33
- })
34
- .join(',\n\t')}
35
- } as const;`,
36
- {
37
- singleQuote: true,
38
- trailingComma: 'all',
39
- parser: 'typescript',
40
- plugins: [parserTypeScript],
41
- },
42
- );
20
+ const path = join(__dirname, './codegen-file-templates', `${property}.tsx`);
21
+ const source = readFileSync(path);
22
+ return source;
43
23
  };
@@ -3,7 +3,7 @@ import parserTypeScript from 'prettier/parser-typescript';
3
3
 
4
4
  import { spacing as tokens } from '@atlaskit/tokens/tokens-raw';
5
5
 
6
- import { capitalize, tokenToStyle } from './utils';
6
+ import { capitalize, constructTokenFunctionCall } from './utils';
7
7
 
8
8
  const spacingProperties: Record<
9
9
  string,
@@ -56,12 +56,7 @@ export const createSpacingStylesFromTemplate = (
56
56
  return (
57
57
  prettier.format(
58
58
  `
59
- const ${spacingProperty}Map = Object.fromEntries(
60
- [
61
- '${cssProperties.join("','")}',
62
- ].map((property: string) => [
63
- property,
64
- {
59
+ export const ${spacingProperty}Map = {
65
60
  ${activeTokens
66
61
  .sort((a, b) =>
67
62
  a.name.localeCompare(b.name, undefined, { numeric: true }),
@@ -70,14 +65,12 @@ export const createSpacingStylesFromTemplate = (
70
65
  const propName = propNameFormatter
71
66
  ? propNameFormatter(token.name)
72
67
  : token.name;
73
- return `'${propName}': ${tokenToStyle(
74
- '[property]' as any,
68
+ return `'${propName}': ${constructTokenFunctionCall(
75
69
  token.name,
76
70
  token.fallback,
77
71
  )}`;
78
72
  })}
79
- } as const,
80
- ]));`,
73
+ } as const;`,
81
74
  {
82
75
  singleQuote: true,
83
76
  trailingComma: 'all',
@@ -90,7 +83,7 @@ export const createSpacingStylesFromTemplate = (
90
83
  cssProperty =>
91
84
  `\nexport type ${capitalize(
92
85
  cssProperty,
93
- )} = keyof typeof ${spacingProperty}Map.${cssProperty};`,
86
+ )} = keyof typeof ${spacingProperty}Map;`,
94
87
  )
95
88
  .join('') +
96
89
  '\n')
package/scripts/utils.tsx CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { CSSProperties } from 'react';
2
2
 
3
- export const tokenCall = (token: string, fallback: string | ShadowDefintion) =>
3
+ export const tokenCall = (token: string, fallback: string | ShadowDefinition) =>
4
4
  `token('${token}', '${fallback}')`;
5
5
 
6
6
  export const tokenToStyle = (
7
7
  prop: keyof CSSProperties,
8
8
  token: string,
9
- fallback: string | ShadowDefintion,
9
+ fallback: string | ShadowDefinition,
10
10
  ) => {
11
11
  if (Array.isArray(fallback)) {
12
12
  fallback = constructShadow(fallback);
@@ -14,7 +14,18 @@ export const tokenToStyle = (
14
14
  return `css({\n\t${prop}: ${tokenCall(token, fallback)}\n})`;
15
15
  };
16
16
 
17
- export type ShadowDefintion = Array<{
17
+ export const constructTokenFunctionCall = (
18
+ token: string,
19
+ fallback: string | ShadowDefinition,
20
+ ) => {
21
+ if (Array.isArray(fallback)) {
22
+ fallback = constructShadow(fallback);
23
+ }
24
+
25
+ return `token('${token}', '${fallback}')`;
26
+ };
27
+
28
+ export type ShadowDefinition = Array<{
18
29
  radius: number;
19
30
  offset: {
20
31
  x: number;
@@ -24,7 +35,7 @@ export type ShadowDefintion = Array<{
24
35
  opacity: number;
25
36
  }>;
26
37
 
27
- const constructShadow = (shadowObject: ShadowDefintion) => {
38
+ const constructShadow = (shadowObject: ShadowDefinition) => {
28
39
  return shadowObject
29
40
  .map(
30
41
  shadow =>