@primer/primitives 7.17.0-rc.8ff6ed39 → 7.17.0-rc.8fffddc7

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 (136) hide show
  1. package/README.md +1 -1
  2. package/dist/css/functional/themes/dark-colorblind.css +10 -0
  3. package/dist/css/functional/themes/dark-dimmed.css +10 -0
  4. package/dist/css/functional/themes/dark-high-contrast.css +10 -0
  5. package/dist/css/functional/themes/dark-tritanopia.css +10 -0
  6. package/dist/css/functional/themes/dark.css +10 -0
  7. package/dist/css/functional/themes/light-colorblind.css +10 -0
  8. package/dist/css/functional/themes/light-high-contrast.css +10 -0
  9. package/dist/css/functional/themes/light-tritanopia.css +10 -0
  10. package/dist/css/functional/themes/light.css +10 -0
  11. package/dist/css/functional/typography/typography.css +1 -1
  12. package/dist/docs/base/typography/typography.json +52 -4
  13. package/dist/docs/functional/themes/dark-colorblind.json +145 -0
  14. package/dist/docs/functional/themes/dark-dimmed.json +145 -0
  15. package/dist/docs/functional/themes/dark-high-contrast.json +145 -0
  16. package/dist/docs/functional/themes/dark-tritanopia.json +145 -0
  17. package/dist/docs/functional/themes/dark.json +145 -0
  18. package/dist/docs/functional/themes/light-colorblind.json +145 -0
  19. package/dist/docs/functional/themes/light-high-contrast.json +145 -0
  20. package/dist/docs/functional/themes/light-tritanopia.json +145 -0
  21. package/dist/docs/functional/themes/light.json +145 -0
  22. package/dist/docs/functional/typography/typography.json +494 -36
  23. package/dist/fallbacks/functional/typography/typography.json +1 -1
  24. package/dist/figma/figma.json +18 -1
  25. package/dist/figma/themes/dark-colorblind.json +80 -0
  26. package/dist/figma/themes/dark-dimmed.json +80 -0
  27. package/dist/figma/themes/dark-high-contrast.json +80 -0
  28. package/dist/figma/themes/dark-tritanopia.json +80 -0
  29. package/dist/figma/themes/dark.json +80 -0
  30. package/dist/figma/themes/light-colorblind.json +80 -0
  31. package/dist/figma/themes/light-high-contrast.json +80 -0
  32. package/dist/figma/themes/light-tritanopia.json +80 -0
  33. package/dist/figma/themes/light.json +80 -0
  34. package/dist/figma/typography/typography.json +370 -0
  35. package/dist/internalCss/dark-colorblind.css +10 -0
  36. package/dist/internalCss/dark-dimmed.css +10 -0
  37. package/dist/internalCss/dark-high-contrast.css +10 -0
  38. package/dist/internalCss/dark-tritanopia.css +10 -0
  39. package/dist/internalCss/dark.css +10 -0
  40. package/dist/internalCss/light-colorblind.css +10 -0
  41. package/dist/internalCss/light-high-contrast.css +10 -0
  42. package/dist/internalCss/light-tritanopia.css +10 -0
  43. package/dist/internalCss/light.css +10 -0
  44. package/dist/styleLint/base/typography/typography.json +52 -4
  45. package/dist/styleLint/functional/themes/dark-colorblind.json +145 -0
  46. package/dist/styleLint/functional/themes/dark-dimmed.json +145 -0
  47. package/dist/styleLint/functional/themes/dark-high-contrast.json +145 -0
  48. package/dist/styleLint/functional/themes/dark-tritanopia.json +145 -0
  49. package/dist/styleLint/functional/themes/dark.json +145 -0
  50. package/dist/styleLint/functional/themes/light-colorblind.json +145 -0
  51. package/dist/styleLint/functional/themes/light-high-contrast.json +145 -0
  52. package/dist/styleLint/functional/themes/light-tritanopia.json +145 -0
  53. package/dist/styleLint/functional/themes/light.json +145 -0
  54. package/dist/styleLint/functional/typography/typography.json +494 -36
  55. package/package.json +4 -11
  56. package/src/PrimerStyleDictionary.ts +12 -0
  57. package/src/filters/index.ts +1 -0
  58. package/src/filters/isNumber.ts +8 -0
  59. package/src/formats/jsonFigma.ts +1 -0
  60. package/src/platforms/figma.ts +10 -1
  61. package/src/schemas/numberToken.ts +17 -0
  62. package/src/tokens/base/typography/typography.json +28 -4
  63. package/src/tokens/functional/color/dark/display-dark.json5 +66 -0
  64. package/src/tokens/functional/color/light/display-light.json5 +66 -0
  65. package/src/tokens/functional/typography/typography.json +263 -34
  66. package/src/transformers/floatToPixel.ts +33 -0
  67. package/src/transformers/fontFamilyToCss.ts +3 -4
  68. package/src/transformers/fontFamilyToFigma.ts +47 -0
  69. package/src/transformers/index.ts +2 -0
  70. package/src/transformers/utilities/hasSpaceInString.ts +6 -0
  71. package/build.js +0 -578
  72. package/tokens/base/size/size.json +0 -57
  73. package/tokens/base/typography/typography.json +0 -20
  74. package/tokens/functional/size/border.json +0 -48
  75. package/tokens/functional/size/breakpoints.json +0 -24
  76. package/tokens/functional/size/size-coarse.json +0 -27
  77. package/tokens/functional/size/size-fine.json +0 -27
  78. package/tokens/functional/size/size.json +0 -189
  79. package/tokens/functional/size/viewport.json +0 -24
  80. package/tokens/functional/typography/typography.json +0 -213
  81. package/tokens/removed/color.json +0 -421
  82. package/tokens-v2-private/css/tokens/base/size/size.css +0 -24
  83. package/tokens-v2-private/css/tokens/base/typography/typography.css +0 -11
  84. package/tokens-v2-private/css/tokens/functional/size/border.css +0 -17
  85. package/tokens-v2-private/css/tokens/functional/size/breakpoints.css +0 -13
  86. package/tokens-v2-private/css/tokens/functional/size/size-coarse.css +0 -11
  87. package/tokens-v2-private/css/tokens/functional/size/size-fine.css +0 -11
  88. package/tokens-v2-private/css/tokens/functional/size/size.css +0 -54
  89. package/tokens-v2-private/css/tokens/functional/size/viewport.css +0 -6
  90. package/tokens-v2-private/css/tokens/functional/typography/typography.css +0 -47
  91. package/tokens-v2-private/docs/docValues.json +0 -2209
  92. package/tokens-v2-private/js/module/tokens/base/size/size.js +0 -266
  93. package/tokens-v2-private/js/module/tokens/base/typography/typography.js +0 -77
  94. package/tokens-v2-private/js/module/tokens/functional/size/border.js +0 -165
  95. package/tokens-v2-private/js/module/tokens/functional/size/breakpoints.js +0 -101
  96. package/tokens-v2-private/js/module/tokens/functional/size/size-coarse.js +0 -73
  97. package/tokens-v2-private/js/module/tokens/functional/size/size-fine.js +0 -73
  98. package/tokens-v2-private/js/module/tokens/functional/size/size.js +0 -824
  99. package/tokens-v2-private/js/module/tokens/functional/size/viewport.js +0 -101
  100. package/tokens-v2-private/js/module/tokens/functional/typography/typography.js +0 -809
  101. package/tokens-v2-private/js/tokens/base/size/size.js +0 -22
  102. package/tokens-v2-private/js/tokens/base/typography/typography.js +0 -9
  103. package/tokens-v2-private/js/tokens/functional/size/border.js +0 -15
  104. package/tokens-v2-private/js/tokens/functional/size/breakpoints.js +0 -11
  105. package/tokens-v2-private/js/tokens/functional/size/size-coarse.js +0 -8
  106. package/tokens-v2-private/js/tokens/functional/size/size-fine.js +0 -8
  107. package/tokens-v2-private/js/tokens/functional/size/size.js +0 -52
  108. package/tokens-v2-private/js/tokens/functional/size/viewport.js +0 -11
  109. package/tokens-v2-private/js/tokens/functional/typography/typography.js +0 -45
  110. package/tokens-v2-private/scss/tokens/base/size/size.scss +0 -21
  111. package/tokens-v2-private/scss/tokens/base/typography/typography.scss +0 -8
  112. package/tokens-v2-private/scss/tokens/functional/size/border.scss +0 -14
  113. package/tokens-v2-private/scss/tokens/functional/size/breakpoints.scss +0 -10
  114. package/tokens-v2-private/scss/tokens/functional/size/size-coarse.scss +0 -7
  115. package/tokens-v2-private/scss/tokens/functional/size/size-fine.scss +0 -7
  116. package/tokens-v2-private/scss/tokens/functional/size/size.scss +0 -51
  117. package/tokens-v2-private/scss/tokens/functional/size/viewport.scss +0 -10
  118. package/tokens-v2-private/scss/tokens/functional/typography/typography.scss +0 -44
  119. package/tokens-v2-private/ts/tokens/base/size/size.d.ts +0 -31
  120. package/tokens-v2-private/ts/tokens/base/size/size.js +0 -30
  121. package/tokens-v2-private/ts/tokens/base/typography/typography.d.ts +0 -20
  122. package/tokens-v2-private/ts/tokens/base/typography/typography.js +0 -19
  123. package/tokens-v2-private/ts/tokens/functional/size/border.d.ts +0 -28
  124. package/tokens-v2-private/ts/tokens/functional/size/border.js +0 -27
  125. package/tokens-v2-private/ts/tokens/functional/size/breakpoints.d.ts +0 -20
  126. package/tokens-v2-private/ts/tokens/functional/size/breakpoints.js +0 -19
  127. package/tokens-v2-private/ts/tokens/functional/size/size-coarse.d.ts +0 -29
  128. package/tokens-v2-private/ts/tokens/functional/size/size-coarse.js +0 -28
  129. package/tokens-v2-private/ts/tokens/functional/size/size-fine.d.ts +0 -29
  130. package/tokens-v2-private/ts/tokens/functional/size/size-fine.js +0 -28
  131. package/tokens-v2-private/ts/tokens/functional/size/size.d.ts +0 -103
  132. package/tokens-v2-private/ts/tokens/functional/size/size.js +0 -102
  133. package/tokens-v2-private/ts/tokens/functional/size/viewport.d.ts +0 -20
  134. package/tokens-v2-private/ts/tokens/functional/size/viewport.js +0 -19
  135. package/tokens-v2-private/ts/tokens/functional/typography/typography.d.ts +0 -131
  136. package/tokens-v2-private/ts/tokens/functional/typography/typography.js +0 -130
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@primer/primitives",
3
- "version": "7.17.0-rc.8ff6ed39",
3
+ "version": "7.17.0-rc.8fffddc7",
4
4
  "description": "Typography, spacing, and color primitives for Primer design system",
5
5
  "files": [
6
6
  "dist",
7
- "tokens-v2-private",
8
- "build.js",
9
- "tokens/",
10
7
  "src/**/*",
11
8
  "!src/**/*.test.ts"
12
9
  ],
@@ -33,8 +30,6 @@
33
30
  "build:v8": "ts-node ./scripts/buildTokens.ts",
34
31
  "build:fallbacks": "ts-node ./scripts/buildFallbacks.ts",
35
32
  "build:figma": "ts-node scripts/buildFigma.ts",
36
- "build:tokens": "node -e \"require('./build')._init()\"",
37
- "build:new-tokens": "npm run build:tokens && npm run build:next && npm run build:figma",
38
33
  "tokenJson:check": "ts-node scripts/diffThemes.ts && ts-node scripts/diffTokenProps.ts",
39
34
  "contrast:check": "ts-node scripts/color-contrast.ts",
40
35
  "format": "prettier --write '**/*.{js,jsx,ts,tsx,md,mdx,css}'",
@@ -44,14 +39,12 @@
44
39
  "lint:fix": "eslint '**/*.{js,ts,tsx,md,mdx}' --fix --max-warnings=0 --config .eslintrc.js",
45
40
  "lint:tokens": "ts-node ./scripts/validateTokenJson.ts",
46
41
  "prebuild": "rm -rf dist",
47
- "prebuild:tokens": "rm -rf tokens-v2-private",
48
42
  "prebuild:next": "rm -rf dist",
49
- "prepack": "npm run build && npm run build:tokens && npm run build:next",
43
+ "prepack": "npm run build && npm run build:next",
50
44
  "prepare": "husky",
51
45
  "release": "changeset publish",
52
- "start:storybook": "npm run build:next && cd docs/storybook && npm run storybook",
53
- "test": "jest --verbose --coverage",
54
- "watch": "ls data/**/*.scss scripts/**/*.ts | entr -s 'npm run build'"
46
+ "start:storybook": "npm run build && cd docs/storybook && npm run storybook",
47
+ "test": "jest --verbose --coverage"
55
48
  },
56
49
  "prettier": "@github/prettier-config",
57
50
  "devDependencies": {
@@ -12,6 +12,7 @@ import {
12
12
  durationToCss,
13
13
  figmaAttributes,
14
14
  fontFamilyToCss,
15
+ fontFamilyToFigma,
15
16
  fontWeightToNumber,
16
17
  jsonDeprecated,
17
18
  namePathToDotNotation,
@@ -22,6 +23,7 @@ import {
22
23
  shadowToCss,
23
24
  typographyToCss,
24
25
  dimensionToRemPxArray,
26
+ floatToPixel,
25
27
  } from './transformers'
26
28
  import {
27
29
  javascriptCommonJs,
@@ -131,6 +133,11 @@ StyleDictionary.registerTransform({
131
133
  ...colorToHex,
132
134
  })
133
135
 
136
+ StyleDictionary.registerTransform({
137
+ name: 'float/pixel',
138
+ ...floatToPixel,
139
+ })
140
+
134
141
  StyleDictionary.registerTransform({
135
142
  name: 'dimension/rem',
136
143
  ...dimensionToRem,
@@ -216,6 +223,11 @@ StyleDictionary.registerTransform({
216
223
  ...fontFamilyToCss,
217
224
  })
218
225
 
226
+ StyleDictionary.registerTransform({
227
+ name: 'fontFamily/figma',
228
+ ...fontFamilyToFigma,
229
+ })
230
+
219
231
  /**
220
232
  * @name {@link PrimerStyleDictionary}
221
233
  * @description Returns style dictionary object with primer preset that includes parsers, formats and transformers
@@ -7,6 +7,7 @@ export {isDeprecated} from './isDeprecated'
7
7
  export {isFromFile} from './isFromFile'
8
8
  export {isFontFamily} from './isFontFamily'
9
9
  export {isFontWeight} from './isFontWeight'
10
+ export {isNumber} from './isNumber'
10
11
  export {isShadow} from './isShadow'
11
12
  export {isSource} from './isSource'
12
13
  export {isTypography} from './isTypography'
@@ -0,0 +1,8 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ /**
4
+ * @description Checks if token type is a number
5
+ * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
6
+ * @returns boolean
7
+ */
8
+ export const isNumber = (token: StyleDictionary.TransformedToken): boolean => token.$type === 'number'
@@ -28,6 +28,7 @@ const getFigmaType = (type: string): string => {
28
28
  color: 'COLOR',
29
29
  dimension: 'FLOAT',
30
30
  fontWeight: 'FLOAT',
31
+ number: 'FLOAT',
31
32
  fontFamily: 'STRING',
32
33
  }
33
34
  if (type in validTypes) return validTypes[type as keyof typeof validTypes]
@@ -3,9 +3,11 @@ import type {PlatformInitializer} from '../types/PlatformInitializer'
3
3
  import {isSource} from '../filters'
4
4
 
5
5
  const validFigmaToken = (token: StyleDictionary.TransformedToken) => {
6
- const validTypes = ['color', 'dimension', 'shadow', 'fontWeight', 'fontFamily']
6
+ const validTypes = ['color', 'dimension', 'shadow', 'fontWeight', 'fontFamily', 'number']
7
7
  // is a siource token, not an included one
8
8
  if (!isSource(token)) return false
9
+
10
+ if (`${token.value}`.substring(token.value.length - 2) === 'em') return false
9
11
  // has a collection attribute
10
12
  if (
11
13
  !('$extensions' in token) ||
@@ -25,6 +27,8 @@ export const figma: PlatformInitializer = (outputFile, prefix, buildPath, option
25
27
  'name/pathToFigma',
26
28
  // 'name/pathToSlashNotation',
27
29
  'figma/attributes',
30
+ 'fontFamily/figma',
31
+ 'float/pixel',
28
32
  'dimension/pixelUnitless',
29
33
  // 'border/figma',
30
34
  // 'typography/figma',
@@ -32,6 +36,11 @@ export const figma: PlatformInitializer = (outputFile, prefix, buildPath, option
32
36
  ],
33
37
  options: {
34
38
  basePxFontSize: 16,
39
+ fontFamilies: {
40
+ 'fontStack/system': 'SF Pro Text',
41
+ 'fontStack/sansSerif': 'SF Pro Text',
42
+ 'fontStack/monospace': 'SF Mono',
43
+ },
35
44
  ...options,
36
45
  },
37
46
  files: [
@@ -2,10 +2,27 @@ import {z} from 'zod'
2
2
  import {baseToken} from './baseToken'
3
3
  import {referenceValue} from './referenceValue'
4
4
  import {tokenType} from './tokenType'
5
+ import {scopes} from './scopes'
6
+ import {collection} from './collections'
5
7
 
6
8
  export const numberToken = baseToken
7
9
  .extend({
8
10
  $value: z.union([z.number(), referenceValue]),
9
11
  $type: tokenType('number'),
12
+ $extensions: z
13
+ .object({
14
+ 'org.primer.data': z
15
+ .object({
16
+ fontSize: z.number().optional(),
17
+ })
18
+ .optional(),
19
+ 'org.primer.figma': z
20
+ .object({
21
+ collection: collection(['typography']).optional(),
22
+ scopes: scopes(['all']).optional(),
23
+ })
24
+ .optional(),
25
+ })
26
+ .optional(),
10
27
  })
11
28
  .strict()
@@ -4,19 +4,43 @@
4
4
  "weight": {
5
5
  "light": {
6
6
  "$type": "fontWeight",
7
- "$value": 300
7
+ "$value": 300,
8
+ "$extensions": {
9
+ "org.primer.figma": {
10
+ "collection": "base/typography",
11
+ "scopes": ["all"]
12
+ }
13
+ }
8
14
  },
9
15
  "normal": {
10
16
  "$value": 400,
11
- "$type": "fontWeight"
17
+ "$type": "fontWeight",
18
+ "$extensions": {
19
+ "org.primer.figma": {
20
+ "collection": "base/typography",
21
+ "scopes": ["all"]
22
+ }
23
+ }
12
24
  },
13
25
  "medium": {
14
26
  "$value": 500,
15
- "$type": "fontWeight"
27
+ "$type": "fontWeight",
28
+ "$extensions": {
29
+ "org.primer.figma": {
30
+ "collection": "base/typography",
31
+ "scopes": ["all"]
32
+ }
33
+ }
16
34
  },
17
35
  "semibold": {
18
36
  "$value": 600,
19
- "$type": "fontWeight"
37
+ "$type": "fontWeight",
38
+ "$extensions": {
39
+ "org.primer.figma": {
40
+ "collection": "base/typography",
41
+ "scopes": ["all"]
42
+ }
43
+ }
20
44
  }
21
45
  }
22
46
  }
@@ -1056,5 +1056,71 @@
1056
1056
  },
1057
1057
  },
1058
1058
  },
1059
+ pink: {
1060
+ bgColor: {
1061
+ muted: {
1062
+ $value: '{base.display.color.pink.0}',
1063
+ $type: 'color',
1064
+ $extensions: {
1065
+ 'org.primer.figma': {
1066
+ collection: 'mode',
1067
+ mode: 'light',
1068
+ group: 'component (internal)',
1069
+ scopes: ['bgColor'],
1070
+ },
1071
+ },
1072
+ },
1073
+ emphasis: {
1074
+ $value: '{base.display.color.pink.5}',
1075
+ $type: 'color',
1076
+ $extensions: {
1077
+ 'org.primer.figma': {
1078
+ collection: 'mode',
1079
+ mode: 'light',
1080
+ group: 'component (internal)',
1081
+ scopes: ['bgColor'],
1082
+ },
1083
+ },
1084
+ },
1085
+ },
1086
+ fgColor: {
1087
+ $value: '{base.display.color.pink.6}',
1088
+ $type: 'color',
1089
+ $extensions: {
1090
+ 'org.primer.figma': {
1091
+ collection: 'mode',
1092
+ mode: 'light',
1093
+ group: 'component (internal)',
1094
+ scopes: ['fgColor'],
1095
+ },
1096
+ },
1097
+ },
1098
+ borderColor: {
1099
+ muted: {
1100
+ $value: '{base.display.color.pink.1}',
1101
+ $type: 'color',
1102
+ $extensions: {
1103
+ 'org.primer.figma': {
1104
+ collection: 'mode',
1105
+ mode: 'light',
1106
+ group: 'component (internal)',
1107
+ scopes: ['borderColor'],
1108
+ },
1109
+ },
1110
+ },
1111
+ emphasis: {
1112
+ $value: '{base.display.color.pink.5}',
1113
+ $type: 'color',
1114
+ $extensions: {
1115
+ 'org.primer.figma': {
1116
+ collection: 'mode',
1117
+ mode: 'light',
1118
+ group: 'component (internal)',
1119
+ scopes: ['borderColor'],
1120
+ },
1121
+ },
1122
+ },
1123
+ },
1124
+ },
1059
1125
  },
1060
1126
  }
@@ -1056,5 +1056,71 @@
1056
1056
  },
1057
1057
  },
1058
1058
  },
1059
+ pink: {
1060
+ bgColor: {
1061
+ muted: {
1062
+ $value: '{base.display.color.pink.0}',
1063
+ $type: 'color',
1064
+ $extensions: {
1065
+ 'org.primer.figma': {
1066
+ collection: 'mode',
1067
+ mode: 'light',
1068
+ group: 'component (internal)',
1069
+ scopes: ['bgColor'],
1070
+ },
1071
+ },
1072
+ },
1073
+ emphasis: {
1074
+ $value: '{base.display.color.pink.5}',
1075
+ $type: 'color',
1076
+ $extensions: {
1077
+ 'org.primer.figma': {
1078
+ collection: 'mode',
1079
+ mode: 'light',
1080
+ group: 'component (internal)',
1081
+ scopes: ['bgColor'],
1082
+ },
1083
+ },
1084
+ },
1085
+ },
1086
+ fgColor: {
1087
+ $value: '{base.display.color.pink.6}',
1088
+ $type: 'color',
1089
+ $extensions: {
1090
+ 'org.primer.figma': {
1091
+ collection: 'mode',
1092
+ mode: 'light',
1093
+ group: 'component (internal)',
1094
+ scopes: ['fgColor'],
1095
+ },
1096
+ },
1097
+ },
1098
+ borderColor: {
1099
+ muted: {
1100
+ $value: '{base.display.color.pink.1}',
1101
+ $type: 'color',
1102
+ $extensions: {
1103
+ 'org.primer.figma': {
1104
+ collection: 'mode',
1105
+ mode: 'light',
1106
+ group: 'component (internal)',
1107
+ scopes: ['borderColor'],
1108
+ },
1109
+ },
1110
+ },
1111
+ emphasis: {
1112
+ $value: '{base.display.color.pink.5}',
1113
+ $type: 'color',
1114
+ $extensions: {
1115
+ 'org.primer.figma': {
1116
+ collection: 'mode',
1117
+ mode: 'light',
1118
+ group: 'component (internal)',
1119
+ scopes: ['borderColor'],
1120
+ },
1121
+ },
1122
+ },
1123
+ },
1124
+ },
1059
1125
  },
1060
1126
  }