@atlaskit/primitives 7.0.0 → 7.0.2
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/.eslintrc.js +1 -1
- package/CHANGELOG.md +19 -1
- package/LICENSE.md +6 -8
- package/constellation/anchor/code.mdx +3 -3
- package/constellation/anchor/examples.mdx +33 -39
- package/constellation/anchor/usage.mdx +60 -30
- package/constellation/bleed/code.mdx +3 -3
- package/constellation/bleed/examples.mdx +17 -13
- package/constellation/box/code.mdx +3 -3
- package/constellation/box/examples.mdx +25 -19
- package/constellation/box/usage.mdx +15 -5
- package/constellation/flex/code.mdx +3 -3
- package/constellation/flex/examples.mdx +12 -11
- package/constellation/grid/code.mdx +3 -3
- package/constellation/grid/examples.mdx +15 -10
- package/constellation/inline/code.mdx +3 -3
- package/constellation/inline/examples.mdx +32 -38
- package/constellation/inline/usage.mdx +15 -6
- package/constellation/overview/index.mdx +29 -27
- package/constellation/pressable/code.mdx +5 -4
- package/constellation/pressable/examples.mdx +41 -55
- package/constellation/pressable/usage.mdx +59 -36
- package/constellation/responsive/01-show/code.mdx +3 -3
- package/constellation/responsive/01-show/examples.mdx +9 -13
- package/constellation/responsive/02-hide/code.mdx +3 -3
- package/constellation/responsive/02-hide/examples.mdx +9 -13
- package/constellation/responsive/03-breakpoints/examples.mdx +3 -3
- package/constellation/responsive/examples.mdx +10 -10
- package/constellation/responsive/usage.mdx +23 -15
- package/constellation/stack/code.mdx +3 -3
- package/constellation/stack/examples.mdx +26 -20
- package/constellation/stack/usage.mdx +13 -5
- package/constellation/text/code.mdx +3 -3
- package/constellation/text/examples.mdx +29 -15
- package/constellation/text/usage.mdx +6 -3
- package/constellation/xcss/examples.mdx +7 -5
- package/constellation/xcss/migration.mdx +32 -25
- package/constellation/xcss/usage.mdx +72 -60
- package/dist/cjs/components/anchor.js +4 -4
- package/dist/cjs/components/pressable.js +1 -1
- package/dist/cjs/xcss/style-maps.partial.js +13 -13
- package/dist/es2019/components/anchor.js +4 -4
- package/dist/es2019/components/pressable.js +1 -1
- package/dist/es2019/xcss/style-maps.partial.js +13 -13
- package/dist/esm/components/anchor.js +4 -4
- package/dist/esm/components/pressable.js +1 -1
- package/dist/esm/xcss/style-maps.partial.js +13 -13
- package/dist/types/components/anchor.d.ts +4 -4
- package/dist/types/responsive/index.d.ts +2 -2
- package/dist/types/xcss/style-maps.partial.d.ts +13 -13
- package/dist/types-ts4.5/components/anchor.d.ts +4 -4
- package/dist/types-ts4.5/responsive/index.d.ts +2 -2
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +13 -13
- package/extract-react-types/anchor-props.tsx +108 -116
- package/extract-react-types/bleed-props.tsx +17 -22
- package/extract-react-types/box-props.tsx +67 -70
- package/extract-react-types/flex-props.tsx +61 -61
- package/extract-react-types/grid-props.tsx +92 -92
- package/extract-react-types/hide-props.tsx +35 -35
- package/extract-react-types/inline-props.tsx +68 -68
- package/extract-react-types/pressable-props.tsx +101 -107
- package/extract-react-types/show-props.tsx +35 -35
- package/extract-react-types/stack-props.tsx +55 -55
- package/package.json +2 -2
- package/report.api.md +940 -965
- package/scripts/border-codegen-template.tsx +40 -47
- package/scripts/codegen-file-templates/dimensions.tsx +8 -8
- package/scripts/codegen-file-templates/layer.tsx +9 -9
- package/scripts/codegen-styles.tsx +97 -103
- package/scripts/color-codegen-template.tsx +61 -73
- package/scripts/elevation-codegen-template.tsx +50 -62
- package/scripts/inverse-color-map-template.tsx +26 -31
- package/scripts/misc-codegen-template.tsx +4 -9
- package/scripts/spacing-codegen-template.tsx +25 -31
- package/scripts/typography-codegen-template.tsx +59 -65
- package/scripts/utils.tsx +36 -43
|
@@ -4,64 +4,57 @@ import { shape as tokens } from '@atlaskit/tokens/tokens-raw';
|
|
|
4
4
|
import { capitalize, constructTokenFunctionCall } from './utils';
|
|
5
5
|
|
|
6
6
|
type Token = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
token: string;
|
|
8
|
+
fallback: string;
|
|
9
|
+
isDeprecated: boolean;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const tokenStyles = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
t.token.startsWith(tokenStyles.radius.filterPrefix),
|
|
26
|
-
},
|
|
13
|
+
width: {
|
|
14
|
+
objectName: 'borderWidth',
|
|
15
|
+
filterPrefix: 'border.width',
|
|
16
|
+
cssProperty: 'borderWidth',
|
|
17
|
+
filterFn: <T extends Token>(t: T) => t.token.startsWith(tokenStyles.width.filterPrefix),
|
|
18
|
+
},
|
|
19
|
+
radius: {
|
|
20
|
+
objectName: 'borderRadius',
|
|
21
|
+
filterPrefix: 'border.radius',
|
|
22
|
+
cssProperty: 'borderRadius',
|
|
23
|
+
filterFn: <T extends Token>(t: T) => t.token.startsWith(tokenStyles.radius.filterPrefix),
|
|
24
|
+
},
|
|
27
25
|
} as const;
|
|
28
26
|
|
|
29
27
|
const activeTokens = tokens
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
.filter((t) => t.attributes.state !== 'deleted')
|
|
29
|
+
.map(
|
|
30
|
+
(t): Token => ({
|
|
31
|
+
token: t.cleanName,
|
|
32
|
+
fallback: t.value === '4px' ? '3px' : (t.value as string),
|
|
33
|
+
isDeprecated: t.attributes.state === 'deprecated',
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
38
36
|
|
|
39
|
-
export const createBorderStylesFromTemplate = (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
throw new Error(`[codegen] Unknown option found "${property}"`);
|
|
44
|
-
}
|
|
37
|
+
export const createBorderStylesFromTemplate = (property: keyof typeof tokenStyles) => {
|
|
38
|
+
if (!tokenStyles[property]) {
|
|
39
|
+
throw new Error(`[codegen] Unknown option found "${property}"`);
|
|
40
|
+
}
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
const { filterFn, objectName } = tokenStyles[property];
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
return (
|
|
45
|
+
format(
|
|
46
|
+
`
|
|
50
47
|
export const ${objectName}Map = {
|
|
51
48
|
${activeTokens
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
.filter(filterFn)
|
|
50
|
+
.map((t) => {
|
|
51
|
+
return `
|
|
55
52
|
${t.isDeprecated ? '// @deprecated' : ''}
|
|
56
|
-
'${t.token}': ${constructTokenFunctionCall(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)}`.trim();
|
|
60
|
-
})
|
|
61
|
-
.join(',\n\t')}
|
|
53
|
+
'${t.token}': ${constructTokenFunctionCall(t.token, t.fallback)}`.trim();
|
|
54
|
+
})
|
|
55
|
+
.join(',\n\t')}
|
|
62
56
|
} as const;`,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
);
|
|
57
|
+
'typescript',
|
|
58
|
+
) + `\nexport type ${capitalize(objectName)} = keyof typeof ${objectName}Map;\n`
|
|
59
|
+
);
|
|
67
60
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export const dimensionMap = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
'100%': '100%',
|
|
3
|
+
'size.100': '1rem',
|
|
4
|
+
'size.200': '1.5rem',
|
|
5
|
+
'size.300': '2rem',
|
|
6
|
+
'size.400': '2.5rem',
|
|
7
|
+
'size.500': '3rem',
|
|
8
|
+
'size.600': '6rem',
|
|
9
|
+
'size.1000': '12rem',
|
|
10
10
|
} as const;
|
|
11
11
|
export type Dimension = keyof typeof dimensionMap;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export const layerMap = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
11
|
} as const;
|
|
12
12
|
|
|
13
13
|
export type Layer = keyof typeof layerMap;
|
|
@@ -13,122 +13,116 @@ import { createSpacingStylesFromTemplate } from './spacing-codegen-template';
|
|
|
13
13
|
import { createTypographyStylesFromTemplate } from './typography-codegen-template';
|
|
14
14
|
|
|
15
15
|
const colorTokensDependencyPath = require.resolve(
|
|
16
|
-
|
|
16
|
+
'../../tokens/src/artifacts/tokens-raw/atlassian-light',
|
|
17
17
|
);
|
|
18
18
|
const spacingTokensDependencyPath = require.resolve(
|
|
19
|
-
|
|
19
|
+
'../../tokens/src/artifacts/tokens-raw/atlassian-spacing',
|
|
20
20
|
);
|
|
21
21
|
const shapeTokensDependencyPath = require.resolve(
|
|
22
|
-
|
|
22
|
+
'../../tokens/src/artifacts/tokens-raw/atlassian-shape',
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
const templateFiles = readdirSync(join(__dirname, 'codegen-file-templates'), {
|
|
26
|
-
|
|
26
|
+
withFileTypes: true,
|
|
27
27
|
})
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
.filter((item) => !item.isDirectory())
|
|
29
|
+
.map((item) => join(__dirname, 'codegen-file-templates', item.name));
|
|
30
30
|
|
|
31
|
-
const targetPath = join(
|
|
32
|
-
__dirname,
|
|
33
|
-
'../',
|
|
34
|
-
'src',
|
|
35
|
-
'xcss',
|
|
36
|
-
'style-maps.partial.tsx',
|
|
37
|
-
);
|
|
31
|
+
const targetPath = join(__dirname, '../', 'src', 'xcss', 'style-maps.partial.tsx');
|
|
38
32
|
|
|
39
33
|
const sourceFns = [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
34
|
+
// width, height, minWidth, maxWidth, minHeight, maxHeight
|
|
35
|
+
() =>
|
|
36
|
+
createPartialSignedArtifact(
|
|
37
|
+
(options) => options.map(createStylesFromFileTemplate).join('\n'),
|
|
38
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
39
|
+
{
|
|
40
|
+
id: 'dimensions',
|
|
41
|
+
absoluteFilePath: targetPath,
|
|
42
|
+
dependencies: templateFiles.filter((v) => v.includes('dimensions')),
|
|
43
|
+
},
|
|
44
|
+
),
|
|
45
|
+
// padding*, gap*, inset*
|
|
46
|
+
() =>
|
|
47
|
+
createPartialSignedArtifact(
|
|
48
|
+
createSpacingStylesFromTemplate,
|
|
49
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
50
|
+
{
|
|
51
|
+
id: 'spacing',
|
|
52
|
+
absoluteFilePath: targetPath,
|
|
53
|
+
dependencies: [spacingTokensDependencyPath],
|
|
54
|
+
},
|
|
55
|
+
),
|
|
56
|
+
// text color, background-color, border-color
|
|
57
|
+
() =>
|
|
58
|
+
createPartialSignedArtifact(
|
|
59
|
+
(options) => options.map(createColorStylesFromTemplate).join('\n'),
|
|
60
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
61
|
+
{
|
|
62
|
+
id: 'colors',
|
|
63
|
+
absoluteFilePath: targetPath,
|
|
64
|
+
dependencies: [colorTokensDependencyPath],
|
|
65
|
+
},
|
|
66
|
+
),
|
|
67
|
+
// inverse color map
|
|
68
|
+
() =>
|
|
69
|
+
createPartialSignedArtifact(
|
|
70
|
+
createInverseColorMapTemplate,
|
|
71
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
72
|
+
{
|
|
73
|
+
id: 'inverse-colors',
|
|
74
|
+
absoluteFilePath: targetPath,
|
|
75
|
+
dependencies: [colorTokensDependencyPath],
|
|
76
|
+
},
|
|
77
|
+
),
|
|
78
|
+
// elevation (opacity, shadow, surface)
|
|
79
|
+
() =>
|
|
80
|
+
createPartialSignedArtifact(
|
|
81
|
+
(options) => options.map(createElevationStylesFromTemplate).join('\n'),
|
|
82
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
83
|
+
{
|
|
84
|
+
id: 'elevation',
|
|
85
|
+
absoluteFilePath: targetPath,
|
|
86
|
+
dependencies: [colorTokensDependencyPath],
|
|
87
|
+
},
|
|
88
|
+
),
|
|
89
|
+
// border-width, border-radius
|
|
90
|
+
() =>
|
|
91
|
+
createPartialSignedArtifact(
|
|
92
|
+
(options) => options.map(createBorderStylesFromTemplate).join('\n'),
|
|
93
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
94
|
+
{
|
|
95
|
+
id: 'border',
|
|
96
|
+
absoluteFilePath: targetPath,
|
|
97
|
+
dependencies: [shapeTokensDependencyPath],
|
|
98
|
+
},
|
|
99
|
+
),
|
|
100
|
+
// border-color, border-radius, border-width, layer',
|
|
101
|
+
() =>
|
|
102
|
+
createPartialSignedArtifact(
|
|
103
|
+
(options) => options.map(createStylesFromFileTemplate).join('\n'),
|
|
104
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
105
|
+
{
|
|
106
|
+
id: 'misc',
|
|
107
|
+
absoluteFilePath: targetPath,
|
|
108
|
+
dependencies: templateFiles,
|
|
109
|
+
},
|
|
110
|
+
),
|
|
111
|
+
// font*, lineheight
|
|
112
|
+
() =>
|
|
113
|
+
createPartialSignedArtifact(
|
|
114
|
+
createTypographyStylesFromTemplate,
|
|
115
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
116
|
+
{
|
|
117
|
+
id: 'typography',
|
|
118
|
+
absoluteFilePath: targetPath,
|
|
119
|
+
dependencies: templateFiles,
|
|
120
|
+
},
|
|
121
|
+
),
|
|
128
122
|
];
|
|
129
123
|
|
|
130
|
-
sourceFns.forEach(sourceFn => {
|
|
131
|
-
|
|
124
|
+
sourceFns.forEach((sourceFn) => {
|
|
125
|
+
writeFileSync(targetPath, sourceFn());
|
|
132
126
|
});
|
|
133
127
|
|
|
134
128
|
console.log(`${targetPath} written!`);
|
|
@@ -1,96 +1,84 @@
|
|
|
1
1
|
import format from '@af/formatting/sync';
|
|
2
|
-
import {
|
|
3
|
-
legacyLightTokens as legacyTokens,
|
|
4
|
-
light as tokens,
|
|
5
|
-
} from '@atlaskit/tokens/tokens-raw';
|
|
2
|
+
import { legacyLightTokens as legacyTokens, light as tokens } from '@atlaskit/tokens/tokens-raw';
|
|
6
3
|
|
|
7
|
-
import {
|
|
8
|
-
capitalize,
|
|
9
|
-
constructTokenFunctionCall,
|
|
10
|
-
type ShadowDefinition,
|
|
11
|
-
} from './utils';
|
|
4
|
+
import { capitalize, constructTokenFunctionCall, type ShadowDefinition } from './utils';
|
|
12
5
|
|
|
13
6
|
type Token = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
token: string;
|
|
8
|
+
fallback: string | ShadowDefinition;
|
|
9
|
+
isDeprecated: boolean;
|
|
17
10
|
};
|
|
18
11
|
|
|
19
12
|
// NB: Fallback CSS variables can be deleted when tokens are no longer behind a feature flag
|
|
20
13
|
const tokenStyles = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
filterFn: <T extends Token>(t: T) =>
|
|
51
|
-
t.token.startsWith(tokenStyles.fill.prefix),
|
|
52
|
-
},
|
|
14
|
+
text: {
|
|
15
|
+
objectName: 'textColor',
|
|
16
|
+
prefix: 'color.text.',
|
|
17
|
+
cssProperty: 'color',
|
|
18
|
+
filterFn: <T extends Token>(t: T) =>
|
|
19
|
+
t.token.startsWith(tokenStyles.text.prefix) || t.token.startsWith('color.link'),
|
|
20
|
+
},
|
|
21
|
+
background: {
|
|
22
|
+
objectName: 'backgroundColor',
|
|
23
|
+
prefix: 'color.background.',
|
|
24
|
+
cssProperty: 'backgroundColor',
|
|
25
|
+
filterFn: <T extends Token>(t: T) =>
|
|
26
|
+
t.token.startsWith(tokenStyles.background.prefix) ||
|
|
27
|
+
t.token.startsWith('elevation.surface') ||
|
|
28
|
+
t.token.startsWith('utility.elevation.surface') ||
|
|
29
|
+
t.token.startsWith('color.blanket'),
|
|
30
|
+
},
|
|
31
|
+
border: {
|
|
32
|
+
objectName: 'borderColor',
|
|
33
|
+
prefix: 'color.border.',
|
|
34
|
+
cssProperty: 'borderColor',
|
|
35
|
+
filterFn: <T extends Token>(t: T) => t.token.startsWith(tokenStyles.border.prefix),
|
|
36
|
+
},
|
|
37
|
+
fill: {
|
|
38
|
+
objectName: 'fill',
|
|
39
|
+
prefix: 'color.icon.',
|
|
40
|
+
cssProperty: 'fill',
|
|
41
|
+
filterFn: <T extends Token>(t: T) => t.token.startsWith(tokenStyles.fill.prefix),
|
|
42
|
+
},
|
|
53
43
|
} as const;
|
|
54
44
|
|
|
55
45
|
const bothTokens = tokens.map((t, i) => [t, legacyTokens[i]]);
|
|
56
46
|
|
|
57
47
|
const activeTokens = bothTokens
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
.filter(([t]) => t.attributes.state !== 'deleted')
|
|
49
|
+
.map((t) => t)
|
|
50
|
+
.map(
|
|
51
|
+
([t, legacy]): Token => ({
|
|
52
|
+
token: t.name,
|
|
53
|
+
fallback: legacy.value as string | ShadowDefinition,
|
|
54
|
+
isDeprecated: t.attributes.state === 'deprecated',
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
67
57
|
|
|
68
|
-
export const createColorStylesFromTemplate = (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
throw new Error(`[codegen] Unknown option found "${colorProperty}"`);
|
|
73
|
-
}
|
|
58
|
+
export const createColorStylesFromTemplate = (colorProperty: keyof typeof tokenStyles) => {
|
|
59
|
+
if (!tokenStyles[colorProperty]) {
|
|
60
|
+
throw new Error(`[codegen] Unknown option found "${colorProperty}"`);
|
|
61
|
+
}
|
|
74
62
|
|
|
75
|
-
|
|
63
|
+
const { filterFn, objectName } = tokenStyles[colorProperty];
|
|
76
64
|
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
return (
|
|
66
|
+
format(
|
|
67
|
+
`
|
|
79
68
|
export const ${objectName}Map = {
|
|
80
69
|
${activeTokens
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
70
|
+
.filter(filterFn)
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
.map((t) => ({ ...t, token: t.token.replaceAll('.[default]', '') }))
|
|
73
|
+
.map((t) => {
|
|
74
|
+
return `
|
|
86
75
|
${t.isDeprecated ? '// @deprecated' : ''}
|
|
87
76
|
'${t.token}': ${constructTokenFunctionCall(t.token, t.fallback)}
|
|
88
77
|
`.trim();
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
})
|
|
79
|
+
.join(',\n\t')}
|
|
91
80
|
} as const;`,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
);
|
|
81
|
+
'typescript',
|
|
82
|
+
) + `\nexport type ${capitalize(objectName)} = keyof typeof ${objectName}Map;\n`
|
|
83
|
+
);
|
|
96
84
|
};
|