@primer/primitives 7.17.0-rc.61b28bca → 7.17.0-rc.8ff6ed39

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 (303) hide show
  1. package/dist/css/functional/themes/dark-colorblind.css +14 -14
  2. package/dist/css/functional/themes/dark-tritanopia.css +14 -14
  3. package/dist/css/functional/themes/dark.css +14 -14
  4. package/dist/docs/functional/themes/dark-colorblind.json +7 -7
  5. package/dist/docs/functional/themes/dark-tritanopia.json +7 -7
  6. package/dist/docs/functional/themes/dark.json +7 -7
  7. package/dist/figma/scales/dark.json +5 -5
  8. package/dist/figma/themes/dark-colorblind.json +20 -20
  9. package/dist/figma/themes/dark-tritanopia.json +20 -20
  10. package/dist/figma/themes/dark.json +20 -20
  11. package/dist/internalCss/dark-colorblind.css +18 -18
  12. package/dist/internalCss/dark-tritanopia.css +18 -18
  13. package/dist/internalCss/dark.css +18 -18
  14. package/dist/styleLint/functional/themes/dark-colorblind.json +7 -7
  15. package/dist/styleLint/functional/themes/dark-tritanopia.json +7 -7
  16. package/dist/styleLint/functional/themes/dark.json +7 -7
  17. package/package.json +2 -3
  18. package/src/formats/jsonFigma.ts +2 -0
  19. package/src/platforms/figma.ts +1 -1
  20. package/src/schemas/collections.ts +2 -0
  21. package/src/schemas/dimensionToken.ts +1 -1
  22. package/src/schemas/fontFamilyToken.ts +10 -0
  23. package/src/schemas/fontWeightToken.ts +10 -0
  24. package/src/tokens/base/color/dark/dark.json5 +2 -2
  25. package/tokens-v2-private/css/tokens/base/size/size.css +1 -1
  26. package/tokens-v2-private/css/tokens/base/typography/typography.css +1 -1
  27. package/tokens-v2-private/css/tokens/functional/size/border.css +1 -1
  28. package/tokens-v2-private/css/tokens/functional/size/breakpoints.css +1 -1
  29. package/tokens-v2-private/css/tokens/functional/size/size-coarse.css +1 -1
  30. package/tokens-v2-private/css/tokens/functional/size/size-fine.css +1 -1
  31. package/tokens-v2-private/css/tokens/functional/size/size.css +1 -1
  32. package/tokens-v2-private/css/tokens/functional/typography/typography.css +1 -1
  33. package/tokens-v2-private/js/module/tokens/base/size/size.js +1 -1
  34. package/tokens-v2-private/js/module/tokens/base/typography/typography.js +1 -1
  35. package/tokens-v2-private/js/module/tokens/functional/size/border.js +1 -1
  36. package/tokens-v2-private/js/module/tokens/functional/size/breakpoints.js +1 -1
  37. package/tokens-v2-private/js/module/tokens/functional/size/size-coarse.js +1 -1
  38. package/tokens-v2-private/js/module/tokens/functional/size/size-fine.js +1 -1
  39. package/tokens-v2-private/js/module/tokens/functional/size/size.js +1 -1
  40. package/tokens-v2-private/js/module/tokens/functional/size/viewport.js +1 -1
  41. package/tokens-v2-private/js/module/tokens/functional/typography/typography.js +1 -1
  42. package/tokens-v2-private/js/tokens/base/size/size.js +1 -1
  43. package/tokens-v2-private/js/tokens/base/typography/typography.js +1 -1
  44. package/tokens-v2-private/js/tokens/functional/size/border.js +1 -1
  45. package/tokens-v2-private/js/tokens/functional/size/breakpoints.js +1 -1
  46. package/tokens-v2-private/js/tokens/functional/size/size-coarse.js +1 -1
  47. package/tokens-v2-private/js/tokens/functional/size/size-fine.js +1 -1
  48. package/tokens-v2-private/js/tokens/functional/size/size.js +1 -1
  49. package/tokens-v2-private/js/tokens/functional/size/viewport.js +1 -1
  50. package/tokens-v2-private/js/tokens/functional/typography/typography.js +1 -1
  51. package/tokens-v2-private/scss/tokens/base/size/size.scss +1 -1
  52. package/tokens-v2-private/scss/tokens/base/typography/typography.scss +1 -1
  53. package/tokens-v2-private/scss/tokens/functional/size/border.scss +1 -1
  54. package/tokens-v2-private/scss/tokens/functional/size/breakpoints.scss +1 -1
  55. package/tokens-v2-private/scss/tokens/functional/size/size-coarse.scss +1 -1
  56. package/tokens-v2-private/scss/tokens/functional/size/size-fine.scss +1 -1
  57. package/tokens-v2-private/scss/tokens/functional/size/size.scss +1 -1
  58. package/tokens-v2-private/scss/tokens/functional/size/viewport.scss +1 -1
  59. package/tokens-v2-private/scss/tokens/functional/typography/typography.scss +1 -1
  60. package/tokens-v2-private/ts/tokens/base/size/size.d.ts +1 -1
  61. package/tokens-v2-private/ts/tokens/base/size/size.js +1 -1
  62. package/tokens-v2-private/ts/tokens/base/typography/typography.d.ts +1 -1
  63. package/tokens-v2-private/ts/tokens/base/typography/typography.js +1 -1
  64. package/tokens-v2-private/ts/tokens/functional/size/border.d.ts +1 -1
  65. package/tokens-v2-private/ts/tokens/functional/size/border.js +1 -1
  66. package/tokens-v2-private/ts/tokens/functional/size/breakpoints.d.ts +1 -1
  67. package/tokens-v2-private/ts/tokens/functional/size/breakpoints.js +1 -1
  68. package/tokens-v2-private/ts/tokens/functional/size/size-coarse.d.ts +1 -1
  69. package/tokens-v2-private/ts/tokens/functional/size/size-coarse.js +1 -1
  70. package/tokens-v2-private/ts/tokens/functional/size/size-fine.d.ts +1 -1
  71. package/tokens-v2-private/ts/tokens/functional/size/size-fine.js +1 -1
  72. package/tokens-v2-private/ts/tokens/functional/size/size.d.ts +1 -1
  73. package/tokens-v2-private/ts/tokens/functional/size/size.js +1 -1
  74. package/tokens-v2-private/ts/tokens/functional/size/viewport.d.ts +1 -1
  75. package/tokens-v2-private/ts/tokens/functional/size/viewport.js +1 -1
  76. package/tokens-v2-private/ts/tokens/functional/typography/typography.d.ts +1 -1
  77. package/tokens-v2-private/ts/tokens/functional/typography/typography.js +1 -1
  78. package/dist/deprecated/colors.json +0 -7
  79. package/dist/js/colors/dark.d.ts +0 -516
  80. package/dist/js/colors/dark.js +0 -616
  81. package/dist/js/colors/dark_colorblind.d.ts +0 -516
  82. package/dist/js/colors/dark_colorblind.js +0 -616
  83. package/dist/js/colors/dark_dimmed.d.ts +0 -516
  84. package/dist/js/colors/dark_dimmed.js +0 -616
  85. package/dist/js/colors/dark_high_contrast.d.ts +0 -516
  86. package/dist/js/colors/dark_high_contrast.js +0 -616
  87. package/dist/js/colors/dark_tritanopia.d.ts +0 -516
  88. package/dist/js/colors/dark_tritanopia.js +0 -616
  89. package/dist/js/colors/index.d.ts +0 -4638
  90. package/dist/js/colors/index.js +0 -15
  91. package/dist/js/colors/light.d.ts +0 -516
  92. package/dist/js/colors/light.js +0 -616
  93. package/dist/js/colors/light_colorblind.d.ts +0 -516
  94. package/dist/js/colors/light_colorblind.js +0 -616
  95. package/dist/js/colors/light_high_contrast.d.ts +0 -516
  96. package/dist/js/colors/light_high_contrast.js +0 -616
  97. package/dist/js/colors/light_tritanopia.d.ts +0 -516
  98. package/dist/js/colors/light_tritanopia.js +0 -616
  99. package/dist/js/index.d.ts +0 -4655
  100. package/dist/js/index.js +0 -9
  101. package/dist/js/spacing/index.d.ts +0 -6
  102. package/dist/js/spacing/index.js +0 -7
  103. package/dist/js/spacing/normal.d.ts +0 -4
  104. package/dist/js/spacing/normal.js +0 -13
  105. package/dist/js/typography/index.d.ts +0 -11
  106. package/dist/js/typography/index.js +0 -7
  107. package/dist/js/typography/normal.d.ts +0 -9
  108. package/dist/js/typography/normal.js +0 -19
  109. package/dist/json/colors/dark.json +0 -614
  110. package/dist/json/colors/dark_colorblind.json +0 -614
  111. package/dist/json/colors/dark_dimmed.json +0 -614
  112. package/dist/json/colors/dark_high_contrast.json +0 -614
  113. package/dist/json/colors/dark_tritanopia.json +0 -614
  114. package/dist/json/colors/light.json +0 -614
  115. package/dist/json/colors/light_colorblind.json +0 -614
  116. package/dist/json/colors/light_high_contrast.json +0 -614
  117. package/dist/json/colors/light_tritanopia.json +0 -614
  118. package/dist/json/spacing/normal.json +0 -11
  119. package/dist/json/typography/normal.json +0 -17
  120. package/dist/removed/colors.json +0 -432
  121. package/dist/scss/colors/_dark.scss +0 -452
  122. package/dist/scss/colors/_dark_colorblind.scss +0 -452
  123. package/dist/scss/colors/_dark_dimmed.scss +0 -452
  124. package/dist/scss/colors/_dark_high_contrast.scss +0 -452
  125. package/dist/scss/colors/_dark_tritanopia.scss +0 -452
  126. package/dist/scss/colors/_light.scss +0 -452
  127. package/dist/scss/colors/_light_colorblind.scss +0 -452
  128. package/dist/scss/colors/_light_high_contrast.scss +0 -452
  129. package/dist/scss/colors/_light_tritanopia.scss +0 -452
  130. package/dist/scss/spacing/_normal.scss +0 -11
  131. package/dist/scss/typography/_normal.scss +0 -15
  132. package/dist/ts/colors/dark.ts +0 -614
  133. package/dist/ts/colors/dark_colorblind.ts +0 -614
  134. package/dist/ts/colors/dark_dimmed.ts +0 -614
  135. package/dist/ts/colors/dark_high_contrast.ts +0 -614
  136. package/dist/ts/colors/dark_tritanopia.ts +0 -614
  137. package/dist/ts/colors/index.ts +0 -10
  138. package/dist/ts/colors/light.ts +0 -614
  139. package/dist/ts/colors/light_colorblind.ts +0 -614
  140. package/dist/ts/colors/light_high_contrast.ts +0 -614
  141. package/dist/ts/colors/light_tritanopia.ts +0 -614
  142. package/dist/ts/index.ts +0 -4
  143. package/dist/ts/spacing/index.ts +0 -2
  144. package/dist/ts/spacing/normal.ts +0 -11
  145. package/dist/ts/typography/index.ts +0 -2
  146. package/dist/ts/typography/normal.ts +0 -17
  147. package/src/filters/isBorder.test.ts +0 -18
  148. package/src/filters/isColor.test.ts +0 -22
  149. package/src/filters/isColorWithAlpha.test.ts +0 -34
  150. package/src/filters/isColorWithMix.test.ts +0 -108
  151. package/src/filters/isDeprecated.test.ts +0 -56
  152. package/src/filters/isDimension.test.ts +0 -22
  153. package/src/filters/isDuration.test.ts +0 -22
  154. package/src/filters/isFontFamily.test.ts +0 -22
  155. package/src/filters/isFontWeight.test.ts +0 -22
  156. package/src/filters/isFromFile.test.ts +0 -34
  157. package/src/filters/isShadow.test.ts +0 -18
  158. package/src/filters/isSource.test.ts +0 -44
  159. package/src/filters/isTypography.test.ts +0 -18
  160. package/src/formats/cssCustomMedia.test.ts +0 -11
  161. package/src/formats/cssThemed.test.ts +0 -87
  162. package/src/formats/cssWrapMediaQuery.test.ts +0 -170
  163. package/src/formats/javascriptCommonJs.test.ts +0 -43
  164. package/src/formats/javascriptEsm.test.ts +0 -41
  165. package/src/formats/jsonNestedPrefixed.test.ts +0 -73
  166. package/src/formats/jsonOneDimensional.test.ts +0 -56
  167. package/src/formats/typescriptExportDefinition.test.ts +0 -178
  168. package/src/formats/utilities/jsonToFlat.test.ts +0 -47
  169. package/src/formats/utilities/jsonToNestedValue.test.ts +0 -39
  170. package/src/formats/utilities/prefixTokens.test.ts +0 -38
  171. package/src/parsers/w3cJsonParser.test.ts +0 -35
  172. package/src/schemas/alphaValueSchema.test.ts +0 -24
  173. package/src/schemas/baseTokenSchema.test.ts +0 -17
  174. package/src/schemas/borderTokenSchema.test.ts +0 -53
  175. package/src/schemas/collectionSchema.test.ts +0 -58
  176. package/src/schemas/colorHexValueSchema.test.ts +0 -26
  177. package/src/schemas/colorTokenSchema.test.ts +0 -27
  178. package/src/schemas/dimensionTokenSchema.test.ts +0 -28
  179. package/src/schemas/dimensionValueSchema.test.ts +0 -21
  180. package/src/schemas/durationTokenSchema.test.ts +0 -58
  181. package/src/schemas/durationValueSchema.test.ts +0 -25
  182. package/src/schemas/fontFamilyTokenSchema.test.ts +0 -82
  183. package/src/schemas/fontWeightTokenSchema.test.ts +0 -88
  184. package/src/schemas/fontWeightValue.test.ts +0 -17
  185. package/src/schemas/numberTokenSchema.test.ts +0 -82
  186. package/src/schemas/referenceValueSchema.test.ts +0 -20
  187. package/src/schemas/schema.test.ts +0 -33
  188. package/src/schemas/scopeTokenSchema.test.ts +0 -29
  189. package/src/schemas/shadowTokenSchema.test.ts +0 -163
  190. package/src/schemas/stringTokenSchema.test.ts +0 -81
  191. package/src/schemas/tokenNameSchema.test.ts +0 -33
  192. package/src/schemas/typographyTokenSchema.test.ts +0 -58
  193. package/src/schemas/validTokenTypeSchema.test.ts +0 -32
  194. package/src/schemas/viewportRangeTokenSchema.test.ts +0 -59
  195. package/src/transformers/borderToCss.test.ts +0 -58
  196. package/src/transformers/colorToHex.test.ts +0 -27
  197. package/src/transformers/colorToHexAlpha.test.ts +0 -30
  198. package/src/transformers/colorToHexMix.test.ts +0 -83
  199. package/src/transformers/colorToRgbAlpha.test.ts +0 -33
  200. package/src/transformers/colorToRgbaFloat.test.ts +0 -168
  201. package/src/transformers/dimensionToPixelUnitless.test.ts +0 -93
  202. package/src/transformers/dimensionToRem.test.ts +0 -81
  203. package/src/transformers/durationToCss.test.ts +0 -56
  204. package/src/transformers/fontFamilyToCss.test.ts +0 -71
  205. package/src/transformers/fontWeightToNumbers.test.ts +0 -117
  206. package/src/transformers/jsonDeprecated.test.ts +0 -31
  207. package/src/transformers/namePathToCamelCase.test.ts +0 -74
  208. package/src/transformers/namePathToDotNotation.test.ts +0 -74
  209. package/src/transformers/namePathToFigma.test.ts +0 -74
  210. package/src/transformers/namePathToKebabCase.test.ts +0 -74
  211. package/src/transformers/namePathToSlashNotation.test.ts +0 -74
  212. package/src/transformers/shadowToCss.test.ts +0 -175
  213. package/src/transformers/typographyToCss.test.ts +0 -164
  214. package/src/transformers/utilities/alpha.test.ts +0 -28
  215. package/src/transformers/utilities/checkRequiredTokenProperties.test.ts +0 -28
  216. package/src/transformers/utilities/getTokenValue.test.ts +0 -18
  217. package/src/transformers/utilities/hexToRgbaFloat.test.ts +0 -66
  218. package/src/transformers/utilities/invalidTokenError.test.ts +0 -21
  219. package/src/transformers/utilities/isRgbaFloat.test.ts +0 -20
  220. package/src/transformers/utilities/rgbaFloatToHex.test.ts +0 -16
  221. package/src/utilities/getFlag.test.ts +0 -31
  222. package/src/utilities/joinFriendly.test.ts +0 -15
  223. package/src/utilities/toCamelCase.test.ts +0 -27
  224. package/src/utilities/treeWalker.test.ts +0 -51
  225. package/src/utilities/upperCaseFirstCharacter.test.ts +0 -19
  226. package/tokens-next-private/css/base/size/size.css +0 -19
  227. package/tokens-next-private/css/base/typography/typography.css +0 -6
  228. package/tokens-next-private/css/functional/motion/motion.css +0 -5
  229. package/tokens-next-private/css/functional/size/border.css +0 -14
  230. package/tokens-next-private/css/functional/size/breakpoints.css +0 -8
  231. package/tokens-next-private/css/functional/size/size-coarse.css +0 -7
  232. package/tokens-next-private/css/functional/size/size-fine.css +0 -7
  233. package/tokens-next-private/css/functional/size/size.css +0 -74
  234. package/tokens-next-private/css/functional/size/viewport.css +0 -6
  235. package/tokens-next-private/css/functional/themes/dark-colorblind.css +0 -1078
  236. package/tokens-next-private/css/functional/themes/dark-dimmed.css +0 -1078
  237. package/tokens-next-private/css/functional/themes/dark-high-contrast.css +0 -1078
  238. package/tokens-next-private/css/functional/themes/dark-tritanopia.css +0 -1078
  239. package/tokens-next-private/css/functional/themes/dark.css +0 -1078
  240. package/tokens-next-private/css/functional/themes/light-colorblind.css +0 -1078
  241. package/tokens-next-private/css/functional/themes/light-high-contrast.css +0 -1078
  242. package/tokens-next-private/css/functional/themes/light-tritanopia.css +0 -1078
  243. package/tokens-next-private/css/functional/themes/light.css +0 -1078
  244. package/tokens-next-private/css/functional/typography/typography.css +0 -47
  245. package/tokens-next-private/docs/base/size/size.json +0 -427
  246. package/tokens-next-private/docs/base/typography/typography.json +0 -54
  247. package/tokens-next-private/docs/functional/motion/motion.json +0 -47
  248. package/tokens-next-private/docs/functional/size/border.json +0 -234
  249. package/tokens-next-private/docs/functional/size/breakpoints.json +0 -152
  250. package/tokens-next-private/docs/functional/size/size-coarse.json +0 -41
  251. package/tokens-next-private/docs/functional/size/size-fine.json +0 -41
  252. package/tokens-next-private/docs/functional/size/size.json +0 -1838
  253. package/tokens-next-private/docs/functional/size/viewport.json +0 -80
  254. package/tokens-next-private/docs/functional/themes/dark-colorblind.json +0 -16155
  255. package/tokens-next-private/docs/functional/themes/dark-dimmed.json +0 -16159
  256. package/tokens-next-private/docs/functional/themes/dark-high-contrast.json +0 -16175
  257. package/tokens-next-private/docs/functional/themes/dark-tritanopia.json +0 -16161
  258. package/tokens-next-private/docs/functional/themes/dark.json +0 -16159
  259. package/tokens-next-private/docs/functional/themes/light-colorblind.json +0 -16123
  260. package/tokens-next-private/docs/functional/themes/light-high-contrast.json +0 -16125
  261. package/tokens-next-private/docs/functional/themes/light-tritanopia.json +0 -16115
  262. package/tokens-next-private/docs/functional/themes/light.json +0 -16113
  263. package/tokens-next-private/docs/functional/typography/typography.json +0 -663
  264. package/tokens-next-private/fallbacks/base/size/size.json +0 -19
  265. package/tokens-next-private/fallbacks/base/typography/typography.json +0 -6
  266. package/tokens-next-private/fallbacks/color-fallbacks.json +0 -260
  267. package/tokens-next-private/fallbacks/functional/motion/motion.json +0 -5
  268. package/tokens-next-private/fallbacks/functional/size/border.json +0 -14
  269. package/tokens-next-private/fallbacks/functional/size/breakpoints.json +0 -8
  270. package/tokens-next-private/fallbacks/functional/size/size-coarse.json +0 -5
  271. package/tokens-next-private/fallbacks/functional/size/size-fine.json +0 -5
  272. package/tokens-next-private/fallbacks/functional/size/size.json +0 -74
  273. package/tokens-next-private/fallbacks/functional/size/viewport.json +0 -8
  274. package/tokens-next-private/fallbacks/functional/typography/typography.json +0 -47
  275. package/tokens-next-private/internalCss/dark-colorblind.css +0 -1648
  276. package/tokens-next-private/internalCss/dark-dimmed.css +0 -1648
  277. package/tokens-next-private/internalCss/dark-high-contrast.css +0 -1648
  278. package/tokens-next-private/internalCss/dark-tritanopia.css +0 -1648
  279. package/tokens-next-private/internalCss/dark.css +0 -1648
  280. package/tokens-next-private/internalCss/light-colorblind.css +0 -1648
  281. package/tokens-next-private/internalCss/light-high-contrast.css +0 -1648
  282. package/tokens-next-private/internalCss/light-tritanopia.css +0 -1648
  283. package/tokens-next-private/internalCss/light.css +0 -1648
  284. package/tokens-next-private/removed/color.json +0 -421
  285. package/tokens-next-private/styleLint/base/size/size.json +0 -427
  286. package/tokens-next-private/styleLint/base/typography/typography.json +0 -54
  287. package/tokens-next-private/styleLint/functional/motion/motion.json +0 -47
  288. package/tokens-next-private/styleLint/functional/size/border.json +0 -234
  289. package/tokens-next-private/styleLint/functional/size/breakpoints.json +0 -152
  290. package/tokens-next-private/styleLint/functional/size/size-coarse.json +0 -41
  291. package/tokens-next-private/styleLint/functional/size/size-fine.json +0 -41
  292. package/tokens-next-private/styleLint/functional/size/size.json +0 -1838
  293. package/tokens-next-private/styleLint/functional/size/viewport.json +0 -80
  294. package/tokens-next-private/styleLint/functional/themes/dark-colorblind.json +0 -16155
  295. package/tokens-next-private/styleLint/functional/themes/dark-dimmed.json +0 -16159
  296. package/tokens-next-private/styleLint/functional/themes/dark-high-contrast.json +0 -16175
  297. package/tokens-next-private/styleLint/functional/themes/dark-tritanopia.json +0 -16161
  298. package/tokens-next-private/styleLint/functional/themes/dark.json +0 -16159
  299. package/tokens-next-private/styleLint/functional/themes/light-colorblind.json +0 -16123
  300. package/tokens-next-private/styleLint/functional/themes/light-high-contrast.json +0 -16125
  301. package/tokens-next-private/styleLint/functional/themes/light-tritanopia.json +0 -16115
  302. package/tokens-next-private/styleLint/functional/themes/light.json +0 -16113
  303. package/tokens-next-private/styleLint/functional/typography/typography.json +0 -663
@@ -1,168 +0,0 @@
1
- import {getMockToken} from '../test-utilities'
2
- import {colorToRgbaFloat} from './colorToRgbaFloat'
3
- import {rgbaFloatToHex} from './utilities/rgbaFloatToHex'
4
-
5
- describe('Transformer: colorToRgbaFloat', () => {
6
- it('transforms `hex3`, `hex6`, and `hex8` tokens to rgb float value', () => {
7
- const input = [getMockToken({value: '#123'}), getMockToken({value: '#343434'}), getMockToken({value: '#34343466'})]
8
- const expectedOutput = [
9
- {
10
- r: 0.06666666666666667,
11
- g: 0.13333333333333333,
12
- b: 0.2,
13
- a: 1,
14
- },
15
- {
16
- r: 0.20392156862745098,
17
- g: 0.20392156862745098,
18
- b: 0.20392156862745098,
19
- a: 1,
20
- },
21
- {
22
- r: 0.20392156862745098,
23
- g: 0.20392156862745098,
24
- b: 0.20392156862745098,
25
- a: 0.4,
26
- },
27
- ]
28
- expect(input.map(item => colorToRgbaFloat.transformer(item, {}))).toStrictEqual(expectedOutput)
29
- })
30
-
31
- it('transforms `rgb` and `rgba` to rgb float value', () => {
32
- const input = [getMockToken({value: 'rgb(100,200,255)'}), getMockToken({value: 'rgba(100,200,255, .4)'})]
33
- const expectedOutput = [
34
- {
35
- r: 0.39215686274509803,
36
- g: 0.7843137254901961,
37
- b: 1,
38
- a: 1,
39
- },
40
- {
41
- r: 0.39215686274509803,
42
- g: 0.7843137254901961,
43
- b: 1,
44
- a: 0.4,
45
- },
46
- ]
47
- expect(input.map(item => colorToRgbaFloat.transformer(item, {}))).toStrictEqual(expectedOutput)
48
- })
49
-
50
- it('transforms `color` tokens including alpha value', () => {
51
- expect(
52
- [
53
- getMockToken({value: '#343434', alpha: 0.4}),
54
- getMockToken({value: '#34343466', alpha: 0.9}),
55
- getMockToken({value: 'rgb(100,200,255)', alpha: 0.4}),
56
- getMockToken({value: 'rgba(100,200,255,0.8)', alpha: 0.4}),
57
- ].map(item => colorToRgbaFloat.transformer(item, {})),
58
- ).toStrictEqual([
59
- {
60
- r: 0.20392156862745098,
61
- g: 0.20392156862745098,
62
- b: 0.20392156862745098,
63
- a: 0.4,
64
- },
65
- {
66
- r: 0.20392156862745098,
67
- g: 0.20392156862745098,
68
- b: 0.20392156862745098,
69
- a: 0.9,
70
- },
71
- {
72
- r: 0.39215686274509803,
73
- g: 0.7843137254901961,
74
- b: 1,
75
- a: 0.4,
76
- },
77
- {
78
- r: 0.39215686274509803,
79
- g: 0.7843137254901961,
80
- b: 1,
81
- a: 0.4,
82
- },
83
- ])
84
- })
85
-
86
- it('transforms `color` tokens including mix', () => {
87
- expect(
88
- [
89
- getMockToken({name: 'Mix of reds', value: '#a40e26', mix: {color: '#660018', weight: 0.4}}),
90
- getMockToken({value: '#34343466', mix: {color: '#000000'}}),
91
- getMockToken({value: 'rgb(100,200,255)', mix: {weight: 0.5}}),
92
- getMockToken({value: 'rgba(100,200,255,0.8)', mix: {color: undefined, weight: undefined}}),
93
- ].map(item => colorToRgbaFloat.transformer(item, {})),
94
- ).toStrictEqual([
95
- {
96
- b: 0.12549019607843137,
97
- g: 0.03137254901960784,
98
- r: 0.5450980392156862,
99
- a: 1,
100
- },
101
- {
102
- r: 0.20392156862745098,
103
- g: 0.20392156862745098,
104
- b: 0.20392156862745098,
105
- a: 0.4,
106
- },
107
- {
108
- r: 0.39215686274509803,
109
- g: 0.7843137254901961,
110
- b: 1,
111
- a: 1,
112
- },
113
- {
114
- r: 0.39215686274509803,
115
- g: 0.7843137254901961,
116
- b: 1,
117
- a: 0.8,
118
- },
119
- ])
120
-
121
- expect(
122
- [
123
- getMockToken({name: 'Mix of reds', value: '#a40e26', mix: {color: '#660018', weight: 0.4}}),
124
- getMockToken({value: '#34343466', mix: {color: '#000000'}}),
125
- getMockToken({value: 'rgb(100,200,255)', mix: {weight: 0.5}}),
126
- getMockToken({value: 'rgba(100,200,255,0.8)', mix: {color: undefined, weight: undefined}}),
127
- ]
128
- .map(item => colorToRgbaFloat.transformer(item, {}))
129
- .map(item => rgbaFloatToHex(item)),
130
- ).toStrictEqual(['#8b0820', '#34343466', '#64c8ff', '#64c8ffcc'])
131
- })
132
-
133
- it('it forwards `rgb float` values', () => {
134
- const input = [
135
- getMockToken({
136
- value: {
137
- r: 0.39215686274509803,
138
- g: 0.7843137254901961,
139
- b: 1,
140
- a: 1,
141
- },
142
- }),
143
- getMockToken({
144
- value: {
145
- r: 0.39215686274509803,
146
- g: 0.7843137254901961,
147
- b: 1,
148
- a: 0.4,
149
- },
150
- }),
151
- ]
152
- const expectedOutput = [
153
- {
154
- r: 0.39215686274509803,
155
- g: 0.7843137254901961,
156
- b: 1,
157
- a: 1,
158
- },
159
- {
160
- r: 0.39215686274509803,
161
- g: 0.7843137254901961,
162
- b: 1,
163
- a: 0.4,
164
- },
165
- ]
166
- expect(input.map(item => colorToRgbaFloat.transformer(item, {}))).toStrictEqual(expectedOutput)
167
- })
168
- })
@@ -1,93 +0,0 @@
1
- import {getMockToken} from '../test-utilities'
2
- import {dimensionToPixelUnitless} from './dimensionToPixelUnitless'
3
-
4
- describe('Transformer: dimensionToPixelUnitless', () => {
5
- it('transforms pixel string tokens', () => {
6
- const input = [
7
- getMockToken({
8
- value: '16px',
9
- }),
10
- ]
11
- const expectedOutput = [16]
12
- expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
13
- })
14
-
15
- it('does not transforms number or number string', () => {
16
- const input = [
17
- getMockToken({
18
- value: '16',
19
- }),
20
- getMockToken({
21
- value: 16,
22
- }),
23
- ]
24
- const expectedOutput = ['16', 16]
25
- expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
26
- })
27
-
28
- it('transforms rem', () => {
29
- const input = [
30
- getMockToken({
31
- value: '1rem',
32
- }),
33
- ]
34
- const expectedOutput = [16]
35
- expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
36
- })
37
-
38
- it('transforms rem with custom basePxFontSize', () => {
39
- const input = [
40
- getMockToken({
41
- value: '2rem',
42
- }),
43
- ]
44
- const expectedOutput = [20]
45
- expect(input.map(item => dimensionToPixelUnitless.transformer(item, {basePxFontSize: 10}))).toStrictEqual(
46
- expectedOutput,
47
- )
48
- })
49
-
50
- it('does not transforms em', () => {
51
- const input = [
52
- getMockToken({
53
- value: '1em',
54
- }),
55
- ]
56
- const expectedOutput = ['1em']
57
- expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
58
- })
59
-
60
- it('transforms 0 to 0', () => {
61
- const input = [
62
- getMockToken({
63
- value: '0rem',
64
- }),
65
- getMockToken({
66
- value: '0px',
67
- }),
68
- getMockToken({
69
- value: '0',
70
- }),
71
- ]
72
- const expectedOutput = [0, 0, 0]
73
- expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
74
- })
75
-
76
- it('throws on invalid tokens', () => {
77
- const input = [
78
- getMockToken({
79
- value: 'rem',
80
- }),
81
- getMockToken({
82
- value: '',
83
- }),
84
- getMockToken({
85
- value: undefined,
86
- }),
87
- getMockToken({
88
- value: null,
89
- }),
90
- ]
91
- expect(() => input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toThrow()
92
- })
93
- })
@@ -1,81 +0,0 @@
1
- import {getMockToken} from '../test-utilities'
2
- import {dimensionToRem} from './dimensionToRem'
3
-
4
- describe('Transformer: dimensionToRem', () => {
5
- it('transforms pixel string tokens to rem', () => {
6
- const input = [
7
- getMockToken({
8
- value: '16px',
9
- }),
10
- ]
11
- const expectedOutput = ['1rem']
12
- expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
13
- })
14
-
15
- it('transforms number to rem', () => {
16
- const input = [
17
- getMockToken({
18
- value: '16',
19
- }),
20
- getMockToken({
21
- value: 16,
22
- }),
23
- ]
24
- const expectedOutput = ['1rem', '1rem']
25
- expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
26
- })
27
-
28
- it('transforms rem to rem', () => {
29
- const input = [
30
- getMockToken({
31
- value: '1rem',
32
- }),
33
- ]
34
- const expectedOutput = ['1rem']
35
- expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
36
- })
37
-
38
- it('does not transforms em to rem', () => {
39
- const input = [
40
- getMockToken({
41
- value: '1em',
42
- }),
43
- ]
44
- const expectedOutput = ['1em']
45
- expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
46
- })
47
-
48
- it('transforms 0 to 0', () => {
49
- const input = [
50
- getMockToken({
51
- value: '0rem',
52
- }),
53
- getMockToken({
54
- value: '0px',
55
- }),
56
- getMockToken({
57
- value: '0',
58
- }),
59
- ]
60
- const expectedOutput = ['0', '0', '0']
61
- expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
62
- })
63
-
64
- it('throws on invalid tokens', () => {
65
- const input = [
66
- getMockToken({
67
- value: 'rem',
68
- }),
69
- getMockToken({
70
- value: '',
71
- }),
72
- getMockToken({
73
- value: undefined,
74
- }),
75
- getMockToken({
76
- value: null,
77
- }),
78
- ]
79
- expect(() => input.map(item => dimensionToRem.transformer(item, {}))).toThrow()
80
- })
81
- })
@@ -1,56 +0,0 @@
1
- import {getMockToken} from '../test-utilities'
2
- import {durationToCss} from './durationToCss'
3
-
4
- describe('Transformer: durationToCss', () => {
5
- it('transforms `duration` token to css duration', () => {
6
- const input = getMockToken({
7
- value: '100ms',
8
- })
9
-
10
- const expectedOutput = '100ms'
11
- expect(durationToCss.transformer(input, {})).toStrictEqual(expectedOutput)
12
- })
13
-
14
- it('transforms `ms` to `s`', () => {
15
- const input = getMockToken({
16
- value: '1252ms',
17
- })
18
-
19
- const expectedOutput = '1.252s'
20
- expect(durationToCss.transformer(input, {})).toStrictEqual(expectedOutput)
21
- })
22
-
23
- it('throws an error when unit is missing or invalid', () => {
24
- // missing unit
25
- expect(() =>
26
- durationToCss.transformer(
27
- getMockToken({
28
- value: '1000',
29
- }),
30
- {},
31
- ),
32
- ).toThrowError()
33
-
34
- // only ms unit is supported
35
- expect(() =>
36
- durationToCss.transformer(
37
- getMockToken({
38
- value: '1s',
39
- }),
40
- {},
41
- ),
42
- ).toThrowError()
43
- })
44
-
45
- it('throws an error when value is number', () => {
46
- // missing unit
47
- expect(() =>
48
- durationToCss.transformer(
49
- getMockToken({
50
- value: 1000,
51
- }),
52
- {},
53
- ),
54
- ).toThrowError()
55
- })
56
- })
@@ -1,71 +0,0 @@
1
- import {getMockToken} from '../test-utilities'
2
- import {fontFamilyToCss} from './fontFamilyToCss'
3
-
4
- describe('Transformer: fontFamilyToCss', () => {
5
- it('transforms fontFamily string', () => {
6
- const input = [
7
- getMockToken({
8
- value: 'Roboto, Noto Sans',
9
- }),
10
- getMockToken({
11
- value: 'Roboto',
12
- }),
13
- ]
14
- const expectedOutput = ['Roboto, Noto Sans', 'Roboto']
15
- expect(input.map(item => fontFamilyToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
16
- })
17
-
18
- it('transforms fontFamily array', () => {
19
- const input = [
20
- getMockToken({
21
- value: ['Roboto', 'Noto Sans'],
22
- }),
23
- getMockToken({
24
- value: ['Roboto'],
25
- }),
26
- ]
27
- const expectedOutput = ["Roboto, 'Noto Sans'", 'Roboto']
28
- expect(input.map(item => fontFamilyToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
29
- })
30
-
31
- it('throws on invalid value', () => {
32
- expect(() =>
33
- fontFamilyToCss.transformer(
34
- getMockToken({
35
- value: {
36
- fontFamily: 'Roboto',
37
- fontSize: '42px',
38
- },
39
- }),
40
- {},
41
- ),
42
- ).toThrowError()
43
-
44
- expect(() =>
45
- fontFamilyToCss.transformer(
46
- getMockToken({
47
- value: 42,
48
- }),
49
- {},
50
- ),
51
- ).toThrowError()
52
-
53
- expect(() =>
54
- fontFamilyToCss.transformer(
55
- getMockToken({
56
- value: undefined,
57
- }),
58
- {},
59
- ),
60
- ).toThrowError()
61
-
62
- expect(() =>
63
- fontFamilyToCss.transformer(
64
- getMockToken({
65
- value: [42, 'Roboto'],
66
- }),
67
- {},
68
- ),
69
- ).toThrowError()
70
- })
71
- })
@@ -1,117 +0,0 @@
1
- import {getMockToken} from '../test-utilities'
2
- import {fontWeightToNumber} from './fontWeightToNumber'
3
-
4
- describe('Transformer: fontWeightToNumbers', () => {
5
- it('keeps number if within range of 1-1000', () => {
6
- const input = [
7
- getMockToken({
8
- value: 100,
9
- }),
10
- getMockToken({
11
- value: 1000,
12
- }),
13
- ]
14
- const expectedOutput = [100, 1000]
15
- expect(input.map(item => fontWeightToNumber.transformer(item, {}))).toStrictEqual(expectedOutput)
16
- })
17
-
18
- it('transforms string of number to number', () => {
19
- const input = getMockToken({
20
- value: '100',
21
- })
22
- const expectedOutput = 100
23
- expect(fontWeightToNumber.transformer(input, {})).toStrictEqual(expectedOutput)
24
- })
25
-
26
- it('transforms font strings to number', () => {
27
- const testCases: [fontWeightNumber: number, fontWeightString: string][] = [
28
- [100, 'thin'],
29
- [100, 'hairline'],
30
- [200, 'extra-light'],
31
- [200, 'ultra-light'],
32
- [300, 'light'],
33
- [400, 'normal'],
34
- [400, 'regular'],
35
- [400, 'book'],
36
- [500, 'medium'],
37
- [600, 'semi-bold'],
38
- [600, 'demi-bold'],
39
- [700, 'bold'],
40
- [800, 'extra-bold'],
41
- [800, 'ultra-bold'],
42
- [900, 'black'],
43
- [900, 'heavy'],
44
- [950, 'extra-black'],
45
- [950, 'ultra-black'],
46
- ]
47
-
48
- for (const [fontWeightNumber, fontWeightString] of testCases) {
49
- const input = getMockToken({
50
- value: fontWeightString,
51
- })
52
- try {
53
- expect(fontWeightToNumber.transformer(input, {})).toStrictEqual(fontWeightNumber)
54
- } catch (e) {
55
- throw new Error(`❌ Expects ${fontWeightString} to be transformed to ${fontWeightNumber}`)
56
- }
57
- }
58
- })
59
-
60
- it('throws on invalid value', () => {
61
- expect(() =>
62
- fontWeightToNumber.transformer(
63
- getMockToken({
64
- value: 1001,
65
- }),
66
- {},
67
- ),
68
- ).toThrowError()
69
-
70
- expect(() =>
71
- fontWeightToNumber.transformer(
72
- getMockToken({
73
- value: 0,
74
- }),
75
- {},
76
- ),
77
- ).toThrowError()
78
-
79
- expect(() =>
80
- fontWeightToNumber.transformer(
81
- getMockToken({
82
- value: undefined,
83
- }),
84
- {},
85
- ),
86
- ).toThrowError()
87
-
88
- expect(() =>
89
- fontWeightToNumber.transformer(
90
- getMockToken({
91
- value: 'Roboto',
92
- }),
93
- {},
94
- ),
95
- ).toThrowError()
96
-
97
- expect(() =>
98
- fontWeightToNumber.transformer(
99
- getMockToken({
100
- value: ['Roboto'],
101
- }),
102
- {},
103
- ),
104
- ).toThrowError()
105
-
106
- expect(() =>
107
- fontWeightToNumber.transformer(
108
- getMockToken({
109
- value: {
110
- fontWeight: 300,
111
- },
112
- }),
113
- {},
114
- ),
115
- ).toThrowError()
116
- })
117
- })
@@ -1,31 +0,0 @@
1
- import {getMockToken} from '../test-utilities'
2
- import {jsonDeprecated} from './jsonDeprecated'
3
-
4
- describe('Transformer: jsonDeprecated', () => {
5
- it('Replaces token value with `null` if deprecated is set to `true`', () => {
6
- const item = getMockToken({
7
- value: 'tokenName',
8
- deprecated: true,
9
- })
10
- const expectedOutput = null
11
- expect(jsonDeprecated.transformer(item, {})).toStrictEqual(expectedOutput)
12
- })
13
-
14
- it('Replaces token value with deprecated value if deprecated is a `string`', () => {
15
- const item = getMockToken({
16
- value: 'tokenName',
17
- deprecated: `token.pumpkin`,
18
- })
19
- const expectedOutput = 'token.pumpkin'
20
- expect(jsonDeprecated.transformer(item, {})).toStrictEqual(expectedOutput)
21
- })
22
-
23
- it('Replaces token value with deprecated value if deprecated is a `string` and removes {}', () => {
24
- const item = getMockToken({
25
- value: 'tokenName',
26
- deprecated: `{token.pumpkin}`,
27
- })
28
- const expectedOutput = 'token.pumpkin'
29
- expect(jsonDeprecated.transformer(item, {})).toStrictEqual(expectedOutput)
30
- })
31
- })
@@ -1,74 +0,0 @@
1
- import {getMockToken} from '../test-utilities'
2
- import {namePathToCamelCase} from './namePathToCamelCase'
3
-
4
- describe('Transformer: namePathToCamelCase', () => {
5
- it('converts path elements to dot.notation and ignores name proprty', () => {
6
- const input = [
7
- getMockToken({
8
- name: 'tokenName',
9
- path: ['path', 'to', 'token'],
10
- }),
11
- getMockToken({
12
- name: 'tokenName',
13
- path: ['PATH', 'tO', 'Token'],
14
- }),
15
- getMockToken({
16
- name: 'tokenName',
17
- path: ['path', 'toToken'],
18
- }),
19
- getMockToken({
20
- name: 'tokenName',
21
- path: ['pathtoToken'],
22
- }),
23
- ]
24
- const expectedOutput = ['pathToToken', 'PATHTOToken', 'pathToToken', 'pathtoToken']
25
-
26
- expect(input.map(item => namePathToCamelCase.transformer(item, {}))).toStrictEqual(expectedOutput)
27
- })
28
-
29
- it('replaces spaces, `-`, `_` and `+` within path elements and joins with camelCase, but does not change the rest of the word', () => {
30
- const input = [
31
- getMockToken({
32
- name: 'tokenName',
33
- path: ['start', 'path to token'],
34
- }),
35
- getMockToken({
36
- name: 'tokenName',
37
- path: ['start', 'PATH_tO-+Token'],
38
- }),
39
- getMockToken({
40
- name: 'tokenName',
41
- path: ['start', 'path+toToken'],
42
- }),
43
- ]
44
- const expectedOutput = ['startPathToToken', 'startPATHTOToken', 'startPathToToken']
45
- expect(input.map(item => namePathToCamelCase.transformer(item, {}))).toStrictEqual(expectedOutput)
46
- })
47
-
48
- it('removes `@`, so we can use it for the default hack', () => {
49
- const input = [
50
- getMockToken({
51
- name: 'tokenName',
52
- path: ['fgColor', 'accent', '@'],
53
- }),
54
- getMockToken({
55
- name: 'tokenName',
56
- path: ['fgColor', '@', 'muted'],
57
- }),
58
- ]
59
- const expectedOutput = ['fgColorAccent', 'fgColorMuted']
60
- expect(input.map(item => namePathToCamelCase.transformer(item, {}))).toStrictEqual(expectedOutput)
61
- })
62
-
63
- it('adds prefix to token name', () => {
64
- const platform = {
65
- prefix: 'PRIMER',
66
- }
67
- const input = getMockToken({
68
- name: 'tokenName',
69
- path: ['start', 'pathTo', 'token'],
70
- })
71
- const expectedOutput = 'PRIMERStartPathToToken'
72
- expect(namePathToCamelCase.transformer(input, platform)).toStrictEqual(expectedOutput)
73
- })
74
- })