@atlaskit/primitives 1.4.2 → 1.4.4
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/CHANGELOG.md +12 -0
- package/README.md +12 -5
- package/constellation/responsive/usage.mdx +1 -1
- package/dist/cjs/components/inline.js +1 -1
- package/dist/cjs/components/internal/surface-provider.js +27 -0
- package/dist/cjs/components/text.js +131 -0
- package/dist/cjs/xcss/style-maps.partial.js +90 -3
- package/dist/es2019/components/inline.js +1 -1
- package/dist/es2019/components/internal/surface-provider.js +19 -0
- package/dist/es2019/components/text.js +127 -0
- package/dist/es2019/xcss/style-maps.partial.js +72 -1
- package/dist/esm/components/inline.js +1 -1
- package/dist/esm/components/internal/surface-provider.js +19 -0
- package/dist/esm/components/text.js +128 -0
- package/dist/esm/xcss/style-maps.partial.js +72 -1
- package/dist/types/components/internal/surface-provider.d.ts +15 -0
- package/dist/types/components/text.d.ts +57 -0
- package/dist/types/xcss/style-maps.partial.d.ts +94 -0
- package/dist/types-ts4.5/components/internal/surface-provider.d.ts +15 -0
- package/dist/types-ts4.5/components/text.d.ts +63 -0
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +94 -0
- package/package.json +5 -4
- package/scripts/codegen-styles.tsx +12 -0
- package/scripts/typography-codegen-template.tsx +107 -0
|
@@ -402,6 +402,76 @@ export declare const borderRadiusMap: {
|
|
|
402
402
|
readonly 'border.radius.circle': "var(--ds-border-radius-circle)";
|
|
403
403
|
};
|
|
404
404
|
export type BorderRadius = keyof typeof borderRadiusMap;
|
|
405
|
+
/**
|
|
406
|
+
* @codegenEnd
|
|
407
|
+
*/
|
|
408
|
+
/**
|
|
409
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
410
|
+
* @codegen <<SignedSource::752c1b8bdc7db62e519dd729222d57ad>>
|
|
411
|
+
* @codegenId typography
|
|
412
|
+
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
413
|
+
* @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "heading", "ui"]
|
|
414
|
+
* @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::0cd422575c3f2a3784eeef767abe71f4>>
|
|
415
|
+
* @codegenDependency ../../scripts/codegen-file-templates/layer.tsx <<SignedSource::79d24a1e558f12d671c06a7609f90dc1>>
|
|
416
|
+
*/
|
|
417
|
+
export declare const fontSizeMap: {
|
|
418
|
+
'font.size.050': "var(--ds-font-size-050)";
|
|
419
|
+
'font.size.075': "var(--ds-font-size-075)";
|
|
420
|
+
'font.size.100': "var(--ds-font-size-100)";
|
|
421
|
+
'font.size.200': "var(--ds-font-size-200)";
|
|
422
|
+
'font.size.300': "var(--ds-font-size-300)";
|
|
423
|
+
'font.size.400': "var(--ds-font-size-400)";
|
|
424
|
+
'font.size.500': "var(--ds-font-size-500)";
|
|
425
|
+
'font.size.600': "var(--ds-font-size-600)";
|
|
426
|
+
};
|
|
427
|
+
export type FontSize = keyof typeof fontSizeMap;
|
|
428
|
+
export declare const fontWeightMap: {
|
|
429
|
+
'font.weight.bold': "var(--ds-font-weight-bold)";
|
|
430
|
+
'font.weight.medium': "var(--ds-font-weight-medium)";
|
|
431
|
+
'font.weight.regular': "var(--ds-font-weight-regular)";
|
|
432
|
+
'font.weight.semibold': "var(--ds-font-weight-semibold)";
|
|
433
|
+
};
|
|
434
|
+
export type FontWeight = keyof typeof fontWeightMap;
|
|
435
|
+
export declare const fontFamilyMap: {
|
|
436
|
+
'font.family.body': "var(--ds-font-family-body)";
|
|
437
|
+
'font.family.brand': "var(--ds-font-family-brand)";
|
|
438
|
+
'font.family.code': "var(--ds-font-family-code)";
|
|
439
|
+
'font.family.heading': "var(--ds-font-family-heading)";
|
|
440
|
+
'font.family.monospace': "var(--ds-font-family-monospace)";
|
|
441
|
+
'font.family.sans': "var(--ds-font-family-sans)";
|
|
442
|
+
};
|
|
443
|
+
export type FontFamily = keyof typeof fontFamilyMap;
|
|
444
|
+
export declare const lineHeightMap: {
|
|
445
|
+
'font.lineHeight.1': "var(--ds-font-lineHeight-1)";
|
|
446
|
+
'font.lineHeight.100': "var(--ds-font-lineHeight-100)";
|
|
447
|
+
'font.lineHeight.200': "var(--ds-font-lineHeight-200)";
|
|
448
|
+
'font.lineHeight.300': "var(--ds-font-lineHeight-300)";
|
|
449
|
+
'font.lineHeight.400': "var(--ds-font-lineHeight-400)";
|
|
450
|
+
'font.lineHeight.500': "var(--ds-font-lineHeight-500)";
|
|
451
|
+
'font.lineHeight.600': "var(--ds-font-lineHeight-600)";
|
|
452
|
+
};
|
|
453
|
+
export type LineHeight = keyof typeof lineHeightMap;
|
|
454
|
+
export declare const bodyTextMap: {
|
|
455
|
+
body: "var(--ds-font-body)";
|
|
456
|
+
'body.lg': "var(--ds-font-body-lg)";
|
|
457
|
+
'body.sm': "var(--ds-font-body-sm)";
|
|
458
|
+
};
|
|
459
|
+
export type BodyText = keyof typeof bodyTextMap;
|
|
460
|
+
export declare const headingTextMap: {
|
|
461
|
+
'heading.lg': "var(--ds-font-heading-lg)";
|
|
462
|
+
'heading.md': "var(--ds-font-heading-md)";
|
|
463
|
+
'heading.sm': "var(--ds-font-heading-sm)";
|
|
464
|
+
'heading.xl': "var(--ds-font-heading-xl)";
|
|
465
|
+
'heading.xs': "var(--ds-font-heading-xs)";
|
|
466
|
+
'heading.xxl': "var(--ds-font-heading-xxl)";
|
|
467
|
+
'heading.xxs': "var(--ds-font-heading-xxs)";
|
|
468
|
+
};
|
|
469
|
+
export type HeadingText = keyof typeof headingTextMap;
|
|
470
|
+
export declare const uiTextMap: {
|
|
471
|
+
ui: "var(--ds-font-ui)";
|
|
472
|
+
'ui.sm': "var(--ds-font-ui-sm)";
|
|
473
|
+
};
|
|
474
|
+
export type UiText = keyof typeof uiTextMap;
|
|
405
475
|
/**
|
|
406
476
|
* @codegenEnd
|
|
407
477
|
*/
|
|
@@ -482,9 +552,33 @@ declare const spacingProperties: readonly [
|
|
|
482
552
|
type SpacingProperty = (typeof spacingProperties)[number];
|
|
483
553
|
type SpacingToken = keyof typeof spaceMap;
|
|
484
554
|
type BackgroundColorToken = keyof typeof backgroundColorMap;
|
|
555
|
+
type TextColorToken = keyof typeof textColorMap;
|
|
556
|
+
type FontSizeToken = keyof typeof fontSizeMap;
|
|
557
|
+
type FontWeightToken = keyof typeof fontWeightMap;
|
|
558
|
+
type FontFamilyToken = keyof typeof fontFamilyMap;
|
|
559
|
+
type LineHeightToken = keyof typeof lineHeightMap;
|
|
560
|
+
type HeadingTextToken = keyof typeof headingTextMap;
|
|
561
|
+
type BodyTextToken = keyof typeof bodyTextMap;
|
|
562
|
+
type UITextToken = keyof typeof uiTextMap;
|
|
485
563
|
type SpacingStyleMap = Record<SpacingProperty, Record<SpacingToken, SerializedStyles>>;
|
|
486
564
|
type BackgroundColorStyleMap = Record<BackgroundColorToken, SerializedStyles>;
|
|
565
|
+
type TextColorStyleMap = Record<TextColorToken, SerializedStyles>;
|
|
566
|
+
type FontSizeStyleMap = Record<FontSizeToken, SerializedStyles>;
|
|
567
|
+
type FontWeightStyleMap = Record<FontWeightToken, SerializedStyles>;
|
|
568
|
+
type FontFamilyStyleMap = Record<FontFamilyToken, SerializedStyles>;
|
|
569
|
+
type LineHeightStyleMap = Record<LineHeightToken, SerializedStyles>;
|
|
570
|
+
type HeadingTextStyleMap = Record<HeadingTextToken, SerializedStyles>;
|
|
571
|
+
type BodyTextStyleMap = Record<BodyTextToken, SerializedStyles>;
|
|
572
|
+
type UITextStyleMap = Record<UITextToken, SerializedStyles>;
|
|
487
573
|
export declare const paddingStylesMap: SpacingStyleMap;
|
|
488
574
|
export declare const spaceStylesMap: SpacingStyleMap;
|
|
489
575
|
export declare const backgroundColorStylesMap: BackgroundColorStyleMap;
|
|
576
|
+
export declare const textColorStylesMap: TextColorStyleMap;
|
|
577
|
+
export declare const fontSizeStylesMap: FontSizeStyleMap;
|
|
578
|
+
export declare const fontWeightStylesMap: FontWeightStyleMap;
|
|
579
|
+
export declare const fontFamilyStylesMap: FontFamilyStyleMap;
|
|
580
|
+
export declare const lineHeightStylesMap: LineHeightStyleMap;
|
|
581
|
+
export declare const headingTextStylesMap: HeadingTextStyleMap;
|
|
582
|
+
export declare const bodyTextStylesMap: BodyTextStyleMap;
|
|
583
|
+
export declare const uiTextStylesMap: UITextStyleMap;
|
|
490
584
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -116,11 +116,12 @@
|
|
|
116
116
|
"codegen-styles": "ts-node -r tsconfig-paths/register ./scripts/codegen-styles.tsx"
|
|
117
117
|
},
|
|
118
118
|
"dependencies": {
|
|
119
|
-
"@atlaskit/tokens": "^1.
|
|
119
|
+
"@atlaskit/tokens": "^1.22.0",
|
|
120
120
|
"@babel/runtime": "^7.0.0",
|
|
121
121
|
"@emotion/react": "^11.7.1",
|
|
122
122
|
"@emotion/serialize": "^1.1.0",
|
|
123
|
-
"bind-event-listener": "^2.1.1"
|
|
123
|
+
"bind-event-listener": "^2.1.1",
|
|
124
|
+
"tiny-invariant": "^1.2.0"
|
|
124
125
|
},
|
|
125
126
|
"peerDependencies": {
|
|
126
127
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
@@ -165,7 +166,7 @@
|
|
|
165
166
|
]
|
|
166
167
|
}
|
|
167
168
|
},
|
|
168
|
-
"homepage": "https://atlassian.design/components/primitives",
|
|
169
|
+
"homepage": "https://atlassian.design/components/primitives/overview/",
|
|
169
170
|
"typesVersions": {
|
|
170
171
|
">=4.5 <4.9": {
|
|
171
172
|
"*": [
|
|
@@ -8,6 +8,7 @@ import { createBorderStylesFromTemplate } from './border-codegen-template';
|
|
|
8
8
|
import { createColorStylesFromTemplate } from './color-codegen-template';
|
|
9
9
|
import { createStylesFromFileTemplate } from './misc-codegen-template';
|
|
10
10
|
import { createSpacingStylesFromTemplate } from './spacing-codegen-template';
|
|
11
|
+
import { createTypographyStylesFromTemplate } from './typography-codegen-template';
|
|
11
12
|
|
|
12
13
|
const colorTokensDependencyPath = require.resolve(
|
|
13
14
|
'../../tokens/src/artifacts/tokens-raw/atlassian-light',
|
|
@@ -89,6 +90,17 @@ const sourceFns = [
|
|
|
89
90
|
dependencies: templateFiles,
|
|
90
91
|
},
|
|
91
92
|
),
|
|
93
|
+
// font*, lineheight
|
|
94
|
+
() =>
|
|
95
|
+
createPartialSignedArtifact(
|
|
96
|
+
options => options.map(createTypographyStylesFromTemplate).join('\n'),
|
|
97
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
98
|
+
{
|
|
99
|
+
id: 'typography',
|
|
100
|
+
absoluteFilePath: targetPath,
|
|
101
|
+
dependencies: templateFiles,
|
|
102
|
+
},
|
|
103
|
+
),
|
|
92
104
|
];
|
|
93
105
|
|
|
94
106
|
sourceFns.forEach(sourceFn => {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import prettier from 'prettier';
|
|
2
|
+
import parserTypeScript from 'prettier/parser-typescript';
|
|
3
|
+
|
|
4
|
+
import { typography as tokens } from '@atlaskit/tokens/tokens-raw';
|
|
5
|
+
|
|
6
|
+
import { capitalize, constructTokenFunctionCall } from './utils';
|
|
7
|
+
|
|
8
|
+
type Token = {
|
|
9
|
+
name: string;
|
|
10
|
+
fallback: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const typographyProperties = {
|
|
14
|
+
heading: {
|
|
15
|
+
objectName: 'headingText',
|
|
16
|
+
prefix: 'font.heading',
|
|
17
|
+
cssProperty: 'font',
|
|
18
|
+
filterFn: <T extends Token>(t: T) => t.name.startsWith('font.heading'),
|
|
19
|
+
},
|
|
20
|
+
body: {
|
|
21
|
+
objectName: 'bodyText',
|
|
22
|
+
prefix: 'font.body',
|
|
23
|
+
cssProperty: 'font',
|
|
24
|
+
filterFn: <T extends Token>(t: T) => t.name.startsWith('font.body'),
|
|
25
|
+
},
|
|
26
|
+
ui: {
|
|
27
|
+
objectName: 'uiText',
|
|
28
|
+
prefix: 'font.ui',
|
|
29
|
+
cssProperty: 'font',
|
|
30
|
+
filterFn: <T extends Token>(t: T) => t.name.startsWith('font.ui'),
|
|
31
|
+
},
|
|
32
|
+
fontSize: {
|
|
33
|
+
objectName: 'fontSize',
|
|
34
|
+
cssProperty: 'fontSize',
|
|
35
|
+
prefix: 'font.size',
|
|
36
|
+
filterFn: <T extends Token>(t: T) => t.name.startsWith('font.size'),
|
|
37
|
+
},
|
|
38
|
+
fontWeight: {
|
|
39
|
+
objectName: 'fontWeight',
|
|
40
|
+
cssProperty: 'fontWeight',
|
|
41
|
+
prefix: 'font.weight.',
|
|
42
|
+
filterFn: <T extends Token>(t: T) => t.name.startsWith('font.weight'),
|
|
43
|
+
},
|
|
44
|
+
fontFamily: {
|
|
45
|
+
objectName: 'fontFamily',
|
|
46
|
+
cssProperty: 'fontFamily',
|
|
47
|
+
prefix: 'font.family.',
|
|
48
|
+
filterFn: <T extends Token>(t: T) => t.name.startsWith('font.family'),
|
|
49
|
+
},
|
|
50
|
+
lineHeight: {
|
|
51
|
+
objectName: 'lineHeight',
|
|
52
|
+
cssProperty: 'lineHeight',
|
|
53
|
+
prefix: 'font.',
|
|
54
|
+
filterFn: <T extends Token>(t: T) => t.name.startsWith('font.lineHeight'),
|
|
55
|
+
},
|
|
56
|
+
} as const;
|
|
57
|
+
|
|
58
|
+
const activeTokens: Token[] = tokens.map(t => ({
|
|
59
|
+
name: t.name,
|
|
60
|
+
fallback: t.value,
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
const removeVerbosity = (name: string): string => {
|
|
64
|
+
const toRemove = ['font.heading', 'font.ui', 'font.body'];
|
|
65
|
+
if (toRemove.some(s => name.includes(s))) {
|
|
66
|
+
return name.replace('font.', '');
|
|
67
|
+
}
|
|
68
|
+
return name;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const createTypographyStylesFromTemplate = (
|
|
72
|
+
typographyProperty: keyof typeof typographyProperties,
|
|
73
|
+
) => {
|
|
74
|
+
if (!typographyProperties[typographyProperty]) {
|
|
75
|
+
throw new Error(`[codegen] Unknown option found "${typographyProperty}"`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const { filterFn, objectName } = typographyProperties[typographyProperty];
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
prettier.format(
|
|
82
|
+
`
|
|
83
|
+
export const ${objectName}Map = {
|
|
84
|
+
${activeTokens
|
|
85
|
+
.filter(filterFn)
|
|
86
|
+
.map(t => ({ ...t, name: t.name.replaceAll('.[default]', '') }))
|
|
87
|
+
.sort((a, b) => (a.name < b.name ? -1 : 1))
|
|
88
|
+
.map(token => {
|
|
89
|
+
return `
|
|
90
|
+
'${removeVerbosity(token.name)}': ${constructTokenFunctionCall(
|
|
91
|
+
token.name,
|
|
92
|
+
token.fallback,
|
|
93
|
+
)}
|
|
94
|
+
`.trim();
|
|
95
|
+
})
|
|
96
|
+
.join(',\n\t')}
|
|
97
|
+
};`,
|
|
98
|
+
{
|
|
99
|
+
singleQuote: true,
|
|
100
|
+
trailingComma: 'all',
|
|
101
|
+
parser: 'typescript',
|
|
102
|
+
plugins: [parserTypeScript],
|
|
103
|
+
},
|
|
104
|
+
) +
|
|
105
|
+
`\nexport type ${capitalize(objectName)} = keyof typeof ${objectName}Map;\n`
|
|
106
|
+
);
|
|
107
|
+
};
|