@primer/primitives 9.0.3 → 9.1.0-rc.c6c17c46
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/dist/build/PrimerStyleDictionary.d.ts +9 -0
- package/dist/build/PrimerStyleDictionary.js +92 -0
- package/dist/build/filters/index.d.ts +13 -0
- package/dist/build/filters/index.js +29 -0
- package/{src/filters/isBorder.ts → dist/build/filters/isBorder.d.ts} +2 -5
- package/dist/build/filters/isBorder.js +12 -0
- package/{src/filters/isColor.ts → dist/build/filters/isColor.d.ts} +2 -5
- package/dist/build/filters/isColor.js +12 -0
- package/dist/build/filters/isColorWithAlpha.d.ts +7 -0
- package/dist/build/filters/isColorWithAlpha.js +13 -0
- package/dist/build/filters/isColorWithMix.d.ts +7 -0
- package/dist/build/filters/isColorWithMix.js +28 -0
- package/{src/filters/isDeprecated.ts → dist/build/filters/isDeprecated.d.ts} +2 -5
- package/dist/build/filters/isDeprecated.js +12 -0
- package/{src/filters/isDimension.ts → dist/build/filters/isDimension.d.ts} +2 -5
- package/dist/build/filters/isDimension.js +12 -0
- package/{src/filters/isDuration.ts → dist/build/filters/isDuration.d.ts} +2 -5
- package/dist/build/filters/isDuration.js +12 -0
- package/{src/filters/isFontFamily.ts → dist/build/filters/isFontFamily.d.ts} +2 -5
- package/dist/build/filters/isFontFamily.js +12 -0
- package/{src/filters/isFontWeight.ts → dist/build/filters/isFontWeight.d.ts} +2 -5
- package/dist/build/filters/isFontWeight.js +12 -0
- package/dist/build/filters/isFromFile.d.ts +8 -0
- package/dist/build/filters/isFromFile.js +14 -0
- package/{src/filters/isNumber.ts → dist/build/filters/isNumber.d.ts} +2 -3
- package/dist/build/filters/isNumber.js +10 -0
- package/{src/filters/isShadow.ts → dist/build/filters/isShadow.d.ts} +2 -5
- package/dist/build/filters/isShadow.js +12 -0
- package/{src/filters/isSource.ts → dist/build/filters/isSource.d.ts} +2 -5
- package/dist/build/filters/isSource.js +12 -0
- package/{src/filters/isTypography.ts → dist/build/filters/isTypography.d.ts} +2 -5
- package/dist/build/filters/isTypography.js +12 -0
- package/dist/build/formats/cssAdvanced.d.ts +2 -0
- package/dist/build/formats/cssAdvanced.js +85 -0
- package/dist/build/formats/cssCustomMedia.d.ts +7 -0
- package/dist/build/formats/cssCustomMedia.js +25 -0
- package/dist/build/formats/index.d.ts +9 -0
- package/dist/build/formats/index.js +21 -0
- package/dist/build/formats/javascriptCommonJs.d.ts +7 -0
- package/dist/build/formats/javascriptCommonJs.js +25 -0
- package/dist/build/formats/javascriptEsm.d.ts +7 -0
- package/dist/build/formats/javascriptEsm.js +25 -0
- package/dist/build/formats/jsonFigma.d.ts +7 -0
- package/dist/build/formats/jsonFigma.js +116 -0
- package/dist/build/formats/jsonNestedPrefixed.d.ts +8 -0
- package/dist/build/formats/jsonNestedPrefixed.js +28 -0
- package/dist/build/formats/jsonOneDimensional.d.ts +8 -0
- package/dist/build/formats/jsonOneDimensional.js +24 -0
- package/dist/build/formats/jsonPostCssFallback.d.ts +8 -0
- package/dist/build/formats/jsonPostCssFallback.js +21 -0
- package/dist/build/formats/typescriptExportDefinition.d.ts +7 -0
- package/dist/build/formats/typescriptExportDefinition.js +166 -0
- package/{src/formats/utilities/jsonToFlat.ts → dist/build/formats/utilities/jsonToFlat.d.ts} +4 -3
- package/dist/build/formats/utilities/jsonToFlat.js +12 -0
- package/dist/build/formats/utilities/jsonToNestedValue.d.ts +8 -0
- package/dist/build/formats/utilities/jsonToNestedValue.js +25 -0
- package/dist/build/formats/utilities/prefixTokens.d.ts +8 -0
- package/dist/build/formats/utilities/prefixTokens.js +17 -0
- package/dist/build/parsers/index.d.ts +1 -0
- package/dist/build/parsers/index.js +5 -0
- package/dist/build/parsers/w3cJsonParser.d.ts +6 -0
- package/dist/build/parsers/w3cJsonParser.js +27 -0
- package/dist/build/platforms/css.d.ts +2 -0
- package/dist/build/platforms/css.js +88 -0
- package/dist/build/platforms/deprecatedJson.d.ts +2 -0
- package/dist/build/platforms/deprecatedJson.js +17 -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 +35 -0
- package/dist/build/platforms/figma.d.ts +2 -0
- package/dist/build/platforms/figma.js +53 -0
- package/dist/build/platforms/index.d.ts +10 -0
- package/dist/build/platforms/index.js +23 -0
- package/dist/build/platforms/javascript.d.ts +2 -0
- package/dist/build/platforms/javascript.js +31 -0
- package/dist/build/platforms/json.d.ts +2 -0
- package/dist/build/platforms/json.js +33 -0
- package/dist/build/platforms/styleLint.d.ts +2 -0
- package/dist/build/platforms/styleLint.js +35 -0
- package/dist/build/platforms/typeDefinitions.d.ts +2 -0
- package/dist/build/platforms/typeDefinitions.js +31 -0
- package/dist/build/platforms/typescript.d.ts +2 -0
- package/dist/build/platforms/typescript.js +31 -0
- package/dist/build/schemas/alphaValue.d.ts +2 -0
- package/dist/build/schemas/alphaValue.js +8 -0
- package/dist/build/schemas/baseToken.d.ts +11 -0
- package/dist/build/schemas/baseToken.js +10 -0
- package/dist/build/schemas/borderToken.d.ts +51 -0
- package/dist/build/schemas/borderToken.js +20 -0
- package/dist/build/schemas/collections.d.ts +6 -0
- package/dist/build/schemas/collections.js +18 -0
- package/dist/build/schemas/colorHexValue.d.ts +2 -0
- package/dist/build/schemas/colorHexValue.js +12 -0
- package/dist/build/schemas/colorToken.d.ts +80 -0
- package/dist/build/schemas/colorToken.js +52 -0
- package/dist/build/schemas/designToken.d.ts +2 -0
- package/dist/build/schemas/designToken.js +37 -0
- package/dist/build/schemas/dimensionToken.d.ts +52 -0
- package/dist/build/schemas/dimensionToken.js +36 -0
- package/dist/build/schemas/dimensionValue.d.ts +2 -0
- package/dist/build/schemas/dimensionValue.js +12 -0
- package/dist/build/schemas/durationToken.d.ts +18 -0
- package/dist/build/schemas/durationToken.js +14 -0
- package/dist/build/schemas/durationValue.d.ts +2 -0
- package/dist/build/schemas/durationValue.js +8 -0
- package/dist/build/schemas/fontFamilyToken.d.ts +52 -0
- package/dist/build/schemas/fontFamilyToken.js +23 -0
- package/dist/build/schemas/fontWeightToken.d.ts +52 -0
- package/dist/build/schemas/fontWeightToken.js +24 -0
- package/dist/build/schemas/fontWeightValue.d.ts +2 -0
- package/dist/build/schemas/fontWeightValue.js +9 -0
- package/dist/build/schemas/numberToken.d.ts +71 -0
- package/dist/build/schemas/numberToken.js +30 -0
- package/dist/build/schemas/referenceValue.d.ts +2 -0
- package/dist/build/schemas/referenceValue.js +8 -0
- package/dist/build/schemas/scopes.d.ts +5 -0
- package/dist/build/schemas/scopes.js +34 -0
- package/dist/build/schemas/shadowToken.d.ts +157 -0
- package/dist/build/schemas/shadowToken.js +46 -0
- package/dist/build/schemas/stringToken.d.ts +18 -0
- package/dist/build/schemas/stringToken.js +13 -0
- package/dist/build/schemas/tokenName.d.ts +2 -0
- package/dist/build/schemas/tokenName.js +8 -0
- package/dist/build/schemas/tokenType.d.ts +3 -0
- package/dist/build/schemas/tokenType.js +6 -0
- package/dist/build/schemas/typographyToken.d.ts +59 -0
- package/dist/build/schemas/typographyToken.js +21 -0
- package/dist/build/schemas/validTokenType.d.ts +5 -0
- package/dist/build/schemas/validTokenType.js +34 -0
- package/dist/build/schemas/viewportRangeToken.d.ts +18 -0
- package/dist/build/schemas/viewportRangeToken.js +13 -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 +18 -0
- package/dist/build/transformers/colorToHexAlpha.d.ts +8 -0
- package/dist/build/transformers/colorToHexAlpha.js +25 -0
- package/dist/build/transformers/colorToHexMix.d.ts +8 -0
- package/dist/build/transformers/colorToHexMix.js +25 -0
- package/dist/build/transformers/colorToRgbAlpha.d.ts +8 -0
- package/dist/build/transformers/colorToRgbAlpha.js +22 -0
- package/dist/build/transformers/colorToRgbaFloat.d.ts +8 -0
- package/dist/build/transformers/colorToRgbaFloat.js +50 -0
- package/dist/build/transformers/dimensionToPixelUnitless.d.ts +8 -0
- package/dist/build/transformers/dimensionToPixelUnitless.js +50 -0
- package/dist/build/transformers/dimensionToRem.d.ts +8 -0
- package/dist/build/transformers/dimensionToRem.js +47 -0
- package/dist/build/transformers/dimensionToRemPxArray.d.ts +8 -0
- package/dist/build/transformers/dimensionToRemPxArray.js +47 -0
- package/dist/build/transformers/durationToCss.d.ts +8 -0
- package/dist/build/transformers/durationToCss.js +30 -0
- package/dist/build/transformers/figmaAttributes.d.ts +8 -0
- package/dist/build/transformers/figmaAttributes.js +57 -0
- package/dist/build/transformers/floatToPixel.d.ts +15 -0
- package/dist/build/transformers/floatToPixel.js +41 -0
- package/dist/build/transformers/fontFamilyToCss.d.ts +14 -0
- package/dist/build/transformers/fontFamilyToCss.js +40 -0
- package/dist/build/transformers/fontFamilyToFigma.d.ts +14 -0
- package/dist/build/transformers/fontFamilyToFigma.js +46 -0
- package/dist/build/transformers/fontWeightToNumber.d.ts +9 -0
- package/dist/build/transformers/fontWeightToNumber.js +53 -0
- package/dist/build/transformers/index.d.ts +24 -0
- package/dist/build/transformers/index.js +51 -0
- package/dist/build/transformers/jsonDeprecated.d.ts +8 -0
- package/dist/build/transformers/jsonDeprecated.js +16 -0
- package/{src/transformers/namePathToCamelCase.ts → dist/build/transformers/namePathToCamelCase.d.ts} +2 -8
- package/dist/build/transformers/namePathToCamelCase.js +14 -0
- package/dist/build/transformers/namePathToDotNotation.d.ts +8 -0
- package/dist/build/transformers/namePathToDotNotation.js +33 -0
- package/dist/build/transformers/namePathToFigma.d.ts +9 -0
- package/dist/build/transformers/namePathToFigma.js +24 -0
- package/dist/build/transformers/namePathToKebabCase.d.ts +8 -0
- package/dist/build/transformers/namePathToKebabCase.js +18 -0
- package/dist/build/transformers/namePathToPascalCase.d.ts +8 -0
- package/dist/build/transformers/namePathToPascalCase.js +14 -0
- package/dist/build/transformers/namePathToSlashNotation.d.ts +8 -0
- package/dist/build/transformers/namePathToSlashNotation.js +18 -0
- package/dist/build/transformers/shadowToCss.d.ts +8 -0
- package/dist/build/transformers/shadowToCss.js +35 -0
- package/dist/build/transformers/typographyToCss.d.ts +8 -0
- package/dist/build/transformers/typographyToCss.js +29 -0
- package/dist/build/transformers/utilities/alpha.d.ts +9 -0
- package/dist/build/transformers/utilities/alpha.js +20 -0
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.d.ts +7 -0
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +17 -0
- package/dist/build/transformers/utilities/getTokenValue.d.ts +2 -0
- package/dist/build/transformers/utilities/getTokenValue.js +18 -0
- package/dist/build/transformers/utilities/hasSpaceInString.d.ts +1 -0
- package/dist/build/transformers/utilities/hasSpaceInString.js +10 -0
- package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +2 -0
- package/dist/build/transformers/utilities/hexToRgbaFloat.js +33 -0
- package/dist/build/transformers/utilities/invalidTokenError.d.ts +7 -0
- package/dist/build/transformers/utilities/invalidTokenError.js +26 -0
- package/dist/build/transformers/utilities/isRgbaFloat.d.ts +7 -0
- package/dist/build/transformers/utilities/isRgbaFloat.js +24 -0
- package/dist/build/transformers/utilities/mix.d.ts +5 -0
- package/dist/build/transformers/utilities/mix.js +40 -0
- package/dist/build/transformers/utilities/rgbaFloatToHex.d.ts +6 -0
- package/dist/build/transformers/utilities/rgbaFloatToHex.js +15 -0
- package/dist/build/utilities/copyFromDir.d.ts +8 -0
- package/dist/build/utilities/copyFromDir.js +34 -0
- package/dist/build/utilities/filterStringArray.d.ts +1 -0
- package/dist/build/utilities/filterStringArray.js +17 -0
- package/{src/utilities/getFlag.ts → dist/build/utilities/getFlag.d.ts} +1 -5
- package/dist/build/utilities/getFlag.js +16 -0
- package/dist/build/utilities/index.d.ts +3 -0
- package/dist/build/utilities/index.js +9 -0
- package/dist/build/utilities/joinFriendly.d.ts +1 -0
- package/dist/build/utilities/joinFriendly.js +5 -0
- package/dist/build/utilities/schemaErrorMessage.d.ts +1 -0
- package/dist/build/utilities/schemaErrorMessage.js +5 -0
- package/dist/build/utilities/toCamelCase.d.ts +1 -0
- package/dist/build/utilities/toCamelCase.js +20 -0
- package/dist/build/utilities/toPascalCase.d.ts +1 -0
- package/dist/build/utilities/toPascalCase.js +17 -0
- package/dist/build/utilities/treeWalker.d.ts +8 -0
- package/dist/build/utilities/treeWalker.js +27 -0
- package/{src/utilities/upperCaseFirstCharacter.ts → dist/build/utilities/upperCaseFirstCharacter.d.ts} +1 -3
- package/dist/build/utilities/upperCaseFirstCharacter.js +14 -0
- package/package.json +4 -5
- package/src/PrimerStyleDictionary.ts +0 -232
- package/src/filters/index.ts +0 -13
- package/src/filters/isColorWithAlpha.ts +0 -11
- package/src/filters/isColorWithMix.ts +0 -33
- package/src/filters/isFromFile.ts +0 -12
- package/src/formats/cssAdvanced.ts +0 -99
- package/src/formats/cssCustomMedia.ts +0 -24
- package/src/formats/index.ts +0 -9
- package/src/formats/javascriptCommonJs.ts +0 -21
- package/src/formats/javascriptEsm.ts +0 -21
- package/src/formats/jsonFigma.ts +0 -134
- package/src/formats/jsonNestedPrefixed.ts +0 -23
- package/src/formats/jsonOneDimensional.ts +0 -18
- package/src/formats/jsonPostCssFallback.ts +0 -16
- package/src/formats/typescriptExportDefinition.ts +0 -170
- package/src/formats/utilities/jsonToNestedValue.ts +0 -20
- package/src/formats/utilities/prefixTokens.ts +0 -17
- package/src/parsers/index.ts +0 -1
- package/src/parsers/w3cJsonParser.ts +0 -25
- package/src/platforms/css.ts +0 -101
- package/src/platforms/deprecatedJson.ts +0 -16
- package/src/platforms/docJson.ts +0 -34
- package/src/platforms/fallbacks.ts +0 -34
- package/src/platforms/figma.ts +0 -58
- package/src/platforms/index.ts +0 -10
- package/src/platforms/javascript.ts +0 -30
- package/src/platforms/json.ts +0 -32
- package/src/platforms/styleLint.ts +0 -34
- package/src/platforms/typeDefinitions.ts +0 -30
- package/src/platforms/typescript.ts +0 -30
- package/src/schemas/alphaValue.ts +0 -12
- package/src/schemas/baseToken.ts +0 -8
- package/src/schemas/borderToken.ts +0 -19
- package/src/schemas/collections.ts +0 -49
- package/src/schemas/colorHexValue.ts +0 -18
- package/src/schemas/colorToken.ts +0 -50
- package/src/schemas/designToken.ts +0 -38
- package/src/schemas/dimensionToken.ts +0 -34
- package/src/schemas/dimensionValue.ts +0 -16
- package/src/schemas/durationToken.ts +0 -12
- package/src/schemas/durationValue.ts +0 -9
- package/src/schemas/fontFamilyToken.ts +0 -21
- package/src/schemas/fontWeightToken.ts +0 -22
- package/src/schemas/fontWeightValue.ts +0 -14
- package/src/schemas/numberToken.ts +0 -28
- package/src/schemas/referenceValue.ts +0 -12
- package/src/schemas/scopes.ts +0 -40
- package/src/schemas/shadowToken.ts +0 -45
- package/src/schemas/stringToken.ts +0 -11
- package/src/schemas/tokenName.ts +0 -12
- package/src/schemas/tokenType.ts +0 -4
- package/src/schemas/typographyToken.ts +0 -20
- package/src/schemas/validTokenType.ts +0 -44
- package/src/schemas/viewportRangeToken.ts +0 -11
- package/src/test-utilities/getMockDictionary.ts +0 -22
- package/src/test-utilities/getMockFormatterArguments.ts +0 -21
- package/src/test-utilities/getMockParserInput.ts +0 -72
- package/src/test-utilities/getMockToken.ts +0 -25
- package/src/test-utilities/index.ts +0 -4
- package/src/tokens/base/color/dark/dark.dimmed.json5 +0 -1164
- package/src/tokens/base/color/dark/dark.high-contrast.json5 +0 -764
- package/src/tokens/base/color/dark/dark.json5 +0 -911
- package/src/tokens/base/color/dark/display-dark.json5 +0 -1774
- package/src/tokens/base/color/light/display-light.json5 +0 -1774
- package/src/tokens/base/color/light/light.high-contrast.json5 +0 -755
- package/src/tokens/base/color/light/light.json5 +0 -911
- package/src/tokens/base/size/size.json +0 -196
- package/src/tokens/base/typography/typography.json +0 -48
- package/src/tokens/fallback/color-fallbacks.json +0 -270
- package/src/tokens/functional/border/dark.json5 +0 -12
- package/src/tokens/functional/border/light.json5 +0 -12
- package/src/tokens/functional/color/dark/app-dark.json5 +0 -554
- package/src/tokens/functional/color/dark/data-vis-dark.json5 +0 -284
- package/src/tokens/functional/color/dark/display-dark.json5 +0 -1258
- package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +0 -194
- package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +0 -935
- package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +0 -310
- package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +0 -224
- package/src/tokens/functional/color/dark/patterns-dark.json5 +0 -3097
- package/src/tokens/functional/color/dark/primitives-dark.json5 +0 -1200
- package/src/tokens/functional/color/dark/syntax-dark.json5 +0 -559
- package/src/tokens/functional/color/light/app-light.json5 +0 -551
- package/src/tokens/functional/color/light/data-vis-light.json5 +0 -284
- package/src/tokens/functional/color/light/display-light.json5 +0 -1258
- package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +0 -819
- package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +0 -327
- package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +0 -237
- package/src/tokens/functional/color/light/patterns-light.json5 +0 -3091
- package/src/tokens/functional/color/light/primitives-light.json5 +0 -1193
- package/src/tokens/functional/color/light/syntax-light.json5 +0 -559
- package/src/tokens/functional/motion/loading.json5 +0 -17
- package/src/tokens/functional/motion/patterns.json5 +0 -28
- package/src/tokens/functional/shadow/dark.json5 +0 -383
- package/src/tokens/functional/shadow/light.json5 +0 -376
- package/src/tokens/functional/size/border.json +0 -111
- package/src/tokens/functional/size/breakpoints.json +0 -64
- package/src/tokens/functional/size/size-coarse.json +0 -28
- package/src/tokens/functional/size/size-fine.json +0 -28
- package/src/tokens/functional/size/size.json +0 -740
- package/src/tokens/functional/size/viewport.json +0 -28
- package/src/tokens/functional/typography/typography.json +0 -527
- package/src/tokens/removed/color.json +0 -421
- package/src/tokens/removed/testing.json5 +0 -4
- package/src/transformers/borderToCss.ts +0 -38
- package/src/transformers/colorToHex.ts +0 -16
- package/src/transformers/colorToHexAlpha.ts +0 -23
- package/src/transformers/colorToHexMix.ts +0 -19
- package/src/transformers/colorToRgbAlpha.ts +0 -19
- package/src/transformers/colorToRgbaFloat.ts +0 -45
- package/src/transformers/dimensionToPixelUnitless.ts +0 -60
- package/src/transformers/dimensionToRem.ts +0 -56
- package/src/transformers/dimensionToRemPxArray.ts +0 -60
- package/src/transformers/durationToCss.ts +0 -29
- package/src/transformers/figmaAttributes.ts +0 -79
- package/src/transformers/floatToPixel.ts +0 -40
- package/src/transformers/fontFamilyToCss.ts +0 -37
- package/src/transformers/fontFamilyToFigma.ts +0 -47
- package/src/transformers/fontWeightToNumber.ts +0 -53
- package/src/transformers/index.ts +0 -24
- package/src/transformers/jsonDeprecated.ts +0 -15
- package/src/transformers/namePathToDotNotation.ts +0 -34
- package/src/transformers/namePathToFigma.ts +0 -28
- package/src/transformers/namePathToKebabCase.ts +0 -19
- package/src/transformers/namePathToSlashNotation.ts +0 -19
- package/src/transformers/shadowToCss.ts +0 -37
- package/src/transformers/typographyToCss.ts +0 -31
- package/src/transformers/utilities/alpha.ts +0 -23
- package/src/transformers/utilities/checkRequiredTokenProperties.ts +0 -16
- package/src/transformers/utilities/getTokenValue.ts +0 -18
- package/src/transformers/utilities/hasSpaceInString.ts +0 -6
- package/src/transformers/utilities/hexToRgbaFloat.ts +0 -31
- package/src/transformers/utilities/invalidTokenError.ts +0 -34
- package/src/transformers/utilities/isRgbaFloat.ts +0 -29
- package/src/transformers/utilities/mix.ts +0 -46
- package/src/transformers/utilities/rgbaFloatToHex.ts +0 -15
- package/src/types/Border.d.ts +0 -5
- package/src/types/BorderTokenValue.d.ts +0 -10
- package/src/types/ColorHex.d.ts +0 -4
- package/src/types/PlatformInitializer.d.ts +0 -11
- package/src/types/Shadow.d.ts +0 -5
- package/src/types/ShadowTokenValue.d.ts +0 -14
- package/src/types/SizeEm.d.ts +0 -4
- package/src/types/SizePx.d.ts +0 -4
- package/src/types/SizeRem.d.ts +0 -4
- package/src/types/StyleDictionaryConfigGenerator.d.ts +0 -15
- package/src/types/TokenBuildInput.d.ts +0 -8
- package/src/types/TypographyTokenValue.d.ts +0 -12
- package/src/types/w3cTransformedToken.d.ts +0 -8
- package/src/utilities/copyFromDir.ts +0 -21
- package/src/utilities/index.ts +0 -3
- package/src/utilities/joinFriendly.ts +0 -2
- package/src/utilities/schemaErrorMessage.ts +0 -2
- package/src/utilities/toCamelCase.ts +0 -29
- package/src/utilities/treeWalker.ts +0 -27
package/src/platforms/css.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {isFromFile, isSource} from '../filters'
|
|
2
|
-
import type StyleDictionary from 'style-dictionary'
|
|
3
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
4
|
-
import type {TransformedToken} from 'style-dictionary'
|
|
5
|
-
|
|
6
|
-
const getCssSelectors = (outputFile: string) => {
|
|
7
|
-
// check for dark in the beginning of the output filename
|
|
8
|
-
const lastSlash = outputFile.lastIndexOf('/')
|
|
9
|
-
const outputBasename = outputFile.substring(lastSlash + 1, outputFile.indexOf('.'))
|
|
10
|
-
const themeName = outputBasename.replace(/-/g, '_')
|
|
11
|
-
const mode = outputBasename.substring(0, 4) === 'dark' ? 'dark' : 'light'
|
|
12
|
-
|
|
13
|
-
return [
|
|
14
|
-
{
|
|
15
|
-
selector: `[data-color-mode="${mode}"][data-${mode}-theme="${themeName}"], [data-color-mode="${mode}"][data-${mode}-theme="${themeName}"] ::backdrop, [data-color-mode="auto"][data-light-theme="${themeName}"], [data-color-mode="auto"][data-light-theme="${themeName}"] ::backdrop`,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
query: '@media (prefers-color-scheme: dark)',
|
|
19
|
-
selector: `[data-color-mode="auto"][data-dark-theme="${themeName}"], [data-color-mode="auto"][data-dark-theme="${themeName}"] ::backdrop`,
|
|
20
|
-
},
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const css: PlatformInitializer = (outputFile, prefix, buildPath, options): StyleDictionary.Platform => {
|
|
25
|
-
return {
|
|
26
|
-
prefix,
|
|
27
|
-
buildPath,
|
|
28
|
-
transforms: [
|
|
29
|
-
'name/pathToKebabCase',
|
|
30
|
-
'color/hex',
|
|
31
|
-
'color/hexAlpha',
|
|
32
|
-
'color/hexMix',
|
|
33
|
-
'dimension/rem',
|
|
34
|
-
'duration/css',
|
|
35
|
-
'shadow/css',
|
|
36
|
-
'border/css',
|
|
37
|
-
'typography/css',
|
|
38
|
-
'fontFamily/css',
|
|
39
|
-
'fontWeight/number',
|
|
40
|
-
],
|
|
41
|
-
options: {
|
|
42
|
-
basePxFontSize: 16,
|
|
43
|
-
},
|
|
44
|
-
files: [
|
|
45
|
-
{
|
|
46
|
-
destination: `${outputFile}`,
|
|
47
|
-
format: `css/advanced`,
|
|
48
|
-
filter: token => isSource(token) && options?.themed === true,
|
|
49
|
-
options: {
|
|
50
|
-
showFileHeader: false,
|
|
51
|
-
outputReferences: false,
|
|
52
|
-
descriptions: false,
|
|
53
|
-
queries: getCssSelectors(outputFile),
|
|
54
|
-
...options?.options,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
destination: `${outputFile}`,
|
|
59
|
-
format: `css/advanced`,
|
|
60
|
-
filter: token => isSource(token) && options?.themed !== true,
|
|
61
|
-
options: {
|
|
62
|
-
showFileHeader: false,
|
|
63
|
-
descriptions: false,
|
|
64
|
-
...options?.options,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
destination: `${outputFile}`,
|
|
69
|
-
format: `css/customMedia`,
|
|
70
|
-
filter: token => isSource(token) && options?.themed !== true && token.$type === 'custom-viewportRange',
|
|
71
|
-
options: {
|
|
72
|
-
showFileHeader: false,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
destination: `${outputFile}`,
|
|
77
|
-
format: `css/advanced`,
|
|
78
|
-
filter: token =>
|
|
79
|
-
isSource(token) &&
|
|
80
|
-
isFromFile(token, [
|
|
81
|
-
'src/tokens/functional/size/size-coarse.json',
|
|
82
|
-
'src/tokens/functional/size/size-fine.json',
|
|
83
|
-
]),
|
|
84
|
-
options: {
|
|
85
|
-
descriptions: false,
|
|
86
|
-
showFileHeader: false,
|
|
87
|
-
queries: [
|
|
88
|
-
{
|
|
89
|
-
query: '@media (pointer: fine)',
|
|
90
|
-
matcher: (token: TransformedToken) => token.filePath.includes('size-fine'),
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
query: '@media (pointer: coarse)',
|
|
94
|
-
matcher: (token: TransformedToken) => token.filePath.includes('size-coarse'),
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isDeprecated} from '../filters'
|
|
4
|
-
|
|
5
|
-
export const deprecatedJson: PlatformInitializer = (outputFile, prefix, buildPath): StyleDictionary.Platform => ({
|
|
6
|
-
prefix,
|
|
7
|
-
buildPath,
|
|
8
|
-
transforms: ['name/pathToDotNotation', 'json/deprecated'],
|
|
9
|
-
files: [
|
|
10
|
-
{
|
|
11
|
-
destination: outputFile,
|
|
12
|
-
format: `json/flat`,
|
|
13
|
-
filter: isDeprecated,
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
})
|
package/src/platforms/docJson.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isSource} from '../filters'
|
|
4
|
-
|
|
5
|
-
export const docJson: PlatformInitializer = (outputFile, prefix, buildPath): StyleDictionary.Platform => ({
|
|
6
|
-
prefix,
|
|
7
|
-
buildPath,
|
|
8
|
-
transforms: [
|
|
9
|
-
'name/pathToKebabCase',
|
|
10
|
-
'color/hex',
|
|
11
|
-
'color/hexMix',
|
|
12
|
-
'color/hexAlpha',
|
|
13
|
-
'dimension/rem',
|
|
14
|
-
'shadow/css',
|
|
15
|
-
'border/css',
|
|
16
|
-
'typography/css',
|
|
17
|
-
'fontFamily/css',
|
|
18
|
-
'fontWeight/number',
|
|
19
|
-
],
|
|
20
|
-
options: {
|
|
21
|
-
basePxFontSize: 16,
|
|
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
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isSource} from '../filters'
|
|
4
|
-
|
|
5
|
-
export const fallbacks: PlatformInitializer = (outputFile, prefix, buildPath): StyleDictionary.Platform => ({
|
|
6
|
-
prefix,
|
|
7
|
-
buildPath,
|
|
8
|
-
transforms: [
|
|
9
|
-
'name/pathToKebabCase',
|
|
10
|
-
'color/hex',
|
|
11
|
-
'color/hexMix',
|
|
12
|
-
'color/hexAlpha',
|
|
13
|
-
'dimension/rem',
|
|
14
|
-
'shadow/css',
|
|
15
|
-
'border/css',
|
|
16
|
-
'typography/css',
|
|
17
|
-
'fontFamily/css',
|
|
18
|
-
'fontWeight/number',
|
|
19
|
-
],
|
|
20
|
-
options: {
|
|
21
|
-
basePxFontSize: 16,
|
|
22
|
-
},
|
|
23
|
-
files: [
|
|
24
|
-
{
|
|
25
|
-
destination: outputFile,
|
|
26
|
-
format: `json/postCss-fallback`,
|
|
27
|
-
filter: isSource,
|
|
28
|
-
options: {
|
|
29
|
-
outputReferences: false,
|
|
30
|
-
outputVerbose: true,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
})
|
package/src/platforms/figma.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isSource} from '../filters'
|
|
4
|
-
|
|
5
|
-
const validFigmaToken = (token: StyleDictionary.TransformedToken) => {
|
|
6
|
-
const validTypes = ['color', 'dimension', 'shadow', 'fontWeight', 'fontFamily', 'number']
|
|
7
|
-
// is a siource token, not an included one
|
|
8
|
-
if (!isSource(token)) return false
|
|
9
|
-
|
|
10
|
-
if (`${token.value}`.substring(token.value.length - 2) === 'em') return false
|
|
11
|
-
// has a collection attribute
|
|
12
|
-
if (
|
|
13
|
-
!('$extensions' in token) ||
|
|
14
|
-
!('org.primer.figma' in token.$extensions) ||
|
|
15
|
-
!('collection' in token.$extensions['org.primer.figma'])
|
|
16
|
-
)
|
|
17
|
-
return false
|
|
18
|
-
// is a color or dimension type
|
|
19
|
-
return validTypes.includes(token.$type)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const figma: PlatformInitializer = (outputFile, prefix, buildPath, options): StyleDictionary.Platform => ({
|
|
23
|
-
prefix,
|
|
24
|
-
buildPath,
|
|
25
|
-
transforms: [
|
|
26
|
-
'color/rgbaFloat',
|
|
27
|
-
'name/pathToFigma',
|
|
28
|
-
// 'name/pathToSlashNotation',
|
|
29
|
-
'figma/attributes',
|
|
30
|
-
'fontFamily/figma',
|
|
31
|
-
'float/pixelUnitless',
|
|
32
|
-
'dimension/pixelUnitless',
|
|
33
|
-
// 'border/figma',
|
|
34
|
-
// 'typography/figma',
|
|
35
|
-
'fontWeight/number',
|
|
36
|
-
],
|
|
37
|
-
options: {
|
|
38
|
-
basePxFontSize: 16,
|
|
39
|
-
fontFamilies: {
|
|
40
|
-
'fontStack/system': 'SF Pro Text',
|
|
41
|
-
'fontStack/sansSerif': 'SF Pro Text',
|
|
42
|
-
'fontStack/sansSerifDisplay': 'SF Pro Display',
|
|
43
|
-
'fontStack/monospace': 'SF Mono',
|
|
44
|
-
},
|
|
45
|
-
...options,
|
|
46
|
-
},
|
|
47
|
-
files: [
|
|
48
|
-
{
|
|
49
|
-
destination: outputFile,
|
|
50
|
-
filter: validFigmaToken,
|
|
51
|
-
format: `json/figma`,
|
|
52
|
-
options: {
|
|
53
|
-
outputReferences: true,
|
|
54
|
-
mode: options?.mode,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
})
|
package/src/platforms/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export {css} from './css'
|
|
2
|
-
export {deprecatedJson} from './deprecatedJson'
|
|
3
|
-
export {docJson} from './docJson'
|
|
4
|
-
export {fallbacks} from './fallbacks'
|
|
5
|
-
export {figma} from './figma'
|
|
6
|
-
export {javascript} from './javascript'
|
|
7
|
-
export {json} from './json'
|
|
8
|
-
export {styleLint} from './styleLint'
|
|
9
|
-
export {typeDefinitions} from './typeDefinitions'
|
|
10
|
-
export {typescript} from './typescript'
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isSource} from '../filters'
|
|
4
|
-
|
|
5
|
-
export const javascript: PlatformInitializer = (outputFile, prefix, buildPath): StyleDictionary.Platform => ({
|
|
6
|
-
prefix,
|
|
7
|
-
buildPath,
|
|
8
|
-
transforms: [
|
|
9
|
-
'color/hex',
|
|
10
|
-
'color/hexMix',
|
|
11
|
-
'color/hexAlpha',
|
|
12
|
-
'dimension/rem',
|
|
13
|
-
'shadow/css',
|
|
14
|
-
'border/css',
|
|
15
|
-
'typography/css',
|
|
16
|
-
'fontFamily/css',
|
|
17
|
-
'fontWeight/number',
|
|
18
|
-
],
|
|
19
|
-
options: {
|
|
20
|
-
showFileHeader: false,
|
|
21
|
-
basePxFontSize: 16,
|
|
22
|
-
},
|
|
23
|
-
files: [
|
|
24
|
-
{
|
|
25
|
-
format: 'javascript/commonJs',
|
|
26
|
-
destination: outputFile,
|
|
27
|
-
filter: isSource,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
})
|
package/src/platforms/json.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isSource} from '../filters'
|
|
4
|
-
|
|
5
|
-
export const json: PlatformInitializer = (outputFile, prefix, buildPath): StyleDictionary.Platform => ({
|
|
6
|
-
prefix,
|
|
7
|
-
buildPath,
|
|
8
|
-
transforms: [
|
|
9
|
-
'color/hex',
|
|
10
|
-
'color/hexMix',
|
|
11
|
-
'color/hexAlpha',
|
|
12
|
-
'dimension/rem',
|
|
13
|
-
'shadow/css',
|
|
14
|
-
'border/css',
|
|
15
|
-
'typography/css',
|
|
16
|
-
'fontFamily/css',
|
|
17
|
-
'fontWeight/number',
|
|
18
|
-
],
|
|
19
|
-
options: {
|
|
20
|
-
basePxFontSize: 16,
|
|
21
|
-
},
|
|
22
|
-
files: [
|
|
23
|
-
{
|
|
24
|
-
destination: outputFile,
|
|
25
|
-
filter: isSource,
|
|
26
|
-
format: `json/nested-prefixed`,
|
|
27
|
-
options: {
|
|
28
|
-
outputReferences: false,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isSource} from '../filters'
|
|
4
|
-
|
|
5
|
-
export const styleLint: PlatformInitializer = (outputFile, prefix, buildPath): StyleDictionary.Platform => ({
|
|
6
|
-
prefix,
|
|
7
|
-
buildPath,
|
|
8
|
-
transforms: [
|
|
9
|
-
'name/pathToKebabCase',
|
|
10
|
-
'color/hex',
|
|
11
|
-
'color/hexMix',
|
|
12
|
-
'color/hexAlpha',
|
|
13
|
-
'dimension/remPxArray',
|
|
14
|
-
'shadow/css',
|
|
15
|
-
'border/css',
|
|
16
|
-
'typography/css',
|
|
17
|
-
'fontFamily/css',
|
|
18
|
-
'fontWeight/number',
|
|
19
|
-
],
|
|
20
|
-
options: {
|
|
21
|
-
basePxFontSize: 16,
|
|
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
|
-
})
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isSource} from '../filters'
|
|
4
|
-
import {upperCaseFirstCharacter} from '../utilities'
|
|
5
|
-
|
|
6
|
-
export const typeDefinitions: PlatformInitializer = (outputFile, prefix, buildPath): StyleDictionary.Platform => ({
|
|
7
|
-
prefix,
|
|
8
|
-
buildPath,
|
|
9
|
-
transforms: [
|
|
10
|
-
'color/hex',
|
|
11
|
-
'color/hexAlpha',
|
|
12
|
-
'shadow/css',
|
|
13
|
-
'border/css',
|
|
14
|
-
'dimension/rem',
|
|
15
|
-
'typography/css',
|
|
16
|
-
'fontFamily/css',
|
|
17
|
-
'fontWeight/number',
|
|
18
|
-
],
|
|
19
|
-
files: [
|
|
20
|
-
{
|
|
21
|
-
format: 'typescript/export-definition',
|
|
22
|
-
destination: `${upperCaseFirstCharacter(outputFile)}DesignTokens.d.ts`,
|
|
23
|
-
filter: isSource,
|
|
24
|
-
options: {
|
|
25
|
-
tokenTypesPath: './src/types/',
|
|
26
|
-
moduleName: `${upperCaseFirstCharacter(outputFile)}DesignTokens`,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
})
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import type {PlatformInitializer} from '../types/PlatformInitializer'
|
|
3
|
-
import {isSource} from '../filters'
|
|
4
|
-
|
|
5
|
-
export const typescript: PlatformInitializer = (outputFile, prefix, buildPath): StyleDictionary.Platform => ({
|
|
6
|
-
prefix,
|
|
7
|
-
buildPath,
|
|
8
|
-
transforms: [
|
|
9
|
-
'color/hex',
|
|
10
|
-
'color/hexMix',
|
|
11
|
-
'color/hexAlpha',
|
|
12
|
-
'dimension/rem',
|
|
13
|
-
'shadow/css',
|
|
14
|
-
'border/css',
|
|
15
|
-
'typography/css',
|
|
16
|
-
'fontFamily/css',
|
|
17
|
-
'fontWeight/number',
|
|
18
|
-
],
|
|
19
|
-
options: {
|
|
20
|
-
showFileHeader: false,
|
|
21
|
-
basePxFontSize: 16,
|
|
22
|
-
},
|
|
23
|
-
files: [
|
|
24
|
-
{
|
|
25
|
-
format: 'javascript/esm',
|
|
26
|
-
destination: outputFile,
|
|
27
|
-
filter: isSource,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod'
|
|
2
|
-
import {schemaErrorMessage} from '../utilities/schemaErrorMessage'
|
|
3
|
-
|
|
4
|
-
export const alphaValue = z.any().refine(
|
|
5
|
-
value => typeof value === 'number' && value >= 0 && value <= 1,
|
|
6
|
-
value => ({
|
|
7
|
-
message: schemaErrorMessage(
|
|
8
|
-
`Invalid alpha value: "${value}" (${typeof value})`,
|
|
9
|
-
'Alpha value must be a number between 0 and 1.',
|
|
10
|
-
),
|
|
11
|
-
}),
|
|
12
|
-
)
|
package/src/schemas/baseToken.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod'
|
|
2
|
-
import {baseToken} from './baseToken'
|
|
3
|
-
import {referenceValue} from './referenceValue'
|
|
4
|
-
import {colorHexValue} from './colorHexValue'
|
|
5
|
-
import {dimensionValue} from './dimensionValue'
|
|
6
|
-
import {tokenType} from './tokenType'
|
|
7
|
-
|
|
8
|
-
export const borderValue = z.object({
|
|
9
|
-
color: z.union([colorHexValue, referenceValue]),
|
|
10
|
-
style: z.enum(['solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'outset', 'inset']),
|
|
11
|
-
width: z.union([dimensionValue, referenceValue]),
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
export const borderToken = baseToken
|
|
15
|
-
.extend({
|
|
16
|
-
$value: z.union([borderValue, referenceValue]),
|
|
17
|
-
$type: tokenType('border'),
|
|
18
|
-
})
|
|
19
|
-
.strict()
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod'
|
|
2
|
-
import {joinFriendly} from '../utilities/joinFriendly'
|
|
3
|
-
import {schemaErrorMessage} from '../utilities/schemaErrorMessage'
|
|
4
|
-
|
|
5
|
-
type Collections =
|
|
6
|
-
| 'base/color/light'
|
|
7
|
-
| 'base/color/light-high-contrast'
|
|
8
|
-
| 'base/color/dark'
|
|
9
|
-
| 'base/color/dark-dimmed'
|
|
10
|
-
| 'base/color/dark-high-contrast'
|
|
11
|
-
| 'base/typography'
|
|
12
|
-
| 'mode'
|
|
13
|
-
| 'pattern/mode'
|
|
14
|
-
| 'base/size'
|
|
15
|
-
| 'functional/size'
|
|
16
|
-
| 'pattern/size'
|
|
17
|
-
| 'typography'
|
|
18
|
-
|
|
19
|
-
export const collection = (collections: Collections[]) => {
|
|
20
|
-
return z.string().refine(
|
|
21
|
-
value => collections.includes(value as Collections),
|
|
22
|
-
value => ({
|
|
23
|
-
message: schemaErrorMessage(
|
|
24
|
-
`Invalid collection: "${value}"`,
|
|
25
|
-
`Valid collections are ${joinFriendly(collections)}`,
|
|
26
|
-
),
|
|
27
|
-
}),
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type Modes =
|
|
32
|
-
| 'light'
|
|
33
|
-
| 'dark'
|
|
34
|
-
| 'dark dimmed'
|
|
35
|
-
| 'light high contrast'
|
|
36
|
-
| 'dark high contrast'
|
|
37
|
-
| 'light colorblind'
|
|
38
|
-
| 'dark colorblind'
|
|
39
|
-
| 'light tritanopia'
|
|
40
|
-
| 'dark tritanopia'
|
|
41
|
-
|
|
42
|
-
export const mode = (modes: Modes[]) => {
|
|
43
|
-
return z.string().refine(
|
|
44
|
-
value => modes.includes(value as Modes),
|
|
45
|
-
value => ({
|
|
46
|
-
message: schemaErrorMessage(`Invalid mode: "${value}"`, `Valid modes are ${joinFriendly(modes)}`),
|
|
47
|
-
}),
|
|
48
|
-
)
|
|
49
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod'
|
|
2
|
-
import {schemaErrorMessage} from '../utilities/schemaErrorMessage'
|
|
3
|
-
|
|
4
|
-
const colorHex3RegEx = '^#[0-9a-f]{3}$'
|
|
5
|
-
const colorHex6RegEx = '^#[0-9a-f]{6}$'
|
|
6
|
-
const colorHex8RegEx = '^#[0-9a-f]{8}$'
|
|
7
|
-
|
|
8
|
-
const colorHexRegex = new RegExp(`(${colorHex3RegEx})|(${colorHex6RegEx})|(${colorHex8RegEx})`, 'i')
|
|
9
|
-
|
|
10
|
-
export const colorHexValue = z.string().refine(
|
|
11
|
-
color => colorHexRegex.test(color),
|
|
12
|
-
color => ({
|
|
13
|
-
message: schemaErrorMessage(
|
|
14
|
-
`Invalid color: "${color}"`,
|
|
15
|
-
'Color must be a hex string or a reference to a color token.',
|
|
16
|
-
),
|
|
17
|
-
}),
|
|
18
|
-
)
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod'
|
|
2
|
-
import {colorHexValue} from './colorHexValue'
|
|
3
|
-
import {referenceValue} from './referenceValue'
|
|
4
|
-
import {alphaValue} from './alphaValue'
|
|
5
|
-
import {baseToken} from './baseToken'
|
|
6
|
-
import {collection, mode} from './collections'
|
|
7
|
-
import {scopes} from './scopes'
|
|
8
|
-
import {tokenType} from './tokenType'
|
|
9
|
-
|
|
10
|
-
export const colorToken = baseToken
|
|
11
|
-
.extend({
|
|
12
|
-
$value: z.union([colorHexValue, referenceValue]),
|
|
13
|
-
$type: tokenType('color'),
|
|
14
|
-
alpha: alphaValue.optional().nullable(),
|
|
15
|
-
mix: z
|
|
16
|
-
.object({
|
|
17
|
-
color: z.string(),
|
|
18
|
-
weight: z.number().min(0).max(1),
|
|
19
|
-
})
|
|
20
|
-
.nullable()
|
|
21
|
-
.optional(),
|
|
22
|
-
$extensions: z
|
|
23
|
-
.object({
|
|
24
|
-
'org.primer.figma': z.object({
|
|
25
|
-
collection: collection([
|
|
26
|
-
'base/color/light',
|
|
27
|
-
'base/color/light-high-contrast',
|
|
28
|
-
'base/color/dark',
|
|
29
|
-
'base/color/dark-dimmed',
|
|
30
|
-
'base/color/dark-high-contrast',
|
|
31
|
-
'mode',
|
|
32
|
-
'pattern/mode',
|
|
33
|
-
]).optional(),
|
|
34
|
-
mode: mode([
|
|
35
|
-
'light',
|
|
36
|
-
'dark',
|
|
37
|
-
'dark dimmed',
|
|
38
|
-
'light high contrast',
|
|
39
|
-
'dark high contrast',
|
|
40
|
-
'light colorblind',
|
|
41
|
-
'dark colorblind',
|
|
42
|
-
'light tritanopia',
|
|
43
|
-
'dark tritanopia',
|
|
44
|
-
]).optional(),
|
|
45
|
-
scopes: scopes(['all', 'bgColor', 'fgColor', 'borderColor', 'effectColor']).optional(),
|
|
46
|
-
}),
|
|
47
|
-
})
|
|
48
|
-
.optional(),
|
|
49
|
-
})
|
|
50
|
-
.strict()
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod'
|
|
2
|
-
import {tokenName} from './tokenName'
|
|
3
|
-
import {stringToken} from './stringToken'
|
|
4
|
-
import {viewportRangeToken} from './viewportRangeToken'
|
|
5
|
-
import {numberToken} from './numberToken'
|
|
6
|
-
import {fontWeightToken} from './fontWeightToken'
|
|
7
|
-
import {typographyToken} from './typographyToken'
|
|
8
|
-
import {borderToken} from './borderToken'
|
|
9
|
-
import {dimensionToken} from './dimensionToken'
|
|
10
|
-
import {colorToken} from './colorToken'
|
|
11
|
-
import {fontFamilyToken} from './fontFamilyToken'
|
|
12
|
-
import {shadowToken} from './shadowToken'
|
|
13
|
-
import {durationToken} from './durationToken'
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
-
// @ts-ignore: TODO: fix this
|
|
17
|
-
export const designToken = z.record(
|
|
18
|
-
tokenName,
|
|
19
|
-
z.lazy((): z.ZodTypeAny => {
|
|
20
|
-
return z.union([
|
|
21
|
-
z.discriminatedUnion('$type', [
|
|
22
|
-
colorToken,
|
|
23
|
-
dimensionToken,
|
|
24
|
-
shadowToken,
|
|
25
|
-
borderToken,
|
|
26
|
-
fontFamilyToken,
|
|
27
|
-
fontWeightToken,
|
|
28
|
-
typographyToken,
|
|
29
|
-
viewportRangeToken,
|
|
30
|
-
numberToken,
|
|
31
|
-
durationToken,
|
|
32
|
-
stringToken,
|
|
33
|
-
]),
|
|
34
|
-
// referenceToken,
|
|
35
|
-
designToken,
|
|
36
|
-
])
|
|
37
|
-
}),
|
|
38
|
-
)
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod'
|
|
2
|
-
import {baseToken} from './baseToken'
|
|
3
|
-
import {referenceValue} from './referenceValue'
|
|
4
|
-
import {collection} from './collections'
|
|
5
|
-
import {scopes} from './scopes'
|
|
6
|
-
import {dimensionValue} from './dimensionValue'
|
|
7
|
-
import {tokenType} from './tokenType'
|
|
8
|
-
|
|
9
|
-
export const dimensionToken = baseToken
|
|
10
|
-
.extend({
|
|
11
|
-
$value: z.union([dimensionValue, referenceValue]),
|
|
12
|
-
$type: tokenType('dimension'),
|
|
13
|
-
$extensions: z
|
|
14
|
-
.object({
|
|
15
|
-
'org.primer.figma': z.object({
|
|
16
|
-
collection: collection(['base/size', 'functional/size', 'pattern/size', 'typography']),
|
|
17
|
-
scopes: scopes([
|
|
18
|
-
'all',
|
|
19
|
-
'size',
|
|
20
|
-
'gap',
|
|
21
|
-
'radius',
|
|
22
|
-
'borderColor',
|
|
23
|
-
'effectFloat',
|
|
24
|
-
'fontSize',
|
|
25
|
-
'letterSpacing',
|
|
26
|
-
'lineHeight',
|
|
27
|
-
'paragraphSpacing',
|
|
28
|
-
'paragraphIndent',
|
|
29
|
-
]),
|
|
30
|
-
}),
|
|
31
|
-
})
|
|
32
|
-
.optional(),
|
|
33
|
-
})
|
|
34
|
-
.strict()
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod'
|
|
2
|
-
import {schemaErrorMessage} from '../utilities/schemaErrorMessage'
|
|
3
|
-
|
|
4
|
-
export const dimensionValue = z.union([
|
|
5
|
-
z.string().refine(
|
|
6
|
-
dim => /(^-?[0-9]+(px|rem)$|^-?[0-9]+\.?[0-9]*em$)/.test(dim),
|
|
7
|
-
val => ({
|
|
8
|
-
message: schemaErrorMessage(
|
|
9
|
-
`Invalid dimension: "${val}"`,
|
|
10
|
-
`Dimension must be a string with a unit (px, rem or em) or 0`,
|
|
11
|
-
),
|
|
12
|
-
}),
|
|
13
|
-
),
|
|
14
|
-
z.literal('0'),
|
|
15
|
-
z.literal(0),
|
|
16
|
-
])
|