@primer/primitives 10.2.0 → 10.3.0-rc.22c9c6cf

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 (123) hide show
  1. package/dist/build/formats/cssCustomMedia.js +2 -2
  2. package/dist/build/formats/jsonOneDimensional.js +2 -1
  3. package/dist/build/platforms/css.js +5 -2
  4. package/dist/build/platforms/figma.js +40 -36
  5. package/dist/build/preprocessors/themeOverrides.js +7 -4
  6. package/dist/build/schemas/collections.d.ts +1 -1
  7. package/dist/build/schemas/colorToken.d.ts +471 -65
  8. package/dist/build/schemas/colorToken.js +18 -15
  9. package/dist/build/schemas/shadowToken.js +2 -2
  10. package/dist/build/transformers/colorAlphaToCss.d.ts +1 -1
  11. package/dist/build/transformers/colorToHex.js +3 -3
  12. package/dist/build/transformers/colorToRgbAlpha.js +2 -2
  13. package/dist/build/transformers/figmaAttributes.js +2 -1
  14. package/dist/build/transformers/shadowToCss.js +2 -2
  15. package/dist/build/transformers/utilities/alpha.d.ts +2 -2
  16. package/dist/build/transformers/utilities/alpha.js +3 -3
  17. package/dist/build/types/styleDictionaryConfigGenerator.d.ts +1 -1
  18. package/dist/build/utilities/asArray.d.ts +1 -0
  19. package/dist/build/utilities/asArray.js +1 -0
  20. package/dist/build/utilities/log.d.ts +6 -0
  21. package/dist/build/utilities/log.js +34 -0
  22. package/dist/css/functional/size/border.css +5 -5
  23. package/dist/css/functional/size/size.css +15 -15
  24. package/dist/css/functional/size/viewport.css +2 -2
  25. package/dist/css/functional/themes/dark-colorblind.css +408 -408
  26. package/dist/css/functional/themes/dark-dimmed.css +390 -390
  27. package/dist/css/functional/themes/dark-high-contrast.css +412 -412
  28. package/dist/css/functional/themes/dark-tritanopia.css +406 -406
  29. package/dist/css/functional/themes/dark.css +416 -416
  30. package/dist/css/functional/themes/light-colorblind.css +444 -444
  31. package/dist/css/functional/themes/light-high-contrast.css +438 -438
  32. package/dist/css/functional/themes/light-tritanopia.css +432 -432
  33. package/dist/css/functional/themes/light.css +444 -444
  34. package/dist/css/primitives.css +20 -20
  35. package/dist/docs/base/motion/motion.json +88 -73
  36. package/dist/docs/base/size/size.json +94 -75
  37. package/dist/docs/base/typography/typography.json +14 -10
  38. package/dist/docs/functional/motion/motion.json +19 -15
  39. package/dist/docs/functional/size/border.json +139 -125
  40. package/dist/docs/functional/size/breakpoints.json +31 -25
  41. package/dist/docs/functional/size/size-coarse.json +13 -10
  42. package/dist/docs/functional/size/size-fine.json +9 -6
  43. package/dist/docs/functional/size/size.json +499 -433
  44. package/dist/docs/functional/size/viewport.json +32 -26
  45. package/dist/docs/functional/themes/dark-colorblind.json +7846 -6530
  46. package/dist/docs/functional/themes/dark-dimmed.json +7774 -6498
  47. package/dist/docs/functional/themes/dark-high-contrast.json +8121 -6737
  48. package/dist/docs/functional/themes/dark-tritanopia.json +7817 -6543
  49. package/dist/docs/functional/themes/dark.json +7772 -6562
  50. package/dist/docs/functional/themes/light-colorblind.json +7753 -6455
  51. package/dist/docs/functional/themes/light-high-contrast.json +7983 -6643
  52. package/dist/docs/functional/themes/light-tritanopia.json +7732 -6454
  53. package/dist/docs/functional/themes/light.json +7658 -6450
  54. package/dist/docs/functional/typography/typography.json +518 -472
  55. package/dist/figma/themes/dark-colorblind.json +5704 -5570
  56. package/dist/figma/themes/dark-dimmed.json +5204 -5122
  57. package/dist/figma/themes/dark-high-contrast.json +4381 -4166
  58. package/dist/figma/themes/dark-tritanopia.json +5354 -5271
  59. package/dist/figma/themes/dark.json +5505 -5504
  60. package/dist/figma/themes/light-colorblind.json +5666 -5567
  61. package/dist/figma/themes/light-high-contrast.json +4277 -4115
  62. package/dist/figma/themes/light-tritanopia.json +5071 -4991
  63. package/dist/figma/themes/light.json +4808 -4808
  64. package/dist/internalCss/dark-colorblind.css +1148 -1148
  65. package/dist/internalCss/dark-dimmed.css +1138 -1138
  66. package/dist/internalCss/dark-high-contrast.css +1154 -1154
  67. package/dist/internalCss/dark-tritanopia.css +1148 -1148
  68. package/dist/internalCss/dark.css +1150 -1150
  69. package/dist/internalCss/light-colorblind.css +1152 -1152
  70. package/dist/internalCss/light-high-contrast.css +1166 -1166
  71. package/dist/internalCss/light-tritanopia.css +1156 -1156
  72. package/dist/internalCss/light.css +1158 -1158
  73. package/dist/styleLint/base/motion/motion.json +97 -82
  74. package/dist/styleLint/base/size/size.json +102 -83
  75. package/dist/styleLint/base/typography/typography.json +16 -12
  76. package/dist/styleLint/functional/motion/motion.json +22 -18
  77. package/dist/styleLint/functional/size/border.json +140 -126
  78. package/dist/styleLint/functional/size/breakpoints.json +32 -26
  79. package/dist/styleLint/functional/size/size-coarse.json +14 -11
  80. package/dist/styleLint/functional/size/size-fine.json +10 -7
  81. package/dist/styleLint/functional/size/size.json +486 -420
  82. package/dist/styleLint/functional/size/viewport.json +36 -30
  83. package/dist/styleLint/functional/themes/dark-colorblind.json +7601 -6285
  84. package/dist/styleLint/functional/themes/dark-dimmed.json +7984 -6708
  85. package/dist/styleLint/functional/themes/dark-high-contrast.json +8150 -6766
  86. package/dist/styleLint/functional/themes/dark-tritanopia.json +7780 -6506
  87. package/dist/styleLint/functional/themes/dark.json +7689 -6479
  88. package/dist/styleLint/functional/themes/light-colorblind.json +7756 -6458
  89. package/dist/styleLint/functional/themes/light-high-contrast.json +8135 -6795
  90. package/dist/styleLint/functional/themes/light-tritanopia.json +7642 -6364
  91. package/dist/styleLint/functional/themes/light.json +7552 -6344
  92. package/dist/styleLint/functional/typography/typography.json +520 -474
  93. package/package.json +2 -2
  94. package/src/tokens/component/diffBlob.json5 +387 -0
  95. package/src/tokens/component/header.json5 +65 -0
  96. package/src/tokens/component/headerSerach.json5 +32 -0
  97. package/src/tokens/component/highlight.json5 +23 -0
  98. package/src/tokens/component/overlay.json5 +68 -0
  99. package/src/tokens/component/page.json5 +20 -0
  100. package/src/tokens/component/reactionButton.json5 +78 -0
  101. package/src/tokens/component/skeletonLoader.json5 +29 -0
  102. package/src/tokens/component/timelineBadge.json5 +19 -0
  103. package/src/tokens/functional/color/dark/app-dark.json5 +0 -399
  104. package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +0 -35
  105. package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +0 -92
  106. package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +5 -63
  107. package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +0 -37
  108. package/src/tokens/functional/color/dark/patterns-dark.json5 +0 -194
  109. package/src/tokens/functional/color/light/app-light.json5 +0 -364
  110. package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +0 -70
  111. package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +15 -76
  112. package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +0 -71
  113. package/src/tokens/functional/color/light/patterns-light.json5 +1 -192
  114. package/dist/figma/figma.json +0 -133
  115. package/dist/figma/shadows/dark-colorblind.json +0 -1152
  116. package/dist/figma/shadows/dark-dimmed.json +0 -1152
  117. package/dist/figma/shadows/dark-high-contrast.json +0 -1152
  118. package/dist/figma/shadows/dark-tritanopia.json +0 -1152
  119. package/dist/figma/shadows/dark.json +0 -1152
  120. package/dist/figma/shadows/light-colorblind.json +0 -1052
  121. package/dist/figma/shadows/light-high-contrast.json +0 -1052
  122. package/dist/figma/shadows/light-tritanopia.json +0 -1052
  123. package/dist/figma/shadows/light.json +0 -1052
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { format } from 'prettier';
11
- import { fileHeader } from 'style-dictionary/utils';
11
+ import { fileHeader, sortByName } from 'style-dictionary/utils';
12
12
  /**
13
13
  * @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media
14
14
  * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
@@ -18,7 +18,7 @@ export const cssCustomMedia = (_a) => __awaiter(void 0, [_a], void 0, function*
18
18
  // add file header
19
19
  const output = [yield fileHeader({ file })];
20
20
  // add single theme css
21
- dictionary.allTokens.map(({ name, $value }) => {
21
+ dictionary.allTokens.sort(sortByName).map(({ name, $value }) => {
22
22
  output.push(`@custom-media --${name} ${$value};`);
23
23
  });
24
24
  // return prettified
@@ -1,5 +1,6 @@
1
1
  import { format } from 'prettier';
2
2
  import { jsonToFlat } from './utilities/jsonToFlat.js';
3
+ import { sortByName } from 'style-dictionary/utils';
3
4
  /**
4
5
  * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
5
6
  * @param FormatFnArguments
@@ -9,7 +10,7 @@ import { jsonToFlat } from './utilities/jsonToFlat.js';
9
10
  export const jsonOneDimensional = ({ dictionary, file: _file, options }) => {
10
11
  // option to allow verbose output (object) or just the value
11
12
  const { outputVerbose, propertyConversion } = options;
12
- const tokens = jsonToFlat(dictionary.allTokens, outputVerbose);
13
+ const tokens = jsonToFlat(dictionary.allTokens.sort(sortByName), outputVerbose);
13
14
  if (propertyConversion === undefined) {
14
15
  //
15
16
  const output = JSON.stringify(tokens, null, 2);
@@ -1,4 +1,5 @@
1
1
  import { isFromFile, isSource } from '../filters/index.js';
2
+ import { outputReferencesTransformed, outputReferencesFilter } from 'style-dictionary/utils';
2
3
  const getCssSelectors = (outputFile) => {
3
4
  // check for dark in the beginning of the output filename
4
5
  const lastSlash = outputFile.lastIndexOf('/');
@@ -49,7 +50,7 @@ export const css = (outputFile, prefix, buildPath, options) => {
49
50
  'src/tokens/functional/size/size-coarse.json5',
50
51
  'src/tokens/functional/size/size-fine.json5',
51
52
  ]),
52
- options: Object.assign({ showFileHeader: false, outputReferences: false, descriptions: false, queries: getCssSelectors(outputFile) }, options === null || options === void 0 ? void 0 : options.options),
53
+ options: Object.assign({ showFileHeader: false, outputReferences: (token, platformOptions) => outputReferencesFilter(token, platformOptions) && outputReferencesTransformed(token, platformOptions), descriptions: false, queries: getCssSelectors(outputFile) }, options === null || options === void 0 ? void 0 : options.options),
53
54
  },
54
55
  {
55
56
  destination: `${outputFile}`,
@@ -61,7 +62,7 @@ export const css = (outputFile, prefix, buildPath, options) => {
61
62
  'src/tokens/functional/size/size-coarse.json5',
62
63
  'src/tokens/functional/size/size-fine.json5',
63
64
  ]),
64
- options: Object.assign({ showFileHeader: false, descriptions: false }, options === null || options === void 0 ? void 0 : options.options),
65
+ options: Object.assign({ showFileHeader: false, outputReferences: (token, platformOptions) => outputReferencesFilter(token, platformOptions) && outputReferencesTransformed(token, platformOptions), descriptions: false }, options === null || options === void 0 ? void 0 : options.options),
65
66
  },
66
67
  {
67
68
  destination: `${outputFile}`,
@@ -69,6 +70,7 @@ export const css = (outputFile, prefix, buildPath, options) => {
69
70
  filter: token => isSource(token) && (options === null || options === void 0 ? void 0 : options.themed) !== true && token.$type === 'custom-viewportRange',
70
71
  options: {
71
72
  showFileHeader: false,
73
+ outputReferences: (token, platformOptions) => outputReferencesFilter(token, platformOptions) && outputReferencesTransformed(token, platformOptions),
72
74
  },
73
75
  },
74
76
  {
@@ -81,6 +83,7 @@ export const css = (outputFile, prefix, buildPath, options) => {
81
83
  ]),
82
84
  options: {
83
85
  descriptions: false,
86
+ outputReferences: (token, platformOptions) => outputReferencesFilter(token, platformOptions) && outputReferencesTransformed(token, platformOptions),
84
87
  showFileHeader: false,
85
88
  queries: [
86
89
  {
@@ -24,40 +24,44 @@ const validFigmaToken = (token, options) => __awaiter(void 0, void 0, void 0, fu
24
24
  // is a color or dimension type
25
25
  return validTypes.includes(token.$type);
26
26
  });
27
- export const figma = (outputFile, prefix, buildPath, options) => ({
28
- prefix,
29
- buildPath,
30
- preprocessors: ['themeOverrides'],
31
- transforms: [
32
- 'color/rgbaFloat',
33
- 'fontFamily/figma',
34
- 'float/pixelUnitless',
35
- 'dimension/pixelUnitless',
36
- // 'border/figma',
37
- // 'typography/figma',
38
- 'fontWeight/number',
39
- 'figma/attributes',
40
- 'name/pathToFigma',
41
- ],
42
- options: Object.assign(Object.assign({ basePxFontSize: 16, fontFamilies: {
43
- 'fontStack/system': 'SF Pro Text',
44
- 'fontStack/sansSerif': 'SF Pro Text',
45
- 'fontStack/sansSerifDisplay': 'SF Pro Display',
46
- 'fontStack/monospace': 'SF Mono',
47
- } }, options), { themeOverrides: {
48
- theme: options === null || options === void 0 ? void 0 : options.theme,
49
- } }),
50
- files: [
51
- {
52
- destination: outputFile,
53
- filter: (token, config) => {
54
- return validFigmaToken(token, config);
27
+ export const figma = (outputFile, prefix, buildPath, options = {}) => {
28
+ const { theme } = options;
29
+ const figmaTheme = ((theme === null || theme === void 0 ? void 0 : theme[0]) || '').replaceAll('-', ' ');
30
+ return {
31
+ prefix,
32
+ buildPath,
33
+ preprocessors: ['themeOverrides'],
34
+ transforms: [
35
+ 'color/rgbaFloat',
36
+ 'fontFamily/figma',
37
+ 'float/pixelUnitless',
38
+ 'dimension/pixelUnitless',
39
+ // 'border/figma',
40
+ // 'typography/figma',
41
+ 'fontWeight/number',
42
+ 'figma/attributes',
43
+ 'name/pathToFigma',
44
+ ],
45
+ options: Object.assign(Object.assign({ basePxFontSize: 16, fontFamilies: {
46
+ 'fontStack/system': 'SF Pro Text',
47
+ 'fontStack/sansSerif': 'SF Pro Text',
48
+ 'fontStack/sansSerifDisplay': 'SF Pro Display',
49
+ 'fontStack/monospace': 'SF Mono',
50
+ } }, options), { theme: figmaTheme, themeOverrides: {
51
+ theme: options.theme,
52
+ } }),
53
+ files: [
54
+ {
55
+ destination: outputFile,
56
+ filter: (token, config) => {
57
+ return validFigmaToken(token, config);
58
+ },
59
+ format: `json/figma`,
60
+ options: {
61
+ outputReferences: true,
62
+ theme: figmaTheme,
63
+ },
55
64
  },
56
- format: `json/figma`,
57
- options: {
58
- outputReferences: true,
59
- theme: options === null || options === void 0 ? void 0 : options.theme,
60
- },
61
- },
62
- ],
63
- });
65
+ ],
66
+ };
67
+ };
@@ -1,19 +1,22 @@
1
1
  import { transformTokens } from './utilities/transformTokens.js';
2
+ import { asArray } from '../utilities/asArray.js';
2
3
  export const themeOverrides = {
3
4
  name: 'themeOverrides',
4
5
  preprocessor: (dictionary, config) => {
5
6
  var _a, _b, _c, _d, _e, _f;
6
7
  const extensionProp = ((_b = (_a = config.options) === null || _a === void 0 ? void 0 : _a.themeOverrides) === null || _b === void 0 ? void 0 : _b.extensionProp) || 'org.primer.overrides';
7
8
  const valueProp = ((_d = (_c = config.options) === null || _c === void 0 ? void 0 : _c.themeOverrides) === null || _d === void 0 ? void 0 : _d.valueProp) || '$value';
8
- const currentTheme = (_f = (_e = config.options) === null || _e === void 0 ? void 0 : _e.themeOverrides) === null || _f === void 0 ? void 0 : _f.theme;
9
+ const [currentTheme, fallbackTheme] = asArray((_f = (_e = config.options) === null || _e === void 0 ? void 0 : _e.themeOverrides) === null || _f === void 0 ? void 0 : _f.theme);
9
10
  const tokens = transformTokens(dictionary, token => {
10
- var _a, _b, _c;
11
+ var _a, _b, _c, _d, _e;
11
12
  // return early if no theme value is set
12
- if (!currentTheme || !((_a = token.$extensions) === null || _a === void 0 ? void 0 : _a[extensionProp]) || !((_b = token.$extensions) === null || _b === void 0 ? void 0 : _b[extensionProp][currentTheme])) {
13
+ if (!currentTheme ||
14
+ !((_a = token.$extensions) === null || _a === void 0 ? void 0 : _a[extensionProp]) ||
15
+ (!((_b = token.$extensions) === null || _b === void 0 ? void 0 : _b[extensionProp][currentTheme]) && !((_c = token.$extensions) === null || _c === void 0 ? void 0 : _c[extensionProp][fallbackTheme]))) {
13
16
  return token;
14
17
  }
15
18
  // get override
16
- const override = (_c = token.$extensions) === null || _c === void 0 ? void 0 : _c[extensionProp][currentTheme];
19
+ const override = ((_d = token.$extensions) === null || _d === void 0 ? void 0 : _d[extensionProp][currentTheme]) || ((_e = token.$extensions) === null || _e === void 0 ? void 0 : _e[extensionProp][fallbackTheme]);
17
20
  // token an theme value exist
18
21
  return Object.assign(Object.assign({}, token), (typeof override === 'object' ? override : { [valueProp]: override }));
19
22
  });
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  type Collections = 'base/color/light' | 'base/color/light-high-contrast' | 'base/color/dark' | 'base/color/dark-dimmed' | 'base/color/dark-high-contrast' | 'base/typography' | 'mode' | 'pattern/mode' | 'base/size' | 'functional/size' | 'pattern/size' | 'typography';
3
3
  export declare const collection: (collections: Collections[]) => z.ZodEffects<z.ZodString, string, string>;
4
- type Modes = 'light' | 'dark' | 'dark dimmed' | 'light high contrast' | 'dark high contrast' | 'light colorblind' | 'dark colorblind' | 'light tritanopia' | 'dark tritanopia';
4
+ type Modes = 'light' | 'dark' | 'dark dimmed' | 'light high contrast' | 'dark high contrast' | 'light protanopia deuteranopia' | 'dark protanopia deuteranopia' | 'light tritanopia' | 'dark tritanopia';
5
5
  export declare const mode: (modes: Modes[]) => z.ZodEffects<z.ZodString, string, string>;
6
6
  export {};