@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
package/README.md
CHANGED
|
@@ -138,10 +138,10 @@ In this case you can create the follwing structure. The `@` will be removed from
|
|
|
138
138
|
bgColor: {
|
|
139
139
|
accent: {
|
|
140
140
|
'@': {
|
|
141
|
-
// values for accent (default)
|
|
141
|
+
// values for bgColor-accent (default)
|
|
142
142
|
},
|
|
143
143
|
muted: {
|
|
144
|
-
// values for accent-muted
|
|
144
|
+
// values for bgColor-accent-muted
|
|
145
145
|
},
|
|
146
146
|
},
|
|
147
147
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import StyleDictionary from 'style-dictionary';
|
|
2
|
+
/**
|
|
3
|
+
* @name {@link PrimerStyleDictionary}
|
|
4
|
+
* @description Returns style dictionary object with primer preset that includes parsers, formats and transformers
|
|
5
|
+
* @formats [javascript/esm](https://github.com/primer/primitives/blob/main/config/formats/javascript-esm.ts), [javascript/commonJs](https://github.com/primer/primitives/blob/main/config/formats/javascript-commonJs.ts), [typescript/export-definition](https://github.com/primer/primitives/blob/main/config/formats/typescript-export-defition.ts)
|
|
6
|
+
* @transformers [color/rgbAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-rgb-alpha.ts), [color/hexAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex-alpha.ts), [color/hex](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex6.ts), [json/deprecated](https://github.com/primer/primitives/blob/main/config/tranformers/json-deprecated.ts), [name/pathToDotNotation](https://github.com/primer/primitives/blob/main/config/tranformers/name-path-to-dot-notation.ts)
|
|
7
|
+
*/
|
|
8
|
+
export declare const PrimerStyleDictionary: StyleDictionary;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import StyleDictionary from 'style-dictionary';
|
|
2
|
+
import { borderToCss, colorToRgbAlpha, colorToHex, colorToHexMix, colorToRgbaFloat, cubicBezierToCss, dimensionToRem, dimensionToPixelUnitless, durationToCss, figmaAttributes, fontFamilyToCss, fontFamilyToFigma, fontWeightToNumber, jsonDeprecated, namePathToDotNotation, namePathToCamelCase, namePathToPascalCase, namePathToKebabCase, namePathToSlashNotation, namePathToFigma, shadowToCss, typographyToCss, dimensionToRemPxArray, floatToPixel, floatToPixelUnitless, } from './transformers/index.js';
|
|
3
|
+
import { javascriptCommonJs, javascriptEsm, typescriptExportDefinition, jsonNestedPrefixed, cssCustomMedia, jsonOneDimensional, jsonPostCssFallback, cssAdvanced, jsonFigma, } from './formats/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* @name {@link PrimerStyleDictionary}
|
|
6
|
+
* @description Returns style dictionary object with primer preset that includes parsers, formats and transformers
|
|
7
|
+
* @formats [javascript/esm](https://github.com/primer/primitives/blob/main/config/formats/javascript-esm.ts), [javascript/commonJs](https://github.com/primer/primitives/blob/main/config/formats/javascript-commonJs.ts), [typescript/export-definition](https://github.com/primer/primitives/blob/main/config/formats/typescript-export-defition.ts)
|
|
8
|
+
* @transformers [color/rgbAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-rgb-alpha.ts), [color/hexAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex-alpha.ts), [color/hex](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex6.ts), [json/deprecated](https://github.com/primer/primitives/blob/main/config/tranformers/json-deprecated.ts), [name/pathToDotNotation](https://github.com/primer/primitives/blob/main/config/tranformers/name-path-to-dot-notation.ts)
|
|
9
|
+
*/
|
|
10
|
+
export const PrimerStyleDictionary = new StyleDictionary();
|
|
11
|
+
/**
|
|
12
|
+
* Formats
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
PrimerStyleDictionary.registerFormat({
|
|
16
|
+
name: 'css/advanced',
|
|
17
|
+
format: cssAdvanced,
|
|
18
|
+
});
|
|
19
|
+
PrimerStyleDictionary.registerFormat({
|
|
20
|
+
name: 'css/customMedia',
|
|
21
|
+
format: cssCustomMedia,
|
|
22
|
+
});
|
|
23
|
+
PrimerStyleDictionary.registerFormat({
|
|
24
|
+
name: 'javascript/esm',
|
|
25
|
+
format: javascriptEsm,
|
|
26
|
+
});
|
|
27
|
+
PrimerStyleDictionary.registerFormat({
|
|
28
|
+
name: 'javascript/commonJs',
|
|
29
|
+
format: javascriptCommonJs,
|
|
30
|
+
});
|
|
31
|
+
PrimerStyleDictionary.registerFormat({
|
|
32
|
+
name: 'typescript/export-definition',
|
|
33
|
+
format: typescriptExportDefinition,
|
|
34
|
+
});
|
|
35
|
+
PrimerStyleDictionary.registerFormat({
|
|
36
|
+
name: 'json/nested-prefixed',
|
|
37
|
+
format: jsonNestedPrefixed,
|
|
38
|
+
});
|
|
39
|
+
PrimerStyleDictionary.registerFormat({
|
|
40
|
+
name: 'json/one-dimensional',
|
|
41
|
+
format: jsonOneDimensional,
|
|
42
|
+
});
|
|
43
|
+
PrimerStyleDictionary.registerFormat({
|
|
44
|
+
name: 'json/postCss-fallback',
|
|
45
|
+
format: jsonPostCssFallback,
|
|
46
|
+
});
|
|
47
|
+
PrimerStyleDictionary.registerFormat({
|
|
48
|
+
name: 'json/figma',
|
|
49
|
+
format: jsonFigma,
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Transformers
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
PrimerStyleDictionary.registerTransform(colorToRgbAlpha);
|
|
56
|
+
PrimerStyleDictionary.registerTransform(colorToRgbaFloat);
|
|
57
|
+
PrimerStyleDictionary.registerTransform(colorToHexMix);
|
|
58
|
+
PrimerStyleDictionary.registerTransform(colorToHex);
|
|
59
|
+
PrimerStyleDictionary.registerTransform(cubicBezierToCss);
|
|
60
|
+
PrimerStyleDictionary.registerTransform(floatToPixel);
|
|
61
|
+
PrimerStyleDictionary.registerTransform(floatToPixelUnitless);
|
|
62
|
+
PrimerStyleDictionary.registerTransform(dimensionToRem);
|
|
63
|
+
PrimerStyleDictionary.registerTransform(dimensionToRemPxArray);
|
|
64
|
+
PrimerStyleDictionary.registerTransform(dimensionToPixelUnitless);
|
|
65
|
+
PrimerStyleDictionary.registerTransform(durationToCss);
|
|
66
|
+
PrimerStyleDictionary.registerTransform(figmaAttributes);
|
|
67
|
+
PrimerStyleDictionary.registerTransform(jsonDeprecated);
|
|
68
|
+
PrimerStyleDictionary.registerTransform(namePathToCamelCase);
|
|
69
|
+
PrimerStyleDictionary.registerTransform(namePathToPascalCase);
|
|
70
|
+
PrimerStyleDictionary.registerTransform(namePathToDotNotation);
|
|
71
|
+
PrimerStyleDictionary.registerTransform(namePathToFigma);
|
|
72
|
+
PrimerStyleDictionary.registerTransform(namePathToCamelCase);
|
|
73
|
+
PrimerStyleDictionary.registerTransform(namePathToKebabCase);
|
|
74
|
+
PrimerStyleDictionary.registerTransform(namePathToSlashNotation);
|
|
75
|
+
PrimerStyleDictionary.registerTransform(shadowToCss);
|
|
76
|
+
PrimerStyleDictionary.registerTransform(borderToCss);
|
|
77
|
+
PrimerStyleDictionary.registerTransform(typographyToCss);
|
|
78
|
+
PrimerStyleDictionary.registerTransform(fontWeightToNumber);
|
|
79
|
+
PrimerStyleDictionary.registerTransform(fontFamilyToCss);
|
|
80
|
+
PrimerStyleDictionary.registerTransform(fontFamilyToFigma);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { isBorder } from './isBorder.js';
|
|
2
|
+
export { isColor } from './isColor.js';
|
|
3
|
+
export { isColorWithAlpha } from './isColorWithAlpha.js';
|
|
4
|
+
export { isColorWithMix } from './isColorWithMix.js';
|
|
5
|
+
export { isDimension } from './isDimension.js';
|
|
6
|
+
export { isDeprecated } from './isDeprecated.js';
|
|
7
|
+
export { isDuration } from './isDuration.js';
|
|
8
|
+
export { isFromFile } from './isFromFile.js';
|
|
9
|
+
export { isFontFamily } from './isFontFamily.js';
|
|
10
|
+
export { isFontWeight } from './isFontWeight.js';
|
|
11
|
+
export { isNumber } from './isNumber.js';
|
|
12
|
+
export { isShadow } from './isShadow.js';
|
|
13
|
+
export { isSource } from './isSource.js';
|
|
14
|
+
export { isTypography } from './isTypography.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { isBorder } from './isBorder.js';
|
|
2
|
+
export { isColor } from './isColor.js';
|
|
3
|
+
export { isColorWithAlpha } from './isColorWithAlpha.js';
|
|
4
|
+
export { isColorWithMix } from './isColorWithMix.js';
|
|
5
|
+
export { isDimension } from './isDimension.js';
|
|
6
|
+
export { isDeprecated } from './isDeprecated.js';
|
|
7
|
+
export { isDuration } from './isDuration.js';
|
|
8
|
+
export { isFromFile } from './isFromFile.js';
|
|
9
|
+
export { isFontFamily } from './isFontFamily.js';
|
|
10
|
+
export { isFontWeight } from './isFontWeight.js';
|
|
11
|
+
export { isNumber } from './isNumber.js';
|
|
12
|
+
export { isShadow } from './isShadow.js';
|
|
13
|
+
export { isSource } from './isSource.js';
|
|
14
|
+
export { isTypography } from './isTypography.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `border`
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isBorder: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `border`
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isBorder = (token) => {
|
|
7
|
+
return token.$type === 'border';
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `color`
|
|
4
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isColor: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `color`
|
|
3
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isColor = (token) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const typeValue = (_a = token.$type) !== null && _a !== void 0 ? _a : token.type;
|
|
9
|
+
// if (token.path.join('-') === 'control-transparent-bgColor-selected') {
|
|
10
|
+
// console.log(typeValue === 'color', token)
|
|
11
|
+
// }
|
|
12
|
+
return typeValue === 'color';
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is color with an alpha value
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isColorWithAlpha: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isColor } from './isColor.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is color with an alpha value
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export const isColorWithAlpha = (token) => {
|
|
8
|
+
return isColor(token) && token.alpha !== undefined && typeof token.alpha === 'number';
|
|
9
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is color and has a mix property
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isColorWithMix: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isColor } from './isColor.js';
|
|
2
|
+
const throwError = (token) => {
|
|
3
|
+
throw new Error(`Invalid mix property on token: ${token.name}. "mix.color": ${token.mix.color}, "mix.weight": ${typeof token.mix.weight === 'string' ? `"${token.mix.weight}" (string)` : token.mix.weight} must be a number between 0 and 1. In file: "${token.filePath}".`);
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* @description Checks if token is color and has a mix property
|
|
7
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
8
|
+
* @returns boolean
|
|
9
|
+
*/
|
|
10
|
+
export const isColorWithMix = (token) => {
|
|
11
|
+
// no color or no mix property
|
|
12
|
+
if (!isColor(token) || token.mix === undefined || token.mix === null) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
// invalid mix property
|
|
16
|
+
if (typeof token.mix.color !== 'string' ||
|
|
17
|
+
typeof token.mix.weight !== 'number' ||
|
|
18
|
+
token.mix.weight < 0 ||
|
|
19
|
+
token.mix.weight > 1) {
|
|
20
|
+
throwError(token);
|
|
21
|
+
}
|
|
22
|
+
// valid mix property
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `cubicBezier`
|
|
4
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isCubicBezier: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `cubicBezier`
|
|
3
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isCubicBezier = (token) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const typeValue = (_a = token.$type) !== null && _a !== void 0 ? _a : token.type;
|
|
9
|
+
return typeValue === 'cubicBezier';
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token has a valid `deprecated` property
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isDeprecated: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token has a valid `deprecated` property
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isDeprecated = (token) => {
|
|
7
|
+
return token.$deprecated === true || typeof token.$deprecated === 'string';
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `dimension`
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isDimension: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `dimension`
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isDimension = (token) => {
|
|
7
|
+
return token.$type === 'dimension';
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `duration`
|
|
4
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isDuration: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `duration`
|
|
3
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isDuration = (token) => {
|
|
7
|
+
return token.$type === 'duration';
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `isFontFamily`
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isFontFamily: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `isFontFamily`
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isFontFamily = (token) => {
|
|
7
|
+
return token.$type === 'fontFamily';
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `fontWeight`
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isFontWeight: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `fontWeight`
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isFontWeight = (token) => {
|
|
7
|
+
return token.$type === 'fontWeight';
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token comes from a specific file
|
|
4
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @param files - array of file paths
|
|
6
|
+
* @returns boolean
|
|
7
|
+
*/
|
|
8
|
+
export declare const isFromFile: (token: TransformedToken, files: string[]) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token comes from a specific file
|
|
3
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @param files - array of file paths
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export const isFromFile = (token, files) => {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
9
|
+
return (files === null || files === void 0 ? void 0 : files.includes(token.filePath)) === true;
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token type is a number
|
|
4
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isNumber: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token type is a number
|
|
3
|
+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isNumber = (token) => {
|
|
7
|
+
return token.$type === 'number';
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `shadow`
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isShadow: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `shadow`
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isShadow = (token) => {
|
|
7
|
+
return token.$type === 'shadow';
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is source token
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isSource: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is source token
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isSource = (token) => {
|
|
7
|
+
return token.isSource === true;
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if token is of $type `typography`
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isTypography: (token: TransformedToken) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Checks if token is of $type `typography`
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export const isTypography = (token) => {
|
|
7
|
+
return token.$type === 'typography';
|
|
8
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { format } from 'prettier';
|
|
11
|
+
import { fileHeader, formattedVariables } from 'style-dictionary/utils';
|
|
12
|
+
const wrapWithSelector = (css, selector) => {
|
|
13
|
+
// return without selector
|
|
14
|
+
if (selector === false || selector.trim().length === 0)
|
|
15
|
+
return css;
|
|
16
|
+
// return with selector
|
|
17
|
+
return `${selector} { ${css} }`;
|
|
18
|
+
};
|
|
19
|
+
export const cssAdvanced = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary: originalDictionary, options = {
|
|
20
|
+
queries: [],
|
|
21
|
+
}, file, }) {
|
|
22
|
+
var _b, _c, _d, _e;
|
|
23
|
+
// get options
|
|
24
|
+
const { outputReferences, usesDtcg, formatting } = options;
|
|
25
|
+
// selector
|
|
26
|
+
const selector = ((_b = file.options) === null || _b === void 0 ? void 0 : _b.selector) !== undefined ? file.options.selector : ':root';
|
|
27
|
+
// query extension property
|
|
28
|
+
const queryExtProp = ((_c = file.options) === null || _c === void 0 ? void 0 : _c.queryExtensionProperty) || 'mediaQuery';
|
|
29
|
+
// get queries from file options
|
|
30
|
+
const queries = ((_d = file.options) === null || _d === void 0 ? void 0 : _d.queries) || [
|
|
31
|
+
{
|
|
32
|
+
query: undefined,
|
|
33
|
+
matcher: () => true,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
// set formatting
|
|
37
|
+
const mergedFormatting = Object.assign({ commentStyle: 'long' }, formatting);
|
|
38
|
+
// clone dictionary
|
|
39
|
+
const dictionary = Object.assign({}, originalDictionary);
|
|
40
|
+
// get queries from tokens
|
|
41
|
+
for (const designToken of dictionary.allTokens) {
|
|
42
|
+
const query = (_e = designToken.$extensions) === null || _e === void 0 ? void 0 : _e[queryExtProp];
|
|
43
|
+
// early abort if query does not exist on token
|
|
44
|
+
if (!query)
|
|
45
|
+
continue;
|
|
46
|
+
// if query exists already from other token
|
|
47
|
+
const currentQueryIndex = queries.findIndex((q) => q.query === query);
|
|
48
|
+
// if query exists
|
|
49
|
+
if (currentQueryIndex > -1) {
|
|
50
|
+
queries[currentQueryIndex] = Object.assign(Object.assign({}, queries[currentQueryIndex]), { matcher: (token) => queries[currentQueryIndex].matcher(token) ||
|
|
51
|
+
token.$extensions[queryExtProp] === queries[currentQueryIndex].query });
|
|
52
|
+
}
|
|
53
|
+
// if query does not exist
|
|
54
|
+
else {
|
|
55
|
+
queries.push({
|
|
56
|
+
query,
|
|
57
|
+
matcher: (token) => { var _a; return ((_a = token.$extensions) === null || _a === void 0 ? void 0 : _a[queryExtProp]) === query; },
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// add file header
|
|
62
|
+
const output = [yield fileHeader({ file })];
|
|
63
|
+
// add single theme css
|
|
64
|
+
for (const query of queries) {
|
|
65
|
+
const { query: queryString, matcher } = query;
|
|
66
|
+
// filter tokens to only include the ones that pass the matcher
|
|
67
|
+
const filteredDictionary = Object.assign(Object.assign({}, dictionary), { allTokens: dictionary.allTokens.filter(matcher || (() => true)) });
|
|
68
|
+
// early abort if no matches
|
|
69
|
+
if (!filteredDictionary.allTokens.length)
|
|
70
|
+
continue;
|
|
71
|
+
// add tokens into root
|
|
72
|
+
const css = formattedVariables({
|
|
73
|
+
format: 'css',
|
|
74
|
+
dictionary: filteredDictionary,
|
|
75
|
+
outputReferences,
|
|
76
|
+
formatting: mergedFormatting,
|
|
77
|
+
usesDtcg,
|
|
78
|
+
});
|
|
79
|
+
// wrap css
|
|
80
|
+
const cssWithSelector = wrapWithSelector(css, query.selector !== undefined ? query.selector : selector);
|
|
81
|
+
// add css with or without query
|
|
82
|
+
output.push(queryString ? `${queryString} { ${cssWithSelector} }` : cssWithSelector);
|
|
83
|
+
}
|
|
84
|
+
// return prettified
|
|
85
|
+
return yield format(output.join('\n'), { parser: 'css', printWidth: 500 });
|
|
86
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media
|
|
4
|
+
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
5
|
+
* @returns formatted `string`
|
|
6
|
+
*/
|
|
7
|
+
export declare const cssCustomMedia: FormatFn;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { format } from 'prettier';
|
|
11
|
+
import { fileHeader } from 'style-dictionary/utils';
|
|
12
|
+
/**
|
|
13
|
+
* @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media
|
|
14
|
+
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
15
|
+
* @returns formatted `string`
|
|
16
|
+
*/
|
|
17
|
+
export const cssCustomMedia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, options: _options, file }) {
|
|
18
|
+
// add file header
|
|
19
|
+
const output = [yield fileHeader({ file })];
|
|
20
|
+
// add single theme css
|
|
21
|
+
dictionary.allTokens.map(({ name, $value }) => {
|
|
22
|
+
output.push(`@custom-media --${name} ${$value};`);
|
|
23
|
+
});
|
|
24
|
+
// return prettified
|
|
25
|
+
return format(output.join('\n'), { parser: 'css', printWidth: 500 });
|
|
26
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { cssCustomMedia } from './cssCustomMedia.js';
|
|
2
|
+
export { cssAdvanced } from './cssAdvanced.js';
|
|
3
|
+
export { jsonFigma } from './jsonFigma.js';
|
|
4
|
+
export { javascriptCommonJs } from './javascriptCommonJs.js';
|
|
5
|
+
export { javascriptEsm } from './javascriptEsm.js';
|
|
6
|
+
export { jsonNestedPrefixed } from './jsonNestedPrefixed.js';
|
|
7
|
+
export { jsonOneDimensional } from './jsonOneDimensional.js';
|
|
8
|
+
export { jsonPostCssFallback } from './jsonPostCssFallback.js';
|
|
9
|
+
export { typescriptExportDefinition } from './typescriptExportDefinition.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { cssCustomMedia } from './cssCustomMedia.js';
|
|
2
|
+
export { cssAdvanced } from './cssAdvanced.js';
|
|
3
|
+
export { jsonFigma } from './jsonFigma.js';
|
|
4
|
+
export { javascriptCommonJs } from './javascriptCommonJs.js';
|
|
5
|
+
export { javascriptEsm } from './javascriptEsm.js';
|
|
6
|
+
export { jsonNestedPrefixed } from './jsonNestedPrefixed.js';
|
|
7
|
+
export { jsonOneDimensional } from './jsonOneDimensional.js';
|
|
8
|
+
export { jsonPostCssFallback } from './jsonPostCssFallback.js';
|
|
9
|
+
export { typescriptExportDefinition } from './typescriptExportDefinition.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Converts `StyleDictionary.dictionary.tokens` to javascript commonJS module
|
|
4
|
+
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
5
|
+
* @returns formatted `string`
|
|
6
|
+
*/
|
|
7
|
+
export declare const javascriptCommonJs: FormatFn;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { format } from 'prettier';
|
|
11
|
+
import { jsonToNestedValue } from './utilities/jsonToNestedValue.js';
|
|
12
|
+
import { prefixTokens } from './utilities/prefixTokens.js';
|
|
13
|
+
import { fileHeader } from 'style-dictionary/utils';
|
|
14
|
+
/**
|
|
15
|
+
* @description Converts `StyleDictionary.dictionary.tokens` to javascript commonJS module
|
|
16
|
+
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
17
|
+
* @returns formatted `string`
|
|
18
|
+
*/
|
|
19
|
+
export const javascriptCommonJs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file, platform }) {
|
|
20
|
+
// add prefix if defined
|
|
21
|
+
const tokens = prefixTokens(dictionary.tokens, platform);
|
|
22
|
+
// add file header and convert output
|
|
23
|
+
const output = `${yield fileHeader({ file })}module.exports = ${JSON.stringify(jsonToNestedValue(tokens), null, 2)}\n`;
|
|
24
|
+
// return prettified
|
|
25
|
+
return format(output, { parser: 'typescript', printWidth: 500 });
|
|
26
|
+
});
|