@atlaskit/primitives 3.1.0 → 4.0.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 (56) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/constellation/text/code.mdx +1 -1
  3. package/constellation/text/examples.mdx +3 -3
  4. package/constellation/text/usage.mdx +2 -4
  5. package/dist/cjs/components/anchor.js +4 -2
  6. package/dist/cjs/components/bleed.js +3 -2
  7. package/dist/cjs/components/box.js +5 -5
  8. package/dist/cjs/components/flex.js +3 -2
  9. package/dist/cjs/components/grid.js +3 -2
  10. package/dist/cjs/components/inline.js +8 -3
  11. package/dist/cjs/components/pressable.js +5 -1
  12. package/dist/cjs/components/stack.js +8 -3
  13. package/dist/cjs/components/text.js +2 -5
  14. package/dist/cjs/xcss/style-maps.partial.js +8 -39
  15. package/dist/cjs/xcss/xcss.js +52 -14
  16. package/dist/es2019/components/anchor.js +4 -2
  17. package/dist/es2019/components/bleed.js +3 -2
  18. package/dist/es2019/components/box.js +5 -5
  19. package/dist/es2019/components/flex.js +3 -2
  20. package/dist/es2019/components/grid.js +3 -2
  21. package/dist/es2019/components/inline.js +8 -3
  22. package/dist/es2019/components/pressable.js +5 -1
  23. package/dist/es2019/components/stack.js +8 -3
  24. package/dist/es2019/components/text.js +2 -6
  25. package/dist/es2019/xcss/style-maps.partial.js +7 -38
  26. package/dist/es2019/xcss/xcss.js +38 -8
  27. package/dist/esm/components/anchor.js +4 -2
  28. package/dist/esm/components/bleed.js +3 -2
  29. package/dist/esm/components/box.js +5 -5
  30. package/dist/esm/components/flex.js +3 -2
  31. package/dist/esm/components/grid.js +3 -2
  32. package/dist/esm/components/inline.js +8 -3
  33. package/dist/esm/components/pressable.js +5 -1
  34. package/dist/esm/components/stack.js +8 -3
  35. package/dist/esm/components/text.js +2 -6
  36. package/dist/esm/xcss/style-maps.partial.js +7 -38
  37. package/dist/esm/xcss/xcss.js +52 -10
  38. package/dist/types/components/flex.d.ts +2 -2
  39. package/dist/types/components/grid.d.ts +3 -3
  40. package/dist/types/components/pressable.d.ts +1 -1
  41. package/dist/types/components/stack.d.ts +1 -1
  42. package/dist/types/components/text.d.ts +12 -23
  43. package/dist/types/components/types.d.ts +3 -2
  44. package/dist/types/xcss/style-maps.partial.d.ts +9 -49
  45. package/dist/types/xcss/xcss.d.ts +11 -5
  46. package/dist/types-ts4.5/components/flex.d.ts +2 -2
  47. package/dist/types-ts4.5/components/grid.d.ts +3 -3
  48. package/dist/types-ts4.5/components/pressable.d.ts +1 -1
  49. package/dist/types-ts4.5/components/stack.d.ts +1 -1
  50. package/dist/types-ts4.5/components/text.d.ts +12 -23
  51. package/dist/types-ts4.5/components/types.d.ts +3 -2
  52. package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +9 -49
  53. package/dist/types-ts4.5/xcss/xcss.d.ts +11 -5
  54. package/package.json +3 -2
  55. package/scripts/codegen-styles.tsx +1 -1
  56. package/scripts/typography-codegen-template.tsx +34 -56
@@ -10,58 +10,36 @@ type Token = {
10
10
  fallback: string;
11
11
  };
12
12
 
13
- const typographyProperties = {
14
- heading: {
15
- objectName: 'headingText',
16
- prefix: 'font.heading',
13
+ const activeTokens: Token[] = tokens
14
+ .filter(t => t.attributes.state === 'active')
15
+ .map(t => ({
16
+ name: t.name,
17
+ fallback: t.value,
18
+ }));
19
+
20
+ const typographyProperties = [
21
+ {
22
+ objectName: 'bodyFont',
17
23
  cssProperty: 'font',
18
- filterFn: <T extends Token>(t: T) => t.name.startsWith('font.heading'),
19
- },
20
- body: {
21
- objectName: 'bodyText',
22
24
  prefix: 'font.body',
23
- cssProperty: 'font',
24
25
  filterFn: <T extends Token>(t: T) => t.name.startsWith('font.body'),
25
26
  },
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: {
27
+ {
39
28
  objectName: 'fontWeight',
40
29
  cssProperty: 'fontWeight',
41
30
  prefix: 'font.weight.',
42
31
  filterFn: <T extends Token>(t: T) => t.name.startsWith('font.weight'),
43
32
  },
44
- fontFamily: {
33
+ {
45
34
  objectName: 'fontFamily',
46
35
  cssProperty: 'fontFamily',
47
36
  prefix: 'font.family.',
48
37
  filterFn: <T extends Token>(t: T) => t.name.startsWith('font.family'),
49
38
  },
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
- }));
39
+ ] as const;
62
40
 
63
41
  const removeVerbosity = (name: string): string => {
64
- const partialRemove = ['font.heading', 'font.ui', 'font.body'];
42
+ const partialRemove = ['font.body'];
65
43
  if (partialRemove.some(s => name.includes(s))) {
66
44
  return name.replace('font.', '');
67
45
  }
@@ -75,18 +53,14 @@ const removeVerbosity = (name: string): string => {
75
53
  return name;
76
54
  };
77
55
 
78
- export const createTypographyStylesFromTemplate = (
79
- typographyProperty: keyof typeof typographyProperties,
80
- ) => {
81
- if (!typographyProperties[typographyProperty]) {
82
- throw new Error(`[codegen] Unknown option found "${typographyProperty}"`);
83
- }
84
-
85
- const { filterFn, objectName } = typographyProperties[typographyProperty];
56
+ export const createTypographyStylesFromTemplate = () => {
57
+ return typographyProperties
58
+ .map(typographyProperty => {
59
+ const { filterFn, objectName } = typographyProperty;
86
60
 
87
- return (
88
- prettier.format(
89
- `
61
+ return (
62
+ prettier.format(
63
+ `
90
64
  export const ${objectName}Map = {
91
65
  ${activeTokens
92
66
  .filter(filterFn)
@@ -102,13 +76,17 @@ ${activeTokens
102
76
  })
103
77
  .join(',\n\t')}
104
78
  };`,
105
- {
106
- singleQuote: true,
107
- trailingComma: 'all',
108
- parser: 'typescript',
109
- plugins: [parserTypeScript],
110
- },
111
- ) +
112
- `\nexport type ${capitalize(objectName)} = keyof typeof ${objectName}Map;\n`
113
- );
79
+ {
80
+ singleQuote: true,
81
+ trailingComma: 'all',
82
+ parser: 'typescript',
83
+ plugins: [parserTypeScript],
84
+ },
85
+ ) +
86
+ `\nexport type ${capitalize(
87
+ objectName,
88
+ )} = keyof typeof ${objectName}Map;\n`
89
+ );
90
+ })
91
+ .join('\n');
114
92
  };