@primer/primitives 10.0.0-rc.fd912e08 → 10.1.0-rc.0146c170
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/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 +10 -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 +100 -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 +39 -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 +63 -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 +30 -0
- package/dist/build/platforms/json.d.ts +2 -0
- package/dist/build/platforms/json.js +32 -0
- package/dist/build/platforms/styleLint.d.ts +2 -0
- package/dist/build/platforms/styleLint.js +34 -0
- package/dist/build/platforms/typeDefinitions.d.ts +2 -0
- package/dist/build/platforms/typeDefinitions.js +30 -0
- package/dist/build/platforms/typescript.d.ts +2 -0
- package/dist/build/platforms/typescript.js +30 -0
- package/dist/build/preprocessors/themeOverrides.d.ts +2 -0
- package/dist/build/preprocessors/themeOverrides.js +22 -0
- package/dist/build/preprocessors/utilities/transformTokens.d.ts +8 -0
- package/dist/build/preprocessors/utilities/transformTokens.js +22 -0
- package/dist/build/primerStyleDictionary.d.ts +8 -0
- package/dist/build/primerStyleDictionary.js +82 -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 +167 -0
- package/dist/build/schemas/colorToken.js +76 -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 +25 -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 +16 -0
- package/dist/build/types/tokenBuildInput.d.ts +10 -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/lowerCaseFirstCharacter.d.ts +8 -0
- package/dist/build/utilities/lowerCaseFirstCharacter.js +10 -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 +15 -23
- 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 +30 -36
- 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,13 @@
|
|
|
1
|
+
import { isDeprecated } from '../filters/index.js';
|
|
2
|
+
export const deprecatedJson = (outputFile, prefix, buildPath) => ({
|
|
3
|
+
prefix,
|
|
4
|
+
buildPath,
|
|
5
|
+
transforms: ['name/pathToDotNotation', 'json/deprecated'],
|
|
6
|
+
files: [
|
|
7
|
+
{
|
|
8
|
+
destination: outputFile,
|
|
9
|
+
format: `json/flat`,
|
|
10
|
+
filter: isDeprecated,
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isSource } from '../filters/index.js';
|
|
2
|
+
export const docJson = (outputFile, prefix, buildPath, options) => ({
|
|
3
|
+
prefix,
|
|
4
|
+
buildPath,
|
|
5
|
+
preprocessors: ['themeOverrides'],
|
|
6
|
+
transforms: [
|
|
7
|
+
'name/pathToKebabCase',
|
|
8
|
+
'color/hex',
|
|
9
|
+
'color/hexMix',
|
|
10
|
+
'dimension/rem',
|
|
11
|
+
'shadow/css',
|
|
12
|
+
'border/css',
|
|
13
|
+
'typography/css',
|
|
14
|
+
'fontFamily/css',
|
|
15
|
+
'fontWeight/number',
|
|
16
|
+
],
|
|
17
|
+
options: {
|
|
18
|
+
basePxFontSize: 16,
|
|
19
|
+
propertyConversion: {
|
|
20
|
+
$value: 'value',
|
|
21
|
+
$type: 'type',
|
|
22
|
+
$description: 'description',
|
|
23
|
+
},
|
|
24
|
+
themeOverrides: {
|
|
25
|
+
theme: options === null || options === void 0 ? void 0 : options.theme,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
files: [
|
|
29
|
+
{
|
|
30
|
+
destination: outputFile,
|
|
31
|
+
format: `json/one-dimensional`,
|
|
32
|
+
filter: isSource,
|
|
33
|
+
options: {
|
|
34
|
+
outputReferences: false,
|
|
35
|
+
outputVerbose: true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isSource } from '../filters/index.js';
|
|
2
|
+
export const fallbacks = (outputFile, prefix, buildPath) => ({
|
|
3
|
+
prefix,
|
|
4
|
+
buildPath,
|
|
5
|
+
transforms: [
|
|
6
|
+
'name/pathToKebabCase',
|
|
7
|
+
'color/hex',
|
|
8
|
+
'color/hexMix',
|
|
9
|
+
'dimension/rem',
|
|
10
|
+
'shadow/css',
|
|
11
|
+
'border/css',
|
|
12
|
+
'typography/css',
|
|
13
|
+
'fontFamily/css',
|
|
14
|
+
'fontWeight/number',
|
|
15
|
+
],
|
|
16
|
+
options: {
|
|
17
|
+
basePxFontSize: 16,
|
|
18
|
+
},
|
|
19
|
+
files: [
|
|
20
|
+
{
|
|
21
|
+
destination: outputFile,
|
|
22
|
+
format: `json/postCss-fallback`,
|
|
23
|
+
filter: isSource,
|
|
24
|
+
options: {
|
|
25
|
+
outputReferences: false,
|
|
26
|
+
outputVerbose: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
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 { isSource } from '../filters/index.js';
|
|
11
|
+
const validFigmaToken = (token, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
13
|
+
const validTypes = ['color', 'dimension', 'shadow', 'fontWeight', 'fontFamily', 'number'];
|
|
14
|
+
// is a siource token, not an included one
|
|
15
|
+
if (!isSource(token) || !token.$type)
|
|
16
|
+
return false;
|
|
17
|
+
if (`${token[valueProp]}`.substring(token[valueProp].length - 2) === 'em')
|
|
18
|
+
return false;
|
|
19
|
+
// has a collection attribute
|
|
20
|
+
if (!('$extensions' in token) ||
|
|
21
|
+
!('org.primer.figma' in token.$extensions) ||
|
|
22
|
+
!('collection' in token.$extensions['org.primer.figma']))
|
|
23
|
+
return false;
|
|
24
|
+
// is a color or dimension type
|
|
25
|
+
return validTypes.includes(token.$type);
|
|
26
|
+
});
|
|
27
|
+
export const figma = (outputFile, prefix, buildPath, options) => ({
|
|
28
|
+
prefix,
|
|
29
|
+
buildPath,
|
|
30
|
+
preprocessors: ['themeOverrides'],
|
|
31
|
+
transforms: [
|
|
32
|
+
'color/rgbaFloat',
|
|
33
|
+
'fontFamily/figma',
|
|
34
|
+
'float/pixelUnitless',
|
|
35
|
+
'dimension/pixelUnitless',
|
|
36
|
+
// 'border/figma',
|
|
37
|
+
// 'typography/figma',
|
|
38
|
+
'fontWeight/number',
|
|
39
|
+
'figma/attributes',
|
|
40
|
+
'name/pathToFigma',
|
|
41
|
+
],
|
|
42
|
+
options: Object.assign(Object.assign({ basePxFontSize: 16, fontFamilies: {
|
|
43
|
+
'fontStack/system': 'SF Pro Text',
|
|
44
|
+
'fontStack/sansSerif': 'SF Pro Text',
|
|
45
|
+
'fontStack/sansSerifDisplay': 'SF Pro Display',
|
|
46
|
+
'fontStack/monospace': 'SF Mono',
|
|
47
|
+
} }, options), { themeOverrides: {
|
|
48
|
+
theme: options === null || options === void 0 ? void 0 : options.theme,
|
|
49
|
+
} }),
|
|
50
|
+
files: [
|
|
51
|
+
{
|
|
52
|
+
destination: outputFile,
|
|
53
|
+
filter: (token, config) => {
|
|
54
|
+
return validFigmaToken(token, config);
|
|
55
|
+
},
|
|
56
|
+
format: `json/figma`,
|
|
57
|
+
options: {
|
|
58
|
+
outputReferences: true,
|
|
59
|
+
theme: options === null || options === void 0 ? void 0 : options.theme,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { css } from './css.js';
|
|
2
|
+
export { deprecatedJson } from './deprecatedJson.js';
|
|
3
|
+
export { docJson } from './docJson.js';
|
|
4
|
+
export { fallbacks } from './fallbacks.js';
|
|
5
|
+
export { figma } from './figma.js';
|
|
6
|
+
export { javascript } from './javascript.js';
|
|
7
|
+
export { json } from './json.js';
|
|
8
|
+
export { styleLint } from './styleLint.js';
|
|
9
|
+
export { typeDefinitions } from './typeDefinitions.js';
|
|
10
|
+
export { typescript } from './typescript.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { css } from './css.js';
|
|
2
|
+
export { deprecatedJson } from './deprecatedJson.js';
|
|
3
|
+
export { docJson } from './docJson.js';
|
|
4
|
+
export { fallbacks } from './fallbacks.js';
|
|
5
|
+
export { figma } from './figma.js';
|
|
6
|
+
export { javascript } from './javascript.js';
|
|
7
|
+
export { json } from './json.js';
|
|
8
|
+
export { styleLint } from './styleLint.js';
|
|
9
|
+
export { typeDefinitions } from './typeDefinitions.js';
|
|
10
|
+
export { typescript } from './typescript.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isSource } from '../filters/index.js';
|
|
2
|
+
export const javascript = (outputFile, prefix, buildPath, options) => ({
|
|
3
|
+
prefix,
|
|
4
|
+
buildPath,
|
|
5
|
+
preprocessors: ['themeOverrides'],
|
|
6
|
+
transforms: [
|
|
7
|
+
'color/hex',
|
|
8
|
+
'color/hexMix',
|
|
9
|
+
'dimension/rem',
|
|
10
|
+
'shadow/css',
|
|
11
|
+
'border/css',
|
|
12
|
+
'typography/css',
|
|
13
|
+
'fontFamily/css',
|
|
14
|
+
'fontWeight/number',
|
|
15
|
+
],
|
|
16
|
+
options: {
|
|
17
|
+
showFileHeader: false,
|
|
18
|
+
basePxFontSize: 16,
|
|
19
|
+
themeOverrides: {
|
|
20
|
+
theme: options === null || options === void 0 ? void 0 : options.theme,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
files: [
|
|
24
|
+
{
|
|
25
|
+
format: 'javascript/commonJs',
|
|
26
|
+
destination: outputFile,
|
|
27
|
+
filter: isSource,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isSource } from '../filters/index.js';
|
|
2
|
+
export const json = (outputFile, prefix, buildPath, options) => ({
|
|
3
|
+
prefix,
|
|
4
|
+
buildPath,
|
|
5
|
+
preprocessors: ['themeOverrides'],
|
|
6
|
+
transforms: [
|
|
7
|
+
'color/hex',
|
|
8
|
+
'color/hexMix',
|
|
9
|
+
'dimension/rem',
|
|
10
|
+
'shadow/css',
|
|
11
|
+
'border/css',
|
|
12
|
+
'typography/css',
|
|
13
|
+
'fontFamily/css',
|
|
14
|
+
'fontWeight/number',
|
|
15
|
+
],
|
|
16
|
+
options: {
|
|
17
|
+
basePxFontSize: 16,
|
|
18
|
+
themeOverrides: {
|
|
19
|
+
theme: options === null || options === void 0 ? void 0 : options.theme,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
files: [
|
|
23
|
+
{
|
|
24
|
+
destination: outputFile,
|
|
25
|
+
filter: isSource,
|
|
26
|
+
format: `json/nested-prefixed`,
|
|
27
|
+
options: {
|
|
28
|
+
outputReferences: false,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isSource } from '../filters/index.js';
|
|
2
|
+
export const styleLint = (outputFile, prefix, buildPath, options) => ({
|
|
3
|
+
prefix,
|
|
4
|
+
buildPath,
|
|
5
|
+
preprocessors: ['themeOverrides'],
|
|
6
|
+
transforms: [
|
|
7
|
+
'name/pathToKebabCase',
|
|
8
|
+
'color/hex',
|
|
9
|
+
'color/hexMix',
|
|
10
|
+
'dimension/remPxArray',
|
|
11
|
+
'shadow/css',
|
|
12
|
+
'border/css',
|
|
13
|
+
'typography/css',
|
|
14
|
+
'fontFamily/css',
|
|
15
|
+
'fontWeight/number',
|
|
16
|
+
],
|
|
17
|
+
options: {
|
|
18
|
+
basePxFontSize: 16,
|
|
19
|
+
themeOverrides: {
|
|
20
|
+
theme: options === null || options === void 0 ? void 0 : options.theme,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
files: [
|
|
24
|
+
{
|
|
25
|
+
destination: outputFile,
|
|
26
|
+
format: `json/one-dimensional`,
|
|
27
|
+
filter: isSource,
|
|
28
|
+
options: {
|
|
29
|
+
outputReferences: false,
|
|
30
|
+
outputVerbose: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isSource } from '../filters/index.js';
|
|
2
|
+
import { upperCaseFirstCharacter } from '../utilities/index.js';
|
|
3
|
+
export const typeDefinitions = (outputFile, prefix, buildPath, options) => ({
|
|
4
|
+
prefix,
|
|
5
|
+
buildPath,
|
|
6
|
+
preprocessors: ['themeOverrides'],
|
|
7
|
+
transforms: [
|
|
8
|
+
'color/hex',
|
|
9
|
+
'shadow/css',
|
|
10
|
+
'border/css',
|
|
11
|
+
'dimension/rem',
|
|
12
|
+
'typography/css',
|
|
13
|
+
'fontFamily/css',
|
|
14
|
+
'fontWeight/number',
|
|
15
|
+
],
|
|
16
|
+
files: [
|
|
17
|
+
{
|
|
18
|
+
format: 'typescript/export-definition',
|
|
19
|
+
destination: `${upperCaseFirstCharacter(outputFile)}DesignTokens.d.ts`,
|
|
20
|
+
filter: isSource,
|
|
21
|
+
options: {
|
|
22
|
+
tokenTypesPath: './src/types/',
|
|
23
|
+
moduleName: `${upperCaseFirstCharacter(outputFile)}DesignTokens`,
|
|
24
|
+
themeOverrides: {
|
|
25
|
+
theme: options === null || options === void 0 ? void 0 : options.theme,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isSource } from '../filters/index.js';
|
|
2
|
+
export const typescript = (outputFile, prefix, buildPath, options) => ({
|
|
3
|
+
prefix,
|
|
4
|
+
buildPath,
|
|
5
|
+
preprocessors: ['themeOverrides'],
|
|
6
|
+
transforms: [
|
|
7
|
+
'color/hex',
|
|
8
|
+
'color/hexMix',
|
|
9
|
+
'dimension/rem',
|
|
10
|
+
'shadow/css',
|
|
11
|
+
'border/css',
|
|
12
|
+
'typography/css',
|
|
13
|
+
'fontFamily/css',
|
|
14
|
+
'fontWeight/number',
|
|
15
|
+
],
|
|
16
|
+
options: {
|
|
17
|
+
showFileHeader: false,
|
|
18
|
+
basePxFontSize: 16,
|
|
19
|
+
themeOverrides: {
|
|
20
|
+
theme: options === null || options === void 0 ? void 0 : options.theme,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
files: [
|
|
24
|
+
{
|
|
25
|
+
format: 'javascript/esm',
|
|
26
|
+
destination: outputFile,
|
|
27
|
+
filter: isSource,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { transformTokens } from './utilities/transformTokens.js';
|
|
2
|
+
export const themeOverrides = {
|
|
3
|
+
name: 'themeOverrides',
|
|
4
|
+
preprocessor: (dictionary, config) => {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6
|
+
const extensionProp = ((_b = (_a = config.options) === null || _a === void 0 ? void 0 : _a.themeOverrides) === null || _b === void 0 ? void 0 : _b.extensionProp) || 'org.primer.overrides';
|
|
7
|
+
const valueProp = ((_d = (_c = config.options) === null || _c === void 0 ? void 0 : _c.themeOverrides) === null || _d === void 0 ? void 0 : _d.valueProp) || '$value';
|
|
8
|
+
const currentTheme = (_f = (_e = config.options) === null || _e === void 0 ? void 0 : _e.themeOverrides) === null || _f === void 0 ? void 0 : _f.theme;
|
|
9
|
+
const tokens = transformTokens(dictionary, token => {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
// return early if no theme value is set
|
|
12
|
+
if (!currentTheme || !((_a = token.$extensions) === null || _a === void 0 ? void 0 : _a[extensionProp]) || !((_b = token.$extensions) === null || _b === void 0 ? void 0 : _b[extensionProp][currentTheme])) {
|
|
13
|
+
return token;
|
|
14
|
+
}
|
|
15
|
+
// get override
|
|
16
|
+
const override = (_c = token.$extensions) === null || _c === void 0 ? void 0 : _c[extensionProp][currentTheme];
|
|
17
|
+
// token an theme value exist
|
|
18
|
+
return Object.assign(Object.assign({}, token), (typeof override === 'object' ? override : { [valueProp]: override }));
|
|
19
|
+
});
|
|
20
|
+
return tokens;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DesignToken } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* jsonToNestedValue
|
|
4
|
+
* @description creates a nested json tree where every final value is the `.value` prop
|
|
5
|
+
* @param token StyleDictionary.DesignToken
|
|
6
|
+
* @returns nested json three
|
|
7
|
+
*/
|
|
8
|
+
export declare const transformTokens: (token: DesignToken | Record<string, unknown>, transform: (token: DesignToken) => DesignToken) => {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jsonToNestedValue
|
|
3
|
+
* @description creates a nested json tree where every final value is the `.value` prop
|
|
4
|
+
* @param token StyleDictionary.DesignToken
|
|
5
|
+
* @returns nested json three
|
|
6
|
+
*/
|
|
7
|
+
export const transformTokens = (token, transform) => {
|
|
8
|
+
// is non-object value
|
|
9
|
+
if (typeof token !== 'object')
|
|
10
|
+
return token;
|
|
11
|
+
// is design token
|
|
12
|
+
if ('$value' in token || 'value' in token) {
|
|
13
|
+
return transform(token);
|
|
14
|
+
}
|
|
15
|
+
// is obj
|
|
16
|
+
const nextObj = {};
|
|
17
|
+
for (const [prop, value] of Object.entries(token)) {
|
|
18
|
+
// @ts-expect-error: can't predict type
|
|
19
|
+
nextObj[prop] = transformTokens(value, transform);
|
|
20
|
+
}
|
|
21
|
+
return nextObj;
|
|
22
|
+
};
|
|
@@ -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,82 @@
|
|
|
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
|
+
import { themeOverrides } from './preprocessors/themeOverrides.js';
|
|
5
|
+
/**
|
|
6
|
+
* @name {@link PrimerStyleDictionary}
|
|
7
|
+
* @description Returns style dictionary object with primer preset that includes parsers, formats and transformers
|
|
8
|
+
* @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)
|
|
9
|
+
* @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)
|
|
10
|
+
*/
|
|
11
|
+
export const PrimerStyleDictionary = new StyleDictionary();
|
|
12
|
+
/**
|
|
13
|
+
* Formats
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
PrimerStyleDictionary.registerFormat({
|
|
17
|
+
name: 'css/advanced',
|
|
18
|
+
format: cssAdvanced,
|
|
19
|
+
});
|
|
20
|
+
PrimerStyleDictionary.registerFormat({
|
|
21
|
+
name: 'css/customMedia',
|
|
22
|
+
format: cssCustomMedia,
|
|
23
|
+
});
|
|
24
|
+
PrimerStyleDictionary.registerFormat({
|
|
25
|
+
name: 'javascript/esm',
|
|
26
|
+
format: javascriptEsm,
|
|
27
|
+
});
|
|
28
|
+
PrimerStyleDictionary.registerFormat({
|
|
29
|
+
name: 'javascript/commonJs',
|
|
30
|
+
format: javascriptCommonJs,
|
|
31
|
+
});
|
|
32
|
+
PrimerStyleDictionary.registerFormat({
|
|
33
|
+
name: 'typescript/export-definition',
|
|
34
|
+
format: typescriptExportDefinition,
|
|
35
|
+
});
|
|
36
|
+
PrimerStyleDictionary.registerFormat({
|
|
37
|
+
name: 'json/nested-prefixed',
|
|
38
|
+
format: jsonNestedPrefixed,
|
|
39
|
+
});
|
|
40
|
+
PrimerStyleDictionary.registerFormat({
|
|
41
|
+
name: 'json/one-dimensional',
|
|
42
|
+
format: jsonOneDimensional,
|
|
43
|
+
});
|
|
44
|
+
PrimerStyleDictionary.registerFormat({
|
|
45
|
+
name: 'json/postCss-fallback',
|
|
46
|
+
format: jsonPostCssFallback,
|
|
47
|
+
});
|
|
48
|
+
PrimerStyleDictionary.registerFormat({
|
|
49
|
+
name: 'json/figma',
|
|
50
|
+
format: jsonFigma,
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Transformers
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
PrimerStyleDictionary.registerTransform(colorToRgbAlpha);
|
|
57
|
+
PrimerStyleDictionary.registerTransform(colorToRgbaFloat);
|
|
58
|
+
PrimerStyleDictionary.registerTransform(colorToHexMix);
|
|
59
|
+
PrimerStyleDictionary.registerTransform(colorToHex);
|
|
60
|
+
PrimerStyleDictionary.registerTransform(cubicBezierToCss);
|
|
61
|
+
PrimerStyleDictionary.registerTransform(floatToPixel);
|
|
62
|
+
PrimerStyleDictionary.registerTransform(floatToPixelUnitless);
|
|
63
|
+
PrimerStyleDictionary.registerTransform(dimensionToRem);
|
|
64
|
+
PrimerStyleDictionary.registerTransform(dimensionToRemPxArray);
|
|
65
|
+
PrimerStyleDictionary.registerTransform(dimensionToPixelUnitless);
|
|
66
|
+
PrimerStyleDictionary.registerTransform(durationToCss);
|
|
67
|
+
PrimerStyleDictionary.registerTransform(figmaAttributes);
|
|
68
|
+
PrimerStyleDictionary.registerTransform(jsonDeprecated);
|
|
69
|
+
PrimerStyleDictionary.registerTransform(namePathToCamelCase);
|
|
70
|
+
PrimerStyleDictionary.registerTransform(namePathToPascalCase);
|
|
71
|
+
PrimerStyleDictionary.registerTransform(namePathToDotNotation);
|
|
72
|
+
PrimerStyleDictionary.registerTransform(namePathToFigma);
|
|
73
|
+
PrimerStyleDictionary.registerTransform(namePathToCamelCase);
|
|
74
|
+
PrimerStyleDictionary.registerTransform(namePathToKebabCase);
|
|
75
|
+
PrimerStyleDictionary.registerTransform(namePathToSlashNotation);
|
|
76
|
+
PrimerStyleDictionary.registerTransform(shadowToCss);
|
|
77
|
+
PrimerStyleDictionary.registerTransform(borderToCss);
|
|
78
|
+
PrimerStyleDictionary.registerTransform(typographyToCss);
|
|
79
|
+
PrimerStyleDictionary.registerTransform(fontWeightToNumber);
|
|
80
|
+
PrimerStyleDictionary.registerTransform(fontFamilyToCss);
|
|
81
|
+
PrimerStyleDictionary.registerTransform(fontFamilyToFigma);
|
|
82
|
+
PrimerStyleDictionary.registerPreprocessor(themeOverrides);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
export const alphaValue = z.any().refine(value => typeof value === 'number' && value >= 0 && value <= 1, value => ({
|
|
4
|
+
message: schemaErrorMessage(`Invalid alpha value: "${value}" (${typeof value})`, 'Alpha value must be a number between 0 and 1.'),
|
|
5
|
+
}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const baseToken: z.ZodObject<{
|
|
3
|
+
$description: z.ZodOptional<z.ZodString>;
|
|
4
|
+
$deprecated: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
5
|
+
}, "strict", z.ZodTypeAny, {
|
|
6
|
+
$description?: string | undefined;
|
|
7
|
+
$deprecated?: string | boolean | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
$description?: string | undefined;
|
|
10
|
+
$deprecated?: string | boolean | undefined;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const borderValue: z.ZodObject<{
|
|
3
|
+
color: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
4
|
+
style: z.ZodEnum<["solid", "dashed", "dotted", "double", "groove", "ridge", "outset", "inset"]>;
|
|
5
|
+
width: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
width: string | 0;
|
|
8
|
+
color: string;
|
|
9
|
+
style: "inset" | "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "outset";
|
|
10
|
+
}, {
|
|
11
|
+
width: string | 0;
|
|
12
|
+
color: string;
|
|
13
|
+
style: "inset" | "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "outset";
|
|
14
|
+
}>;
|
|
15
|
+
export declare const borderToken: z.ZodObject<z.objectUtil.extendShape<{
|
|
16
|
+
$description: z.ZodOptional<z.ZodString>;
|
|
17
|
+
$deprecated: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
18
|
+
}, {
|
|
19
|
+
$value: z.ZodUnion<[z.ZodObject<{
|
|
20
|
+
color: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
21
|
+
style: z.ZodEnum<["solid", "dashed", "dotted", "double", "groove", "ridge", "outset", "inset"]>;
|
|
22
|
+
width: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
width: string | 0;
|
|
25
|
+
color: string;
|
|
26
|
+
style: "inset" | "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "outset";
|
|
27
|
+
}, {
|
|
28
|
+
width: string | 0;
|
|
29
|
+
color: string;
|
|
30
|
+
style: "inset" | "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "outset";
|
|
31
|
+
}>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
32
|
+
$type: z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
33
|
+
}>, "strict", z.ZodTypeAny, {
|
|
34
|
+
$value: string | {
|
|
35
|
+
width: string | 0;
|
|
36
|
+
color: string;
|
|
37
|
+
style: "inset" | "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "outset";
|
|
38
|
+
};
|
|
39
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
40
|
+
$description?: string | undefined;
|
|
41
|
+
$deprecated?: string | boolean | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
$value: string | {
|
|
44
|
+
width: string | 0;
|
|
45
|
+
color: string;
|
|
46
|
+
style: "inset" | "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "outset";
|
|
47
|
+
};
|
|
48
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
49
|
+
$description?: string | undefined;
|
|
50
|
+
$deprecated?: string | boolean | undefined;
|
|
51
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { baseToken } from './baseToken.js';
|
|
3
|
+
import { referenceValue } from './referenceValue.js';
|
|
4
|
+
import { colorHexValue } from './colorHexValue.js';
|
|
5
|
+
import { dimensionValue } from './dimensionValue.js';
|
|
6
|
+
import { tokenType } from './tokenType.js';
|
|
7
|
+
export const borderValue = z.object({
|
|
8
|
+
color: z.union([colorHexValue, referenceValue]),
|
|
9
|
+
style: z.enum(['solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'outset', 'inset']),
|
|
10
|
+
width: z.union([dimensionValue, referenceValue]),
|
|
11
|
+
});
|
|
12
|
+
export const borderToken = baseToken
|
|
13
|
+
.extend({
|
|
14
|
+
$value: z.union([borderValue, referenceValue]),
|
|
15
|
+
$type: tokenType('border'),
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
type Collections = 'base/color/light' | 'base/color/light-high-contrast' | 'base/color/dark' | 'base/color/dark-dimmed' | 'base/color/dark-high-contrast' | 'base/typography' | 'mode' | 'pattern/mode' | 'base/size' | 'functional/size' | 'pattern/size' | 'typography';
|
|
3
|
+
export declare const collection: (collections: Collections[]) => z.ZodEffects<z.ZodString, string, string>;
|
|
4
|
+
type Modes = 'light' | 'dark' | 'dark dimmed' | 'light high contrast' | 'dark high contrast' | 'light colorblind' | 'dark colorblind' | 'light tritanopia' | 'dark tritanopia';
|
|
5
|
+
export declare const mode: (modes: Modes[]) => z.ZodEffects<z.ZodString, string, string>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { joinFriendly, schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
export const collection = (collections) => {
|
|
4
|
+
return z.string().refine(value => collections.includes(value), value => ({
|
|
5
|
+
message: schemaErrorMessage(`Invalid collection: "${value}"`, `Valid collections are ${joinFriendly(collections)}`),
|
|
6
|
+
}));
|
|
7
|
+
};
|
|
8
|
+
export const mode = (modes) => {
|
|
9
|
+
return z.string().refine(value => modes.includes(value), value => ({
|
|
10
|
+
message: schemaErrorMessage(`Invalid mode: "${value}"`, `Valid modes are ${joinFriendly(modes)}`),
|
|
11
|
+
}));
|
|
12
|
+
};
|