@primer/primitives 10.0.0-rc.fd912e08 → 10.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.
- package/README.md +2 -2
- package/dist/build/PrimerStyleDictionary.d.ts +8 -0
- package/dist/build/PrimerStyleDictionary.js +80 -0
- package/dist/build/filters/index.d.ts +14 -0
- package/dist/build/filters/index.js +14 -0
- package/dist/build/filters/isBorder.d.ts +7 -0
- package/dist/build/filters/isBorder.js +8 -0
- package/dist/build/filters/isColor.d.ts +7 -0
- package/dist/build/filters/isColor.js +13 -0
- package/dist/build/filters/isColorWithAlpha.d.ts +7 -0
- package/dist/build/filters/isColorWithAlpha.js +9 -0
- package/dist/build/filters/isColorWithMix.d.ts +7 -0
- package/dist/build/filters/isColorWithMix.js +24 -0
- package/dist/build/filters/isCubicBezier.d.ts +7 -0
- package/dist/build/filters/isCubicBezier.js +10 -0
- package/dist/build/filters/isDeprecated.d.ts +7 -0
- package/dist/build/filters/isDeprecated.js +8 -0
- package/dist/build/filters/isDimension.d.ts +7 -0
- package/dist/build/filters/isDimension.js +8 -0
- package/dist/build/filters/isDuration.d.ts +7 -0
- package/dist/build/filters/isDuration.js +8 -0
- package/dist/build/filters/isFontFamily.d.ts +7 -0
- package/dist/build/filters/isFontFamily.js +8 -0
- package/dist/build/filters/isFontWeight.d.ts +7 -0
- package/dist/build/filters/isFontWeight.js +8 -0
- package/dist/build/filters/isFromFile.d.ts +8 -0
- package/dist/build/filters/isFromFile.js +10 -0
- package/dist/build/filters/isNumber.d.ts +7 -0
- package/dist/build/filters/isNumber.js +8 -0
- package/dist/build/filters/isShadow.d.ts +7 -0
- package/dist/build/filters/isShadow.js +8 -0
- package/dist/build/filters/isSource.d.ts +7 -0
- package/dist/build/filters/isSource.js +8 -0
- package/dist/build/filters/isTypography.d.ts +7 -0
- package/dist/build/filters/isTypography.js +8 -0
- package/dist/build/formats/cssAdvanced.d.ts +2 -0
- package/dist/build/formats/cssAdvanced.js +86 -0
- package/dist/build/formats/cssCustomMedia.d.ts +7 -0
- package/dist/build/formats/cssCustomMedia.js +26 -0
- package/dist/build/formats/index.d.ts +9 -0
- package/dist/build/formats/index.js +9 -0
- package/dist/build/formats/javascriptCommonJs.d.ts +7 -0
- package/dist/build/formats/javascriptCommonJs.js +26 -0
- package/dist/build/formats/javascriptEsm.d.ts +7 -0
- package/dist/build/formats/javascriptEsm.js +26 -0
- package/dist/build/formats/jsonFigma.d.ts +7 -0
- package/dist/build/formats/jsonFigma.js +121 -0
- package/dist/build/formats/jsonNestedPrefixed.d.ts +8 -0
- package/dist/build/formats/jsonNestedPrefixed.js +30 -0
- package/dist/build/formats/jsonOneDimensional.d.ts +8 -0
- package/dist/build/formats/jsonOneDimensional.js +32 -0
- package/dist/build/formats/jsonPostCssFallback.d.ts +8 -0
- package/dist/build/formats/jsonPostCssFallback.js +14 -0
- package/dist/build/formats/typescriptExportDefinition.d.ts +7 -0
- package/dist/build/formats/typescriptExportDefinition.js +170 -0
- package/dist/build/formats/utilities/getPropName.d.ts +1 -0
- package/dist/build/formats/utilities/getPropName.js +16 -0
- package/dist/build/formats/utilities/jsonToFlat.d.ts +11 -0
- package/dist/build/formats/utilities/jsonToFlat.js +8 -0
- package/dist/build/formats/utilities/jsonToNestedValue.d.ts +8 -0
- package/dist/build/formats/utilities/jsonToNestedValue.js +23 -0
- package/dist/build/formats/utilities/prefixTokens.d.ts +8 -0
- package/dist/build/formats/utilities/prefixTokens.js +13 -0
- package/dist/build/parsers/index.d.ts +1 -0
- package/dist/build/parsers/index.js +1 -0
- package/dist/build/parsers/w3cJsonParser.d.ts +6 -0
- package/dist/build/parsers/w3cJsonParser.js +25 -0
- package/dist/build/platforms/css.d.ts +2 -0
- package/dist/build/platforms/css.js +96 -0
- package/dist/build/platforms/deprecatedJson.d.ts +2 -0
- package/dist/build/platforms/deprecatedJson.js +13 -0
- package/dist/build/platforms/docJson.d.ts +2 -0
- package/dist/build/platforms/docJson.js +35 -0
- package/dist/build/platforms/fallbacks.d.ts +2 -0
- package/dist/build/platforms/fallbacks.js +30 -0
- package/dist/build/platforms/figma.d.ts +2 -0
- package/dist/build/platforms/figma.js +60 -0
- package/dist/build/platforms/index.d.ts +10 -0
- package/dist/build/platforms/index.js +10 -0
- package/dist/build/platforms/javascript.d.ts +2 -0
- package/dist/build/platforms/javascript.js +26 -0
- package/dist/build/platforms/json.d.ts +2 -0
- package/dist/build/platforms/json.js +28 -0
- package/dist/build/platforms/styleLint.d.ts +2 -0
- package/dist/build/platforms/styleLint.js +30 -0
- package/dist/build/platforms/typeDefinitions.d.ts +2 -0
- package/dist/build/platforms/typeDefinitions.js +26 -0
- package/dist/build/platforms/typescript.d.ts +2 -0
- package/dist/build/platforms/typescript.js +26 -0
- package/dist/build/schemas/alphaValue.d.ts +2 -0
- package/dist/build/schemas/alphaValue.js +5 -0
- package/dist/build/schemas/baseToken.d.ts +11 -0
- package/dist/build/schemas/baseToken.js +7 -0
- package/dist/build/schemas/borderToken.d.ts +51 -0
- package/dist/build/schemas/borderToken.js +17 -0
- package/dist/build/schemas/collections.d.ts +6 -0
- package/dist/build/schemas/collections.js +12 -0
- package/dist/build/schemas/colorHexValue.d.ts +2 -0
- package/dist/build/schemas/colorHexValue.js +9 -0
- package/dist/build/schemas/colorToken.d.ts +92 -0
- package/dist/build/schemas/colorToken.js +53 -0
- package/dist/build/schemas/cubicBezierToken.d.ts +18 -0
- package/dist/build/schemas/cubicBezierToken.js +8 -0
- package/dist/build/schemas/designToken.d.ts +2 -0
- package/dist/build/schemas/designToken.js +35 -0
- package/dist/build/schemas/dimensionToken.d.ts +59 -0
- package/dist/build/schemas/dimensionToken.js +34 -0
- package/dist/build/schemas/dimensionValue.d.ts +2 -0
- package/dist/build/schemas/dimensionValue.js +9 -0
- package/dist/build/schemas/durationToken.d.ts +18 -0
- package/dist/build/schemas/durationToken.js +11 -0
- package/dist/build/schemas/durationValue.d.ts +2 -0
- package/dist/build/schemas/durationValue.js +5 -0
- package/dist/build/schemas/fontFamilyToken.d.ts +52 -0
- package/dist/build/schemas/fontFamilyToken.js +20 -0
- package/dist/build/schemas/fontWeightToken.d.ts +52 -0
- package/dist/build/schemas/fontWeightToken.js +21 -0
- package/dist/build/schemas/fontWeightValue.d.ts +2 -0
- package/dist/build/schemas/fontWeightValue.js +6 -0
- package/dist/build/schemas/numberToken.d.ts +71 -0
- package/dist/build/schemas/numberToken.js +27 -0
- package/dist/build/schemas/referenceValue.d.ts +2 -0
- package/dist/build/schemas/referenceValue.js +5 -0
- package/dist/build/schemas/scopes.d.ts +5 -0
- package/dist/build/schemas/scopes.js +29 -0
- package/dist/build/schemas/shadowToken.d.ts +164 -0
- package/dist/build/schemas/shadowToken.js +46 -0
- package/dist/build/schemas/stringToken.d.ts +18 -0
- package/dist/build/schemas/stringToken.js +10 -0
- package/dist/build/schemas/tokenName.d.ts +2 -0
- package/dist/build/schemas/tokenName.js +5 -0
- package/dist/build/schemas/tokenType.d.ts +3 -0
- package/dist/build/schemas/tokenType.js +2 -0
- package/dist/build/schemas/typographyToken.d.ts +59 -0
- package/dist/build/schemas/typographyToken.js +18 -0
- package/dist/build/schemas/validTokenType.d.ts +5 -0
- package/dist/build/schemas/validTokenType.js +31 -0
- package/dist/build/schemas/viewportRangeToken.d.ts +18 -0
- package/dist/build/schemas/viewportRangeToken.js +10 -0
- package/dist/build/transformers/borderToCss.d.ts +8 -0
- package/dist/build/transformers/borderToCss.js +38 -0
- package/dist/build/transformers/colorToHex.d.ts +8 -0
- package/dist/build/transformers/colorToHex.js +24 -0
- package/dist/build/transformers/colorToHexMix.d.ts +8 -0
- package/dist/build/transformers/colorToHexMix.js +20 -0
- package/dist/build/transformers/colorToRgbAlpha.d.ts +8 -0
- package/dist/build/transformers/colorToRgbAlpha.js +20 -0
- package/dist/build/transformers/colorToRgbaFloat.d.ts +8 -0
- package/dist/build/transformers/colorToRgbaFloat.js +46 -0
- package/dist/build/transformers/cubicBezierToCss.d.ts +8 -0
- package/dist/build/transformers/cubicBezierToCss.js +23 -0
- package/dist/build/transformers/dimensionToPixelUnitless.d.ts +8 -0
- package/dist/build/transformers/dimensionToPixelUnitless.js +49 -0
- package/dist/build/transformers/dimensionToRem.d.ts +8 -0
- package/dist/build/transformers/dimensionToRem.js +46 -0
- package/dist/build/transformers/dimensionToRemPxArray.d.ts +8 -0
- package/dist/build/transformers/dimensionToRemPxArray.js +46 -0
- package/dist/build/transformers/durationToCss.d.ts +8 -0
- package/dist/build/transformers/durationToCss.js +29 -0
- package/dist/build/transformers/figmaAttributes.d.ts +8 -0
- package/dist/build/transformers/figmaAttributes.js +55 -0
- package/dist/build/transformers/floatToPixel.d.ts +15 -0
- package/dist/build/transformers/floatToPixel.js +39 -0
- package/dist/build/transformers/fontFamilyToCss.d.ts +14 -0
- package/dist/build/transformers/fontFamilyToCss.js +37 -0
- package/dist/build/transformers/fontFamilyToFigma.d.ts +14 -0
- package/dist/build/transformers/fontFamilyToFigma.js +44 -0
- package/dist/build/transformers/fontWeightToNumber.d.ts +9 -0
- package/dist/build/transformers/fontWeightToNumber.js +50 -0
- package/dist/build/transformers/index.d.ts +25 -0
- package/dist/build/transformers/index.js +25 -0
- package/dist/build/transformers/jsonDeprecated.d.ts +8 -0
- package/dist/build/transformers/jsonDeprecated.js +14 -0
- package/dist/build/transformers/namePathToCamelCase.d.ts +8 -0
- package/dist/build/transformers/namePathToCamelCase.js +12 -0
- package/dist/build/transformers/namePathToDotNotation.d.ts +8 -0
- package/dist/build/transformers/namePathToDotNotation.js +31 -0
- package/dist/build/transformers/namePathToFigma.d.ts +9 -0
- package/dist/build/transformers/namePathToFigma.js +21 -0
- package/dist/build/transformers/namePathToKebabCase.d.ts +8 -0
- package/dist/build/transformers/namePathToKebabCase.js +16 -0
- package/dist/build/transformers/namePathToPascalCase.d.ts +8 -0
- package/dist/build/transformers/namePathToPascalCase.js +12 -0
- package/dist/build/transformers/namePathToSlashNotation.d.ts +8 -0
- package/dist/build/transformers/namePathToSlashNotation.js +16 -0
- package/dist/build/transformers/shadowToCss.d.ts +8 -0
- package/dist/build/transformers/shadowToCss.js +34 -0
- package/dist/build/transformers/typographyToCss.d.ts +8 -0
- package/dist/build/transformers/typographyToCss.js +27 -0
- package/dist/build/transformers/utilities/alpha.d.ts +9 -0
- package/dist/build/transformers/utilities/alpha.js +16 -0
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.d.ts +7 -0
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +13 -0
- package/dist/build/transformers/utilities/getTokenValue.d.ts +2 -0
- package/dist/build/transformers/utilities/getTokenValue.js +16 -0
- package/dist/build/transformers/utilities/hasSpaceInString.d.ts +1 -0
- package/dist/build/transformers/utilities/hasSpaceInString.js +6 -0
- package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +2 -0
- package/dist/build/transformers/utilities/hexToRgbaFloat.js +29 -0
- package/dist/build/transformers/utilities/invalidTokenError.d.ts +7 -0
- package/dist/build/transformers/utilities/invalidTokenError.js +27 -0
- package/dist/build/transformers/utilities/isRgbaFloat.d.ts +7 -0
- package/dist/build/transformers/utilities/isRgbaFloat.js +20 -0
- package/dist/build/transformers/utilities/mix.d.ts +5 -0
- package/dist/build/transformers/utilities/mix.js +38 -0
- package/dist/build/transformers/utilities/rgbaFloatToHex.d.ts +6 -0
- package/dist/build/transformers/utilities/rgbaFloatToHex.js +11 -0
- package/dist/build/types/Border.d.ts +5 -0
- package/dist/build/types/BorderTokenValue.d.ts +10 -0
- package/dist/build/types/ColorHex.d.ts +4 -0
- package/dist/build/types/PlatformInitializer.d.ts +11 -0
- package/dist/build/types/Shadow.d.ts +5 -0
- package/dist/build/types/ShadowTokenValue.d.ts +14 -0
- package/dist/build/types/SizeEm.d.ts +4 -0
- package/dist/build/types/SizePx.d.ts +4 -0
- package/dist/build/types/SizeRem.d.ts +4 -0
- package/dist/build/types/StyleDictionaryConfigGenerator.d.ts +15 -0
- package/dist/build/types/TokenBuildInput.d.ts +8 -0
- package/dist/build/types/TypographyTokenValue.d.ts +12 -0
- package/dist/build/types/w3cTransformedToken.d.ts +8 -0
- package/dist/build/utilities/copyFromDir.d.ts +8 -0
- package/dist/build/utilities/copyFromDir.js +31 -0
- package/dist/build/utilities/filterStringArray.d.ts +1 -0
- package/dist/build/utilities/filterStringArray.js +13 -0
- package/dist/build/utilities/getFlag.d.ts +8 -0
- package/dist/build/utilities/getFlag.js +12 -0
- package/dist/build/utilities/index.d.ts +9 -0
- package/dist/build/utilities/index.js +9 -0
- package/dist/build/utilities/joinFriendly.d.ts +1 -0
- package/dist/build/utilities/joinFriendly.js +1 -0
- package/dist/build/utilities/schemaErrorMessage.d.ts +1 -0
- package/dist/build/utilities/schemaErrorMessage.js +1 -0
- package/dist/build/utilities/toCamelCase.d.ts +1 -0
- package/dist/build/utilities/toCamelCase.js +16 -0
- package/dist/build/utilities/toPascalCase.d.ts +1 -0
- package/dist/build/utilities/toPascalCase.js +13 -0
- package/dist/build/utilities/treeWalker.d.ts +8 -0
- package/dist/build/utilities/treeWalker.js +23 -0
- package/dist/build/utilities/upperCaseFirstCharacter.d.ts +8 -0
- package/dist/build/utilities/upperCaseFirstCharacter.js +10 -0
- package/dist/css/base/motion/motion.css +17 -0
- package/dist/css/functional/motion/motion.css +4 -3
- package/dist/css/functional/themes/dark-colorblind.css +58 -38
- package/dist/css/functional/themes/dark-dimmed.css +44 -24
- package/dist/css/functional/themes/dark-high-contrast.css +42 -22
- package/dist/css/functional/themes/dark-tritanopia.css +44 -24
- package/dist/css/functional/themes/dark.css +42 -22
- package/dist/css/functional/themes/light-colorblind.css +60 -40
- package/dist/css/functional/themes/light-high-contrast.css +44 -24
- package/dist/css/functional/themes/light-tritanopia.css +42 -22
- package/dist/css/functional/themes/light.css +42 -22
- package/dist/css/functional/typography/typography.css +43 -43
- package/dist/css/primitives.css +64 -46
- package/dist/docs/base/motion/motion.json +205 -0
- package/dist/docs/functional/motion/motion.json +18 -3
- package/dist/docs/functional/themes/dark-colorblind.json +350 -1114
- package/dist/docs/functional/themes/dark-dimmed.json +364 -1152
- package/dist/docs/functional/themes/dark-high-contrast.json +312 -922
- package/dist/docs/functional/themes/dark-tritanopia.json +344 -1138
- package/dist/docs/functional/themes/dark.json +346 -1206
- package/dist/docs/functional/themes/light-colorblind.json +366 -1140
- package/dist/docs/functional/themes/light-high-contrast.json +335 -949
- package/dist/docs/functional/themes/light-tritanopia.json +311 -1135
- package/dist/docs/functional/themes/light.json +336 -1202
- package/dist/fallbacks/base/motion/motion.json +17 -0
- package/dist/fallbacks/functional/motion/motion.json +1 -0
- package/dist/figma/dimension/dimension.json +518 -518
- package/dist/figma/figma.json +19 -19
- package/dist/figma/scales/dark-dimmed.json +3536 -656
- package/dist/figma/scales/dark-high-constrast.json +3535 -655
- package/dist/figma/scales/dark.json +3371 -491
- package/dist/figma/scales/light-high-constrast.json +3533 -653
- package/dist/figma/scales/light.json +3370 -490
- package/dist/figma/shadows/dark-colorblind.json +285 -285
- package/dist/figma/shadows/dark-dimmed.json +285 -285
- package/dist/figma/shadows/dark-high-contrast.json +285 -285
- package/dist/figma/shadows/dark-tritanopia.json +285 -285
- package/dist/figma/shadows/dark.json +285 -285
- package/dist/figma/shadows/light-colorblind.json +254 -254
- package/dist/figma/shadows/light-high-contrast.json +254 -254
- package/dist/figma/shadows/light-tritanopia.json +254 -254
- package/dist/figma/shadows/light.json +254 -254
- package/dist/figma/themes/dark-colorblind.json +5197 -5068
- package/dist/figma/themes/dark-dimmed.json +5526 -5351
- package/dist/figma/themes/dark-high-contrast.json +4361 -4251
- package/dist/figma/themes/dark-tritanopia.json +5315 -5187
- package/dist/figma/themes/dark.json +5740 -5581
- package/dist/figma/themes/light-colorblind.json +5104 -4929
- package/dist/figma/themes/light-high-contrast.json +4462 -4319
- package/dist/figma/themes/light-tritanopia.json +5176 -5050
- package/dist/figma/themes/light.json +5657 -5500
- package/dist/figma/typography/typography.json +162 -162
- package/dist/internalCss/dark-colorblind.css +58 -38
- package/dist/internalCss/dark-dimmed.css +44 -24
- package/dist/internalCss/dark-high-contrast.css +42 -22
- package/dist/internalCss/dark-tritanopia.css +44 -24
- package/dist/internalCss/dark.css +42 -22
- package/dist/internalCss/light-colorblind.css +60 -40
- package/dist/internalCss/light-high-contrast.css +44 -24
- package/dist/internalCss/light-tritanopia.css +42 -22
- package/dist/internalCss/light.css +42 -22
- package/dist/styleLint/base/motion/motion.json +205 -0
- package/dist/styleLint/functional/motion/motion.json +18 -3
- package/dist/styleLint/functional/themes/dark-colorblind.json +350 -1114
- package/dist/styleLint/functional/themes/dark-dimmed.json +364 -1152
- package/dist/styleLint/functional/themes/dark-high-contrast.json +311 -921
- package/dist/styleLint/functional/themes/dark-tritanopia.json +344 -1138
- package/dist/styleLint/functional/themes/dark.json +346 -1206
- package/dist/styleLint/functional/themes/light-colorblind.json +366 -1140
- package/dist/styleLint/functional/themes/light-high-contrast.json +335 -949
- package/dist/styleLint/functional/themes/light-tritanopia.json +311 -1135
- package/dist/styleLint/functional/themes/light.json +336 -1202
- package/package.json +23 -30
- package/src/tokens/base/motion/easing.json5 +26 -0
- package/src/tokens/base/motion/timing.json5 +50 -0
- package/src/tokens/functional/color/dark/app-dark.json5 +236 -121
- package/src/tokens/functional/color/dark/data-vis-dark.json5 +40 -40
- package/src/tokens/functional/color/dark/display-dark.json5 +95 -95
- package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +1 -9
- package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +40 -27
- package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +56 -30
- package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +37 -14
- package/src/tokens/functional/color/dark/patterns-dark.json +3963 -0
- package/src/tokens/functional/color/dark/patterns-dark.json5 +126 -277
- package/src/tokens/functional/color/dark/primitives-dark.json5 +78 -78
- package/src/tokens/functional/color/dark/syntax-dark.json5 +47 -47
- package/src/tokens/functional/color/light/app-light.json5 +179 -118
- package/src/tokens/functional/color/light/data-vis-light.json5 +40 -40
- package/src/tokens/functional/color/light/display-light.json5 +0 -95
- package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +25 -27
- package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +58 -33
- package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +59 -10
- package/src/tokens/functional/color/light/patterns-light.json5 +126 -276
- package/src/tokens/functional/color/light/primitives-light.json5 +0 -78
- package/src/tokens/functional/color/light/syntax-light.json5 +0 -47
- package/src/tokens/functional/motion/loading.json5 +1 -1
- package/src/tokens/functional/motion/patterns.json5 +9 -2
- package/src/tokens/functional/shadow/dark.json5 +0 -14
- package/src/tokens/functional/shadow/light.json5 +0 -13
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts cubicBezeir tokens array value to a css cubic-bezier
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `duration`
|
|
6
|
+
* @transformer returns a css cubic-bezier function
|
|
7
|
+
*/
|
|
8
|
+
export declare const cubicBezierToCss: Transform;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isCubicBezier } from '../filters/isCubicBezier.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts cubicBezeir tokens array value to a css cubic-bezier
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `duration`
|
|
6
|
+
* @transformer returns a css cubic-bezier function
|
|
7
|
+
*/
|
|
8
|
+
export const cubicBezierToCss = {
|
|
9
|
+
name: 'cubicBezeir/css',
|
|
10
|
+
type: 'value',
|
|
11
|
+
transitive: true,
|
|
12
|
+
filter: isCubicBezier,
|
|
13
|
+
transform: (token, _config) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const value = (_a = token.$value) !== null && _a !== void 0 ? _a : token.value;
|
|
16
|
+
// throw value of more or less than 4 items in array
|
|
17
|
+
if (value.length !== 4 || value.some((item) => typeof item !== 'number')) {
|
|
18
|
+
throw new Error(`Invalid cubicBezier token ${token.path.join('.')}, must be an array with 4 numbers, but got this instead: ${JSON.stringify(value)}`);
|
|
19
|
+
}
|
|
20
|
+
// return value
|
|
21
|
+
return `cubic-bezier(${value.join(',')})`;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts dimension tokens value to pixel value without unit, ignores `em` as they are relative to the font size of the parent element
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `dimension`
|
|
6
|
+
* @transformer returns a float number
|
|
7
|
+
*/
|
|
8
|
+
export declare const dimensionToPixelUnitless: Transform;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isDimension } from '../filters/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description base font size from options or 16
|
|
4
|
+
* @param options
|
|
5
|
+
* @returns number
|
|
6
|
+
*/
|
|
7
|
+
const getBasePxFontSize = (options) => (options && options.basePxFontSize) || 16;
|
|
8
|
+
/**
|
|
9
|
+
* @description checks if token value has a specific unit
|
|
10
|
+
* @param value token value
|
|
11
|
+
* @param unit unit string like px or value
|
|
12
|
+
* @returns boolean
|
|
13
|
+
*/
|
|
14
|
+
const hasUnit = (value, unit) => {
|
|
15
|
+
if (typeof value === 'number') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return value.indexOf(unit) > -1;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @description converts dimension tokens value to pixel value without unit, ignores `em` as they are relative to the font size of the parent element
|
|
22
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
23
|
+
* @matcher matches all tokens of $type `dimension`
|
|
24
|
+
* @transformer returns a float number
|
|
25
|
+
*/
|
|
26
|
+
export const dimensionToPixelUnitless = {
|
|
27
|
+
name: 'dimension/pixelUnitless',
|
|
28
|
+
type: 'value',
|
|
29
|
+
transitive: true,
|
|
30
|
+
filter: isDimension,
|
|
31
|
+
transform: (token, config, options) => {
|
|
32
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
33
|
+
const baseFont = getBasePxFontSize(config);
|
|
34
|
+
const floatVal = parseFloat(token[valueProp]);
|
|
35
|
+
if (isNaN(floatVal)) {
|
|
36
|
+
throw new Error(`Invalid dimension token: '${token.path.join('.')}: ${token[valueProp]}' is not valid and cannot be transform to 'float' \n`);
|
|
37
|
+
}
|
|
38
|
+
if (floatVal === 0) {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
if (hasUnit(token[valueProp], 'rem')) {
|
|
42
|
+
return floatVal * baseFont;
|
|
43
|
+
}
|
|
44
|
+
if (hasUnit(token[valueProp], 'px')) {
|
|
45
|
+
return floatVal;
|
|
46
|
+
}
|
|
47
|
+
return token[valueProp];
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `dimension`
|
|
6
|
+
* @transformer returns a `rem` string
|
|
7
|
+
*/
|
|
8
|
+
export declare const dimensionToRem: Transform;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isDimension } from '../filters/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description base font size from options or 16
|
|
4
|
+
* @param options
|
|
5
|
+
* @returns number
|
|
6
|
+
*/
|
|
7
|
+
const getBasePxFontSize = (options) => (options && options.basePxFontSize) || 16;
|
|
8
|
+
/**
|
|
9
|
+
* @description checks if token value has a specific unit
|
|
10
|
+
* @param value token value
|
|
11
|
+
* @param unit unit string like px or value
|
|
12
|
+
* @returns boolean
|
|
13
|
+
*/
|
|
14
|
+
const hasUnit = (value, unit) => {
|
|
15
|
+
if (typeof value === 'number') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return value.indexOf(unit) > -1;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
|
|
22
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
23
|
+
* @matcher matches all tokens of $type `dimension`
|
|
24
|
+
* @transformer returns a `rem` string
|
|
25
|
+
*/
|
|
26
|
+
export const dimensionToRem = {
|
|
27
|
+
name: 'dimension/rem',
|
|
28
|
+
type: 'value',
|
|
29
|
+
transitive: true,
|
|
30
|
+
filter: isDimension,
|
|
31
|
+
transform: (token, config, options) => {
|
|
32
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
33
|
+
const baseFont = getBasePxFontSize(config);
|
|
34
|
+
const floatVal = parseFloat(token[valueProp]);
|
|
35
|
+
if (isNaN(floatVal)) {
|
|
36
|
+
throw new Error(`Invalid dimension token: '${token.name}: ${token[valueProp]}' is not valid and cannot be transform to 'rem' \n`);
|
|
37
|
+
}
|
|
38
|
+
if (floatVal === 0) {
|
|
39
|
+
return '0';
|
|
40
|
+
}
|
|
41
|
+
if (hasUnit(token[valueProp], 'rem') || hasUnit(token[valueProp], 'em')) {
|
|
42
|
+
return token[valueProp];
|
|
43
|
+
}
|
|
44
|
+
return `${floatVal / baseFont}rem`;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `dimension`
|
|
6
|
+
* @transformer returns an array with the `rem` and `pixel` string
|
|
7
|
+
*/
|
|
8
|
+
export declare const dimensionToRemPxArray: Transform;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isDimension } from '../filters/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description base font size from options or 16
|
|
4
|
+
* @param options
|
|
5
|
+
* @returns number
|
|
6
|
+
*/
|
|
7
|
+
const getBasePxFontSize = (options) => (options && options.basePxFontSize) || 16;
|
|
8
|
+
/**
|
|
9
|
+
* @description checks if token value has a specific unit
|
|
10
|
+
* @param value token value
|
|
11
|
+
* @param unit unit string like px or value
|
|
12
|
+
* @returns boolean
|
|
13
|
+
*/
|
|
14
|
+
const hasUnit = (value, unit) => {
|
|
15
|
+
if (typeof value === 'number') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return value.indexOf(unit) > -1;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
|
|
22
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
23
|
+
* @matcher matches all tokens of $type `dimension`
|
|
24
|
+
* @transformer returns an array with the `rem` and `pixel` string
|
|
25
|
+
*/
|
|
26
|
+
export const dimensionToRemPxArray = {
|
|
27
|
+
name: 'dimension/remPxArray',
|
|
28
|
+
type: 'value',
|
|
29
|
+
transitive: true,
|
|
30
|
+
filter: isDimension,
|
|
31
|
+
transform: (token, config, options) => {
|
|
32
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
33
|
+
const baseFont = getBasePxFontSize(config);
|
|
34
|
+
const floatVal = parseFloat(token[valueProp]);
|
|
35
|
+
if (isNaN(floatVal)) {
|
|
36
|
+
throw new Error(`Invalid dimension token: '${token.name}: ${token[valueProp]}' is not valid and cannot be transform to 'rem' \n`);
|
|
37
|
+
}
|
|
38
|
+
if (floatVal === 0) {
|
|
39
|
+
return ['0', '0'];
|
|
40
|
+
}
|
|
41
|
+
if (hasUnit(token[valueProp], 'rem') || hasUnit(token[valueProp], 'em')) {
|
|
42
|
+
return [token.value, `${floatVal * baseFont}px`];
|
|
43
|
+
}
|
|
44
|
+
return [`${floatVal / baseFont}rem`, `${floatVal}px`];
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts duration tokens string value to number with `ms` unit
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `duration`
|
|
6
|
+
* @transformer returns a css duration
|
|
7
|
+
*/
|
|
8
|
+
export declare const durationToCss: Transform;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isDuration } from '../filters/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts duration tokens string value to number with `ms` unit
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `duration`
|
|
6
|
+
* @transformer returns a css duration
|
|
7
|
+
*/
|
|
8
|
+
export const durationToCss = {
|
|
9
|
+
name: 'duration/css',
|
|
10
|
+
type: 'value',
|
|
11
|
+
transitive: true,
|
|
12
|
+
filter: isDuration,
|
|
13
|
+
transform: (token, _config, options) => {
|
|
14
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
15
|
+
// throw an error if token value is not a string or does not end with `ms`
|
|
16
|
+
if (typeof token[valueProp] !== `string` || !(token[valueProp].endsWith(`ms`) || token[valueProp].endsWith(`s`))) {
|
|
17
|
+
throw new Error(`duration token value must be a string with an "ms" || "s" unit, invalid token: ${token.name} with value: ${token[valueProp]}`);
|
|
18
|
+
}
|
|
19
|
+
// get value
|
|
20
|
+
let value = parseInt(token[valueProp].replace('ms', ''));
|
|
21
|
+
let unit = `ms`;
|
|
22
|
+
if (value >= 1000) {
|
|
23
|
+
value = value / 1000;
|
|
24
|
+
unit = `s`;
|
|
25
|
+
}
|
|
26
|
+
// return value
|
|
27
|
+
return `${value}${unit}`;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description retrieves figma attributes from token and adds them to attributes
|
|
4
|
+
* @type attribute transformer — [StyleDictionary.AttributeTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens
|
|
6
|
+
* @transformer returns ab object of figma attributes
|
|
7
|
+
*/
|
|
8
|
+
export declare const figmaAttributes: Transform;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const figmaScopes = {
|
|
2
|
+
all: ['ALL_SCOPES'],
|
|
3
|
+
radius: ['CORNER_RADIUS'],
|
|
4
|
+
size: ['WIDTH_HEIGHT'],
|
|
5
|
+
gap: ['GAP'],
|
|
6
|
+
bgColor: ['FRAME_FILL', 'SHAPE_FILL'],
|
|
7
|
+
fgColor: ['TEXT_FILL', 'SHAPE_FILL'],
|
|
8
|
+
effectColor: ['EFFECT_COLOR'],
|
|
9
|
+
effectFloat: ['EFFECT_FLOAT'],
|
|
10
|
+
borderColor: ['STROKE_COLOR'],
|
|
11
|
+
borderWidth: ['STROKE_FLOAT'],
|
|
12
|
+
opacity: ['OPACITY'],
|
|
13
|
+
fontFamily: ['FONT_FAMILY'],
|
|
14
|
+
fontStyle: ['FONT_STYLE'],
|
|
15
|
+
fontWeight: ['FONT_WEIGHT'],
|
|
16
|
+
fontSize: ['FONT_SIZE'],
|
|
17
|
+
lineHeight: ['LINE_HEIGHT'],
|
|
18
|
+
letterSpacing: ['LETTER_SPACING'],
|
|
19
|
+
paragraphSpacing: ['PARAGRAPH_SPACING'],
|
|
20
|
+
paragraphIndent: ['PARAGRAPH_INDENT'],
|
|
21
|
+
};
|
|
22
|
+
const getScopes = (scopes) => {
|
|
23
|
+
if (typeof scopes === 'string')
|
|
24
|
+
scopes = [scopes];
|
|
25
|
+
if (Array.isArray(scopes))
|
|
26
|
+
return scopes
|
|
27
|
+
.map(scope => {
|
|
28
|
+
if (scope in figmaScopes)
|
|
29
|
+
return figmaScopes[scope];
|
|
30
|
+
throw new Error(`Invalid scope: ${scope}`);
|
|
31
|
+
})
|
|
32
|
+
.flat();
|
|
33
|
+
return ['ALL_SCOPES'];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @description retrieves figma attributes from token and adds them to attributes
|
|
37
|
+
* @type attribute transformer — [StyleDictionary.AttributeTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
38
|
+
* @matcher matches all tokens
|
|
39
|
+
* @transformer returns ab object of figma attributes
|
|
40
|
+
*/
|
|
41
|
+
export const figmaAttributes = {
|
|
42
|
+
name: 'figma/attributes',
|
|
43
|
+
type: `attribute`,
|
|
44
|
+
transform: (token, platform = {}) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const { modeOverride, collection, scopes, group, codeSyntax } = ((_a = token.$extensions) === null || _a === void 0 ? void 0 : _a['org.primer.figma']) || {};
|
|
47
|
+
return {
|
|
48
|
+
mode: modeOverride || ((_b = platform.options) === null || _b === void 0 ? void 0 : _b.mode) || 'default',
|
|
49
|
+
collection,
|
|
50
|
+
group: group || collection,
|
|
51
|
+
scopes: getScopes(scopes),
|
|
52
|
+
codeSyntax,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Transform, TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* takes a value and returns it if its a px string if it is a float and the token has a fontSize value in extensions['org.primer.data']
|
|
4
|
+
* @param value
|
|
5
|
+
* @returns string
|
|
6
|
+
*/
|
|
7
|
+
export declare const convertFloatToPixel: (token: TransformedToken, unitless?: boolean) => any;
|
|
8
|
+
/**
|
|
9
|
+
* @description converts a float value to a pixel value based on the provided fontSize on the tokersn extension
|
|
10
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
11
|
+
* @matcher matches all tokens of $type `isNumber`
|
|
12
|
+
* @transformer returns a pixel string
|
|
13
|
+
*/
|
|
14
|
+
export declare const floatToPixel: Transform;
|
|
15
|
+
export declare const floatToPixelUnitless: Transform;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isNumber } from '../filters/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* takes a value and returns it if its a px string if it is a float and the token has a fontSize value in extensions['org.primer.data']
|
|
4
|
+
* @param value
|
|
5
|
+
* @returns string
|
|
6
|
+
*/
|
|
7
|
+
export const convertFloatToPixel = (token, unitless = false) => {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9
|
+
// short circut if value is not a number
|
|
10
|
+
if (typeof token.value !== 'number' ||
|
|
11
|
+
!((_b = (_a = token.$extensions) === null || _a === void 0 ? void 0 : _a['org.primer.data']) === null || _b === void 0 ? void 0 : _b.fontSize) ||
|
|
12
|
+
typeof ((_d = (_c = token.$extensions) === null || _c === void 0 ? void 0 : _c['org.primer.data']) === null || _d === void 0 ? void 0 : _d.fontSize) !== 'number') {
|
|
13
|
+
return token.value;
|
|
14
|
+
}
|
|
15
|
+
// convert value
|
|
16
|
+
const convertedValue = ((_f = (_e = token.$extensions) === null || _e === void 0 ? void 0 : _e['org.primer.data']) === null || _f === void 0 ? void 0 : _f.fontSize) * token.value;
|
|
17
|
+
// return converted value
|
|
18
|
+
return convertedValue === 0 ? 0 : unitless ? Math.round(convertedValue) : `${Math.round(convertedValue)}px`;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @description converts a float value to a pixel value based on the provided fontSize on the tokersn extension
|
|
22
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
23
|
+
* @matcher matches all tokens of $type `isNumber`
|
|
24
|
+
* @transformer returns a pixel string
|
|
25
|
+
*/
|
|
26
|
+
export const floatToPixel = {
|
|
27
|
+
name: 'float/pixel',
|
|
28
|
+
type: 'value',
|
|
29
|
+
transitive: true,
|
|
30
|
+
filter: isNumber,
|
|
31
|
+
transform: (token) => convertFloatToPixel(token),
|
|
32
|
+
};
|
|
33
|
+
export const floatToPixelUnitless = {
|
|
34
|
+
name: 'float/pixelUnitless',
|
|
35
|
+
type: 'value',
|
|
36
|
+
transitive: true,
|
|
37
|
+
filter: isNumber,
|
|
38
|
+
transform: (token) => convertFloatToPixel(token, true),
|
|
39
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
|
|
4
|
+
* @param value
|
|
5
|
+
* @returns string
|
|
6
|
+
*/
|
|
7
|
+
export declare const parseFontFamily: (value: unknown) => string;
|
|
8
|
+
/**
|
|
9
|
+
* @description converts fontFamily tokens value to string
|
|
10
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
11
|
+
* @matcher matches all tokens of $type `fontFamily`
|
|
12
|
+
* @transformer returns a string
|
|
13
|
+
*/
|
|
14
|
+
export declare const fontFamilyToCss: Transform;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isFontFamily } from '../filters/index.js';
|
|
2
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
3
|
+
import { hasSpaceInString } from './utilities/hasSpaceInString.js';
|
|
4
|
+
/**
|
|
5
|
+
* takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
|
|
6
|
+
* @param value
|
|
7
|
+
* @returns string
|
|
8
|
+
*/
|
|
9
|
+
export const parseFontFamily = (value) => {
|
|
10
|
+
if (typeof value === 'string') {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return value
|
|
15
|
+
.map((string) => {
|
|
16
|
+
if (typeof string !== 'string') {
|
|
17
|
+
throw new Error(`Invalid value in array ${string}, must be a string`);
|
|
18
|
+
}
|
|
19
|
+
return hasSpaceInString(string) ? `'${string}'` : string;
|
|
20
|
+
})
|
|
21
|
+
.join(', ');
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Invalid value ${value}, should be a string or array of strings`);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @description converts fontFamily tokens value to string
|
|
27
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
28
|
+
* @matcher matches all tokens of $type `fontFamily`
|
|
29
|
+
* @transformer returns a string
|
|
30
|
+
*/
|
|
31
|
+
export const fontFamilyToCss = {
|
|
32
|
+
name: 'fontFamily/css',
|
|
33
|
+
type: 'value',
|
|
34
|
+
transitive: true,
|
|
35
|
+
filter: isFontFamily,
|
|
36
|
+
transform: (token) => parseFontFamily(getTokenValue(token)),
|
|
37
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Config, Transform, TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
|
|
4
|
+
* @param value
|
|
5
|
+
* @returns string
|
|
6
|
+
*/
|
|
7
|
+
export declare const parseFontFamily: (token: TransformedToken, fontFamilies: Record<string, string> | undefined, options: Config) => string;
|
|
8
|
+
/**
|
|
9
|
+
* @description converts fontFamily tokens value to string
|
|
10
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
11
|
+
* @matcher matches all tokens of $type `fontFamily`
|
|
12
|
+
* @transformer returns a string
|
|
13
|
+
*/
|
|
14
|
+
export declare const fontFamilyToFigma: Transform;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { isFontFamily } from '../filters/index.js';
|
|
2
|
+
import { hasSpaceInString } from './utilities/hasSpaceInString.js';
|
|
3
|
+
/**
|
|
4
|
+
* takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
|
|
5
|
+
* @param value
|
|
6
|
+
* @returns string
|
|
7
|
+
*/
|
|
8
|
+
export const parseFontFamily = (token, fontFamilies = {}, options) => {
|
|
9
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
10
|
+
// return value from fontFamilies
|
|
11
|
+
if (token.name in fontFamilies) {
|
|
12
|
+
return fontFamilies[token.name];
|
|
13
|
+
}
|
|
14
|
+
// return string
|
|
15
|
+
if (typeof token[valueProp] === 'string') {
|
|
16
|
+
return token[valueProp];
|
|
17
|
+
}
|
|
18
|
+
// return stringified array
|
|
19
|
+
if (Array.isArray(token[valueProp])) {
|
|
20
|
+
return token[valueProp]
|
|
21
|
+
.map((string) => {
|
|
22
|
+
if (typeof string !== 'string') {
|
|
23
|
+
throw new Error(`Invalid value in array ${string}, must be a string`);
|
|
24
|
+
}
|
|
25
|
+
return hasSpaceInString(string) ? `'${string}'` : string;
|
|
26
|
+
})
|
|
27
|
+
.join(', ');
|
|
28
|
+
}
|
|
29
|
+
// invalid value
|
|
30
|
+
throw new Error(`Invalid value ${token[valueProp]}, should be a string or array of strings`);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @description converts fontFamily tokens value to string
|
|
34
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
35
|
+
* @matcher matches all tokens of $type `fontFamily`
|
|
36
|
+
* @transformer returns a string
|
|
37
|
+
*/
|
|
38
|
+
export const fontFamilyToFigma = {
|
|
39
|
+
name: 'fontFamily/figma',
|
|
40
|
+
type: 'value',
|
|
41
|
+
transitive: true,
|
|
42
|
+
filter: isFontFamily,
|
|
43
|
+
transform: (token, platform, options) => { var _a; return parseFontFamily(token, (_a = platform.options) === null || _a === void 0 ? void 0 : _a.fontFamilies, options); },
|
|
44
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
export declare const parseFontWeight: (value: unknown) => number;
|
|
3
|
+
/**
|
|
4
|
+
* @description converts fontWeight tokens value to numeric value
|
|
5
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
6
|
+
* @matcher matches all tokens of $type `fontWeight`
|
|
7
|
+
* @transformer returns a number
|
|
8
|
+
*/
|
|
9
|
+
export declare const fontWeightToNumber: Transform;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isFontWeight } from '../filters/index.js';
|
|
2
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
3
|
+
const fontWeightMatrix = {
|
|
4
|
+
'100': ['thin', 'hairline'],
|
|
5
|
+
'200': ['extra-light', 'ultra-light'],
|
|
6
|
+
'300': ['light'],
|
|
7
|
+
'400': ['normal', 'regular', 'book'],
|
|
8
|
+
'500': ['medium'],
|
|
9
|
+
'600': ['semi-bold', 'demi-bold'],
|
|
10
|
+
'700': ['bold'],
|
|
11
|
+
'800': ['extra-bold', 'ultra-bold'],
|
|
12
|
+
'900': ['black', 'heavy'],
|
|
13
|
+
'950': ['extra-black', 'ultra-black'],
|
|
14
|
+
};
|
|
15
|
+
export const parseFontWeight = (value) => {
|
|
16
|
+
// throw on anything but string and number
|
|
17
|
+
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
18
|
+
throw new Error(`Invalid value ${value}, should be a number or fontWeight string`);
|
|
19
|
+
}
|
|
20
|
+
// valid string
|
|
21
|
+
if (typeof value === 'string') {
|
|
22
|
+
const key = Object.keys(fontWeightMatrix).find((k) => fontWeightMatrix[k].includes(value));
|
|
23
|
+
if (key !== undefined) {
|
|
24
|
+
return parseInt(key);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// if number as string
|
|
28
|
+
if (typeof value === 'string' && typeof parseInt(value) === 'number' && !isNaN(parseInt(value))) {
|
|
29
|
+
value = parseInt(value);
|
|
30
|
+
}
|
|
31
|
+
// return if valid numver
|
|
32
|
+
if (typeof value === 'number' && value > 0 && value <= 1000) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
// invalid value
|
|
36
|
+
throw new Error(`Invalid value ${value}, should be a number or fontWeight string`);
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @description converts fontWeight tokens value to numeric value
|
|
40
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
41
|
+
* @matcher matches all tokens of $type `fontWeight`
|
|
42
|
+
* @transformer returns a number
|
|
43
|
+
*/
|
|
44
|
+
export const fontWeightToNumber = {
|
|
45
|
+
name: 'fontWeight/number',
|
|
46
|
+
type: 'value',
|
|
47
|
+
transitive: true,
|
|
48
|
+
filter: isFontWeight,
|
|
49
|
+
transform: (token) => parseFontWeight(getTokenValue(token)),
|
|
50
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { borderToCss } from './borderToCss.js';
|
|
2
|
+
export { colorToHex } from './colorToHex.js';
|
|
3
|
+
export { colorToHexMix } from './colorToHexMix.js';
|
|
4
|
+
export { colorToRgbAlpha } from './colorToRgbAlpha.js';
|
|
5
|
+
export { colorToRgbaFloat } from './colorToRgbaFloat.js';
|
|
6
|
+
export { cubicBezierToCss } from './cubicBezierToCss.js';
|
|
7
|
+
export { floatToPixel } from './floatToPixel.js';
|
|
8
|
+
export { floatToPixelUnitless } from './floatToPixel.js';
|
|
9
|
+
export { dimensionToRem } from './dimensionToRem.js';
|
|
10
|
+
export { dimensionToRemPxArray } from './dimensionToRemPxArray.js';
|
|
11
|
+
export { dimensionToPixelUnitless } from './dimensionToPixelUnitless.js';
|
|
12
|
+
export { durationToCss } from './durationToCss.js';
|
|
13
|
+
export { figmaAttributes } from './figmaAttributes.js';
|
|
14
|
+
export { fontFamilyToCss } from './fontFamilyToCss.js';
|
|
15
|
+
export { fontFamilyToFigma } from './fontFamilyToFigma.js';
|
|
16
|
+
export { fontWeightToNumber } from './fontWeightToNumber.js';
|
|
17
|
+
export { jsonDeprecated } from './jsonDeprecated.js';
|
|
18
|
+
export { namePathToCamelCase } from './namePathToCamelCase.js';
|
|
19
|
+
export { namePathToPascalCase } from './namePathToPascalCase.js';
|
|
20
|
+
export { namePathToDotNotation } from './namePathToDotNotation.js';
|
|
21
|
+
export { namePathToFigma } from './namePathToFigma.js';
|
|
22
|
+
export { namePathToKebabCase } from './namePathToKebabCase.js';
|
|
23
|
+
export { namePathToSlashNotation } from './namePathToSlashNotation.js';
|
|
24
|
+
export { shadowToCss } from './shadowToCss.js';
|
|
25
|
+
export { typographyToCss } from './typographyToCss.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { borderToCss } from './borderToCss.js';
|
|
2
|
+
export { colorToHex } from './colorToHex.js';
|
|
3
|
+
export { colorToHexMix } from './colorToHexMix.js';
|
|
4
|
+
export { colorToRgbAlpha } from './colorToRgbAlpha.js';
|
|
5
|
+
export { colorToRgbaFloat } from './colorToRgbaFloat.js';
|
|
6
|
+
export { cubicBezierToCss } from './cubicBezierToCss.js';
|
|
7
|
+
export { floatToPixel } from './floatToPixel.js';
|
|
8
|
+
export { floatToPixelUnitless } from './floatToPixel.js';
|
|
9
|
+
export { dimensionToRem } from './dimensionToRem.js';
|
|
10
|
+
export { dimensionToRemPxArray } from './dimensionToRemPxArray.js';
|
|
11
|
+
export { dimensionToPixelUnitless } from './dimensionToPixelUnitless.js';
|
|
12
|
+
export { durationToCss } from './durationToCss.js';
|
|
13
|
+
export { figmaAttributes } from './figmaAttributes.js';
|
|
14
|
+
export { fontFamilyToCss } from './fontFamilyToCss.js';
|
|
15
|
+
export { fontFamilyToFigma } from './fontFamilyToFigma.js';
|
|
16
|
+
export { fontWeightToNumber } from './fontWeightToNumber.js';
|
|
17
|
+
export { jsonDeprecated } from './jsonDeprecated.js';
|
|
18
|
+
export { namePathToCamelCase } from './namePathToCamelCase.js';
|
|
19
|
+
export { namePathToPascalCase } from './namePathToPascalCase.js';
|
|
20
|
+
export { namePathToDotNotation } from './namePathToDotNotation.js';
|
|
21
|
+
export { namePathToFigma } from './namePathToFigma.js';
|
|
22
|
+
export { namePathToKebabCase } from './namePathToKebabCase.js';
|
|
23
|
+
export { namePathToSlashNotation } from './namePathToSlashNotation.js';
|
|
24
|
+
export { shadowToCss } from './shadowToCss.js';
|
|
25
|
+
export { typographyToCss } from './typographyToCss.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description replaces tokens value with content of tokens `deprecated` property
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens with a `deprecated` property
|
|
6
|
+
* @transformer returns `string` specified in `token.deprecated` or `null`
|
|
7
|
+
*/
|
|
8
|
+
export declare const jsonDeprecated: Transform;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isDeprecated } from '../filters/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description replaces tokens value with content of tokens `deprecated` property
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens with a `deprecated` property
|
|
6
|
+
* @transformer returns `string` specified in `token.deprecated` or `null`
|
|
7
|
+
*/
|
|
8
|
+
export const jsonDeprecated = {
|
|
9
|
+
name: 'json/deprecated',
|
|
10
|
+
type: 'value',
|
|
11
|
+
transitive: true,
|
|
12
|
+
filter: isDeprecated,
|
|
13
|
+
transform: (token) => typeof token.$deprecated === 'string' ? token.$deprecated.replace(/[{}]/g, '') : null,
|
|
14
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a camelCase string, preserves casing of parts
|
|
4
|
+
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher omitted to match all tokens
|
|
6
|
+
* @transformer returns `string` camelCase
|
|
7
|
+
*/
|
|
8
|
+
export declare const namePathToCamelCase: Transform;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { toCamelCase } from '../utilities/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a camelCase string, preserves casing of parts
|
|
4
|
+
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher omitted to match all tokens
|
|
6
|
+
* @transformer returns `string` camelCase
|
|
7
|
+
*/
|
|
8
|
+
export const namePathToCamelCase = {
|
|
9
|
+
name: 'name/pathToCamelCase',
|
|
10
|
+
type: 'name',
|
|
11
|
+
transform: (token, options) => toCamelCase([(options === null || options === void 0 ? void 0 : options.prefix) || '', ...token.path]),
|
|
12
|
+
};
|