@primer/primitives 9.1.2 → 10.0.0-rc.0c3e84bf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/build/PrimerStyleDictionary.d.ts +1 -2
- package/dist/build/PrimerStyleDictionary.js +52 -64
- package/dist/build/filters/index.d.ts +14 -13
- package/dist/build/filters/index.js +14 -29
- package/dist/build/filters/isBorder.d.ts +3 -3
- package/dist/build/filters/isBorder.js +2 -6
- package/dist/build/filters/isColor.d.ts +3 -3
- package/dist/build/filters/isColor.js +8 -7
- package/dist/build/filters/isColorWithAlpha.d.ts +3 -3
- package/dist/build/filters/isColorWithAlpha.js +4 -8
- package/dist/build/filters/isColorWithMix.d.ts +3 -3
- package/dist/build/filters/isColorWithMix.js +4 -8
- package/dist/build/filters/isCubicBezier.d.ts +7 -0
- package/dist/build/filters/isCubicBezier.js +10 -0
- package/dist/build/filters/isDeprecated.d.ts +3 -3
- package/dist/build/filters/isDeprecated.js +3 -7
- package/dist/build/filters/isDimension.d.ts +3 -3
- package/dist/build/filters/isDimension.js +2 -6
- package/dist/build/filters/isDuration.d.ts +3 -3
- package/dist/build/filters/isDuration.js +2 -6
- package/dist/build/filters/isFontFamily.d.ts +3 -3
- package/dist/build/filters/isFontFamily.js +2 -6
- package/dist/build/filters/isFontWeight.d.ts +3 -3
- package/dist/build/filters/isFontWeight.js +2 -6
- package/dist/build/filters/isFromFile.d.ts +3 -3
- package/dist/build/filters/isFromFile.js +2 -6
- package/dist/build/filters/isNumber.d.ts +3 -3
- package/dist/build/filters/isNumber.js +4 -6
- package/dist/build/filters/isShadow.d.ts +3 -3
- package/dist/build/filters/isShadow.js +2 -6
- package/dist/build/filters/isSource.d.ts +3 -3
- package/dist/build/filters/isSource.js +2 -6
- package/dist/build/filters/isTypography.d.ts +3 -3
- package/dist/build/filters/isTypography.js +2 -6
- package/dist/build/formats/cssAdvanced.d.ts +2 -2
- package/dist/build/formats/cssAdvanced.js +22 -20
- package/dist/build/formats/cssCustomMedia.d.ts +2 -2
- package/dist/build/formats/cssCustomMedia.js +16 -15
- package/dist/build/formats/index.d.ts +9 -9
- package/dist/build/formats/index.js +9 -21
- package/dist/build/formats/javascriptCommonJs.d.ts +2 -2
- package/dist/build/formats/javascriptCommonJs.js +17 -16
- package/dist/build/formats/javascriptEsm.d.ts +2 -2
- package/dist/build/formats/javascriptEsm.js +17 -16
- package/dist/build/formats/jsonFigma.d.ts +2 -2
- package/dist/build/formats/jsonFigma.js +27 -22
- package/dist/build/formats/jsonNestedPrefixed.d.ts +3 -3
- package/dist/build/formats/jsonNestedPrefixed.js +17 -15
- package/dist/build/formats/jsonOneDimensional.d.ts +3 -3
- package/dist/build/formats/jsonOneDimensional.js +24 -16
- package/dist/build/formats/jsonPostCssFallback.d.ts +3 -3
- package/dist/build/formats/jsonPostCssFallback.js +5 -12
- package/dist/build/formats/typescriptExportDefinition.d.ts +2 -2
- package/dist/build/formats/typescriptExportDefinition.js +50 -46
- 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 +2 -2
- package/dist/build/formats/utilities/jsonToFlat.js +1 -5
- package/dist/build/formats/utilities/jsonToNestedValue.d.ts +2 -2
- package/dist/build/formats/utilities/jsonToNestedValue.js +4 -6
- package/dist/build/formats/utilities/prefixTokens.d.ts +2 -2
- package/dist/build/formats/utilities/prefixTokens.js +1 -5
- package/dist/build/parsers/index.d.ts +1 -1
- package/dist/build/parsers/index.js +1 -5
- package/dist/build/parsers/w3cJsonParser.d.ts +2 -2
- package/dist/build/parsers/w3cJsonParser.js +7 -9
- package/dist/build/platforms/css.d.ts +1 -1
- package/dist/build/platforms/css.js +20 -11
- package/dist/build/platforms/deprecatedJson.d.ts +1 -1
- package/dist/build/platforms/deprecatedJson.js +3 -7
- package/dist/build/platforms/docJson.d.ts +1 -1
- package/dist/build/platforms/docJson.js +8 -7
- package/dist/build/platforms/fallbacks.d.ts +1 -1
- package/dist/build/platforms/fallbacks.js +3 -7
- package/dist/build/platforms/figma.d.ts +1 -1
- package/dist/build/platforms/figma.js +21 -14
- package/dist/build/platforms/index.d.ts +10 -10
- package/dist/build/platforms/index.js +10 -23
- package/dist/build/platforms/javascript.d.ts +1 -1
- package/dist/build/platforms/javascript.js +3 -7
- package/dist/build/platforms/json.d.ts +1 -1
- package/dist/build/platforms/json.js +3 -7
- package/dist/build/platforms/styleLint.d.ts +1 -1
- package/dist/build/platforms/styleLint.js +3 -7
- package/dist/build/platforms/typeDefinitions.d.ts +1 -1
- package/dist/build/platforms/typeDefinitions.js +6 -10
- package/dist/build/platforms/typescript.d.ts +1 -1
- package/dist/build/platforms/typescript.js +3 -7
- package/dist/build/schemas/alphaValue.js +4 -7
- package/dist/build/schemas/baseToken.d.ts +3 -3
- package/dist/build/schemas/baseToken.js +4 -7
- package/dist/build/schemas/borderToken.d.ts +6 -6
- package/dist/build/schemas/borderToken.js +13 -16
- package/dist/build/schemas/collections.js +8 -14
- package/dist/build/schemas/colorHexValue.js +4 -7
- package/dist/build/schemas/colorToken.d.ts +37 -25
- package/dist/build/schemas/colorToken.js +25 -24
- package/dist/build/schemas/cubicBezierToken.d.ts +18 -0
- package/dist/build/schemas/cubicBezierToken.js +8 -0
- package/dist/build/schemas/designToken.js +30 -32
- package/dist/build/schemas/dimensionToken.d.ts +15 -8
- package/dist/build/schemas/dimensionToken.js +15 -17
- package/dist/build/schemas/dimensionValue.js +7 -10
- package/dist/build/schemas/durationToken.d.ts +6 -6
- package/dist/build/schemas/durationToken.js +8 -11
- package/dist/build/schemas/durationValue.js +4 -7
- package/dist/build/schemas/fontFamilyToken.d.ts +8 -8
- package/dist/build/schemas/fontFamilyToken.js +13 -16
- package/dist/build/schemas/fontWeightToken.d.ts +8 -8
- package/dist/build/schemas/fontWeightToken.js +14 -17
- package/dist/build/schemas/fontWeightValue.js +4 -7
- package/dist/build/schemas/numberToken.d.ts +8 -8
- package/dist/build/schemas/numberToken.js +15 -18
- package/dist/build/schemas/referenceValue.js +4 -7
- package/dist/build/schemas/scopes.js +5 -10
- package/dist/build/schemas/shadowToken.d.ts +23 -16
- package/dist/build/schemas/shadowToken.js +27 -27
- package/dist/build/schemas/stringToken.d.ts +6 -6
- package/dist/build/schemas/stringToken.js +7 -10
- package/dist/build/schemas/tokenName.js +4 -7
- package/dist/build/schemas/tokenType.d.ts +2 -2
- package/dist/build/schemas/tokenType.js +2 -6
- package/dist/build/schemas/typographyToken.d.ts +6 -6
- package/dist/build/schemas/typographyToken.js +14 -17
- package/dist/build/schemas/validTokenType.d.ts +1 -1
- package/dist/build/schemas/validTokenType.js +10 -13
- package/dist/build/schemas/viewportRangeToken.d.ts +6 -6
- package/dist/build/schemas/viewportRangeToken.js +7 -10
- package/dist/build/transformers/borderToCss.d.ts +3 -3
- package/dist/build/transformers/borderToCss.js +16 -16
- package/dist/build/transformers/colorToHex.d.ts +2 -2
- package/dist/build/transformers/colorToHex.js +11 -13
- package/dist/build/transformers/colorToHexMix.d.ts +2 -2
- package/dist/build/transformers/colorToHexMix.js +10 -15
- package/dist/build/transformers/colorToRgbAlpha.d.ts +2 -2
- package/dist/build/transformers/colorToRgbAlpha.js +10 -12
- package/dist/build/transformers/colorToRgbaFloat.d.ts +2 -2
- package/dist/build/transformers/colorToRgbaFloat.js +24 -28
- package/dist/build/transformers/cubicBezierToCss.d.ts +8 -0
- package/dist/build/transformers/cubicBezierToCss.js +23 -0
- package/dist/build/transformers/dimensionToPixelUnitless.d.ts +2 -2
- package/dist/build/transformers/dimensionToPixelUnitless.js +13 -14
- package/dist/build/transformers/dimensionToRem.d.ts +2 -2
- package/dist/build/transformers/dimensionToRem.js +12 -13
- package/dist/build/transformers/dimensionToRemPxArray.d.ts +2 -2
- package/dist/build/transformers/dimensionToRemPxArray.js +11 -12
- package/dist/build/transformers/durationToCss.d.ts +2 -2
- package/dist/build/transformers/durationToCss.js +10 -11
- package/dist/build/transformers/figmaAttributes.d.ts +2 -2
- package/dist/build/transformers/figmaAttributes.js +5 -7
- package/dist/build/transformers/floatToPixel.d.ts +4 -4
- package/dist/build/transformers/floatToPixel.js +12 -14
- package/dist/build/transformers/fontFamilyToCss.d.ts +2 -2
- package/dist/build/transformers/fontFamilyToCss.js +10 -13
- package/dist/build/transformers/fontFamilyToFigma.d.ts +3 -3
- package/dist/build/transformers/fontFamilyToFigma.js +15 -17
- package/dist/build/transformers/fontWeightToNumber.d.ts +2 -2
- package/dist/build/transformers/fontWeightToNumber.js +8 -11
- package/dist/build/transformers/index.d.ts +25 -24
- package/dist/build/transformers/index.js +25 -51
- package/dist/build/transformers/jsonDeprecated.d.ts +2 -2
- package/dist/build/transformers/jsonDeprecated.js +6 -8
- package/dist/build/transformers/namePathToCamelCase.d.ts +2 -2
- package/dist/build/transformers/namePathToCamelCase.js +5 -7
- package/dist/build/transformers/namePathToDotNotation.d.ts +2 -2
- package/dist/build/transformers/namePathToDotNotation.js +6 -8
- package/dist/build/transformers/namePathToFigma.d.ts +3 -3
- package/dist/build/transformers/namePathToFigma.js +5 -8
- package/dist/build/transformers/namePathToKebabCase.d.ts +2 -2
- package/dist/build/transformers/namePathToKebabCase.js +4 -6
- package/dist/build/transformers/namePathToPascalCase.d.ts +2 -2
- package/dist/build/transformers/namePathToPascalCase.js +5 -7
- package/dist/build/transformers/namePathToSlashNotation.d.ts +2 -2
- package/dist/build/transformers/namePathToSlashNotation.js +4 -6
- package/dist/build/transformers/shadowToCss.d.ts +2 -2
- package/dist/build/transformers/shadowToCss.js +14 -15
- package/dist/build/transformers/typographyToCss.d.ts +2 -2
- package/dist/build/transformers/typographyToCss.js +13 -15
- package/dist/build/transformers/utilities/alpha.d.ts +1 -1
- package/dist/build/transformers/utilities/alpha.js +4 -8
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +1 -5
- package/dist/build/transformers/utilities/getTokenValue.d.ts +2 -2
- package/dist/build/transformers/utilities/getTokenValue.js +10 -12
- package/dist/build/transformers/utilities/hasSpaceInString.js +1 -5
- package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +1 -1
- package/dist/build/transformers/utilities/hexToRgbaFloat.js +1 -5
- package/dist/build/transformers/utilities/invalidTokenError.d.ts +1 -1
- package/dist/build/transformers/utilities/invalidTokenError.js +11 -10
- package/dist/build/transformers/utilities/isRgbaFloat.js +1 -5
- package/dist/build/transformers/utilities/mix.js +5 -7
- package/dist/build/transformers/utilities/rgbaFloatToHex.js +1 -5
- package/dist/build/types/Border.d.ts +5 -0
- package/dist/build/types/BorderTokenValue.d.ts +10 -0
- package/dist/build/types/ColorHex.d.ts +4 -0
- package/dist/build/types/PlatformInitializer.d.ts +11 -0
- package/dist/build/types/Shadow.d.ts +5 -0
- package/dist/build/types/ShadowTokenValue.d.ts +14 -0
- package/dist/build/types/SizeEm.d.ts +4 -0
- package/dist/build/types/SizePx.d.ts +4 -0
- package/dist/build/types/SizeRem.d.ts +4 -0
- package/dist/build/types/StyleDictionaryConfigGenerator.d.ts +15 -0
- package/dist/build/types/TokenBuildInput.d.ts +8 -0
- package/dist/build/types/TypographyTokenValue.d.ts +12 -0
- package/dist/build/types/w3cTransformedToken.d.ts +8 -0
- package/dist/build/utilities/copyFromDir.d.ts +2 -2
- package/dist/build/utilities/copyFromDir.js +7 -10
- package/dist/build/utilities/filterStringArray.js +1 -5
- package/dist/build/utilities/getFlag.js +1 -5
- package/dist/build/utilities/index.d.ts +9 -3
- package/dist/build/utilities/index.js +9 -9
- package/dist/build/utilities/joinFriendly.js +1 -5
- package/dist/build/utilities/schemaErrorMessage.js +1 -5
- package/dist/build/utilities/toCamelCase.js +5 -9
- package/dist/build/utilities/toPascalCase.js +5 -9
- package/dist/build/utilities/treeWalker.js +2 -6
- package/dist/build/utilities/upperCaseFirstCharacter.js +1 -5
- 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 +62 -42
- 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 +58 -38
- 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/base/size/size.json +76 -76
- package/dist/docs/base/typography/typography.json +16 -16
- package/dist/docs/functional/motion/motion.json +33 -18
- package/dist/docs/functional/size/border.json +56 -56
- package/dist/docs/functional/size/breakpoints.json +24 -24
- package/dist/docs/functional/size/size-coarse.json +12 -12
- package/dist/docs/functional/size/size-fine.json +12 -12
- package/dist/docs/functional/size/size.json +264 -264
- package/dist/docs/functional/size/viewport.json +24 -24
- package/dist/docs/functional/themes/dark-colorblind.json +2561 -4201
- package/dist/docs/functional/themes/dark-dimmed.json +2610 -3892
- package/dist/docs/functional/themes/dark-high-contrast.json +2687 -5815
- package/dist/docs/functional/themes/dark-tritanopia.json +2613 -4059
- package/dist/docs/functional/themes/dark.json +2590 -3450
- package/dist/docs/functional/themes/light-colorblind.json +2568 -4168
- package/dist/docs/functional/themes/light-high-contrast.json +2686 -5526
- package/dist/docs/functional/themes/light-tritanopia.json +2542 -4026
- package/dist/docs/functional/themes/light.json +2570 -3436
- package/dist/docs/functional/typography/typography.json +206 -206
- package/dist/fallbacks/base/motion/motion.json +17 -0
- package/dist/fallbacks/functional/motion/motion.json +1 -0
- package/dist/figma/dimension/dimension.json +492 -492
- package/dist/figma/figma.json +21 -13
- 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 +3532 -652
- package/dist/figma/scales/light.json +3367 -487
- package/dist/figma/shadows/dark-colorblind.json +199 -199
- package/dist/figma/shadows/dark-dimmed.json +199 -199
- package/dist/figma/shadows/dark-high-contrast.json +199 -199
- package/dist/figma/shadows/dark-tritanopia.json +199 -199
- package/dist/figma/shadows/dark.json +199 -199
- package/dist/figma/shadows/light-colorblind.json +189 -189
- package/dist/figma/shadows/light-high-contrast.json +191 -191
- package/dist/figma/shadows/light-tritanopia.json +189 -189
- package/dist/figma/shadows/light.json +189 -189
- package/dist/figma/themes/dark-colorblind.json +4470 -5204
- package/dist/figma/themes/dark-dimmed.json +4771 -5081
- package/dist/figma/themes/dark-high-contrast.json +4189 -6548
- package/dist/figma/themes/dark-tritanopia.json +4629 -5153
- package/dist/figma/themes/dark.json +5072 -4916
- package/dist/figma/themes/light-colorblind.json +4490 -5127
- package/dist/figma/themes/light-high-contrast.json +4170 -6201
- package/dist/figma/themes/light-tritanopia.json +4525 -5027
- package/dist/figma/themes/light.json +4982 -4825
- package/dist/figma/typography/typography.json +159 -203
- package/dist/internalCss/dark-colorblind.css +58 -38
- package/dist/internalCss/dark-dimmed.css +44 -24
- package/dist/internalCss/dark-high-contrast.css +62 -42
- 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 +58 -38
- 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/base/size/size.json +38 -38
- package/dist/styleLint/base/typography/typography.json +8 -8
- package/dist/styleLint/functional/motion/motion.json +27 -12
- package/dist/styleLint/functional/size/border.json +30 -30
- package/dist/styleLint/functional/size/breakpoints.json +12 -12
- package/dist/styleLint/functional/size/size-coarse.json +6 -6
- package/dist/styleLint/functional/size/size-fine.json +6 -6
- package/dist/styleLint/functional/size/size.json +132 -132
- package/dist/styleLint/functional/size/viewport.json +12 -12
- package/dist/styleLint/functional/themes/dark-colorblind.json +1442 -3082
- package/dist/styleLint/functional/themes/dark-dimmed.json +1486 -2768
- package/dist/styleLint/functional/themes/dark-high-contrast.json +1517 -4645
- package/dist/styleLint/functional/themes/dark-tritanopia.json +1480 -2926
- package/dist/styleLint/functional/themes/dark.json +1474 -2334
- package/dist/styleLint/functional/themes/light-colorblind.json +1428 -3028
- package/dist/styleLint/functional/themes/light-high-contrast.json +1524 -4364
- package/dist/styleLint/functional/themes/light-tritanopia.json +1416 -2900
- package/dist/styleLint/functional/themes/light.json +1454 -2320
- package/dist/styleLint/functional/typography/typography.json +114 -114
- package/package.json +33 -32
- 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 +44 -31
- package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +62 -30
- package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +53 -12
- 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 +81 -81
- 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 +62 -34
- package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +63 -11
- package/src/tokens/functional/color/light/patterns-light.json5 +126 -276
- package/src/tokens/functional/color/light/primitives-light.json5 +2 -80
- 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
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const filters_1 = require("../filters");
|
|
6
|
-
const getTokenValue_1 = require("./utilities/getTokenValue");
|
|
7
|
-
const alpha_1 = require("./utilities/alpha");
|
|
1
|
+
import { toHex } from 'color2k';
|
|
2
|
+
import { isColor } from '../filters/index.js';
|
|
3
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
4
|
+
import { alpha } from './utilities/alpha.js';
|
|
8
5
|
/**
|
|
9
6
|
* @description converts color tokens value to `hex6` or `hex8`
|
|
10
7
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
11
8
|
* @matcher matches all tokens of $type `color`
|
|
12
9
|
* @transformer returns a `hex` string
|
|
13
10
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export const colorToHex = {
|
|
12
|
+
name: 'color/hex',
|
|
13
|
+
type: 'value',
|
|
16
14
|
transitive: true,
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
filter: isColor,
|
|
16
|
+
transform: (token) => {
|
|
19
17
|
var _a, _b;
|
|
20
18
|
const alphaValue = (_a = token.alpha) !== null && _a !== void 0 ? _a : (_b = token.$extensions) === null || _b === void 0 ? void 0 : _b.alpha;
|
|
21
19
|
if (alphaValue === null || alphaValue === undefined) {
|
|
22
|
-
return
|
|
20
|
+
return toHex(getTokenValue(token));
|
|
23
21
|
}
|
|
24
|
-
return
|
|
22
|
+
return toHex(alpha(getTokenValue(token), alphaValue, token));
|
|
25
23
|
},
|
|
26
24
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description replaces tokens value with `hex8` color using the tokens `alpha` property to specify the value used for alpha
|
|
4
4
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher matches all tokens of $type `color` with an `alpha` property
|
|
6
6
|
* @transformer returns `hex8` string
|
|
7
7
|
*/
|
|
8
|
-
export declare const colorToHexMix:
|
|
8
|
+
export declare const colorToHexMix: Transform;
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.colorToHexMix = void 0;
|
|
7
|
-
const color2k_1 = require("color2k");
|
|
8
|
-
const filters_1 = require("../filters");
|
|
9
|
-
const getTokenValue_1 = require("./utilities/getTokenValue");
|
|
10
|
-
const mix_1 = __importDefault(require("./utilities/mix"));
|
|
1
|
+
import { toHex } from 'color2k';
|
|
2
|
+
import { isColorWithMix } from '../filters/index.js';
|
|
3
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
4
|
+
import mix from './utilities/mix.js';
|
|
11
5
|
/**
|
|
12
6
|
* @description replaces tokens value with `hex8` color using the tokens `alpha` property to specify the value used for alpha
|
|
13
7
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
14
8
|
* @matcher matches all tokens of $type `color` with an `alpha` property
|
|
15
9
|
* @transformer returns `hex8` string
|
|
16
10
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export const colorToHexMix = {
|
|
12
|
+
name: 'color/hexMix',
|
|
13
|
+
type: 'value',
|
|
19
14
|
transitive: true,
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
filter: isColorWithMix,
|
|
16
|
+
transform: (token) => {
|
|
22
17
|
var _a, _b;
|
|
23
|
-
return
|
|
18
|
+
return toHex(mix(getTokenValue(token), ((_a = token.mix) === null || _a === void 0 ? void 0 : _a.color) || getTokenValue(token), ((_b = token.mix) === null || _b === void 0 ? void 0 : _b.weight) || 0));
|
|
24
19
|
},
|
|
25
20
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description replaces tokens value with `rgba` color using the tokens `alpha` property to specify the value used for alpha
|
|
4
4
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher matches all tokens of $type `color` with an `alpha` property
|
|
6
6
|
* @transformer returns `rgba` string
|
|
7
7
|
*/
|
|
8
|
-
export declare const colorToRgbAlpha:
|
|
8
|
+
export declare const colorToRgbAlpha: Transform;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const filters_1 = require("../filters");
|
|
5
|
-
const alpha_1 = require("./utilities/alpha");
|
|
6
|
-
const getTokenValue_1 = require("./utilities/getTokenValue");
|
|
1
|
+
import { isColorWithAlpha } from '../filters/index.js';
|
|
2
|
+
import { alpha } from './utilities/alpha.js';
|
|
3
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
7
4
|
/**
|
|
8
5
|
* @description replaces tokens value with `rgba` color using the tokens `alpha` property to specify the value used for alpha
|
|
9
6
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
10
7
|
* @matcher matches all tokens of $type `color` with an `alpha` property
|
|
11
8
|
* @transformer returns `rgba` string
|
|
12
9
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export const colorToRgbAlpha = {
|
|
11
|
+
name: 'color/rgbAlpha',
|
|
12
|
+
type: 'value',
|
|
15
13
|
transitive: true,
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
filter: isColorWithAlpha,
|
|
15
|
+
transform: (token) => {
|
|
18
16
|
if (token.alpha === null)
|
|
19
|
-
return
|
|
20
|
-
return
|
|
17
|
+
return getTokenValue(token);
|
|
18
|
+
return alpha(getTokenValue(token), token.alpha, token);
|
|
21
19
|
},
|
|
22
20
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts color tokens rgba float with values from 0 - 1
|
|
4
4
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher matches all tokens of $type `color`
|
|
6
6
|
* @transformer returns a `rgb` float object
|
|
7
7
|
*/
|
|
8
|
-
export declare const colorToRgbaFloat:
|
|
8
|
+
export declare const colorToRgbaFloat: Transform;
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const getTokenValue_1 = require("./utilities/getTokenValue");
|
|
10
|
-
const rgbaFloatToHex_1 = require("./utilities/rgbaFloatToHex");
|
|
11
|
-
const mix_1 = __importDefault(require("./utilities/mix"));
|
|
12
|
-
const hexToRgbaFloat_1 = require("./utilities/hexToRgbaFloat");
|
|
13
|
-
const isRgbaFloat_1 = require("./utilities/isRgbaFloat");
|
|
14
|
-
const toRgbaFloat = (token, alpha) => {
|
|
1
|
+
import { toHex } from 'color2k';
|
|
2
|
+
import { isColor } from '../filters/index.js';
|
|
3
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
4
|
+
import { rgbaFloatToHex } from './utilities/rgbaFloatToHex.js';
|
|
5
|
+
import mix from './utilities/mix.js';
|
|
6
|
+
import { hexToRgbaFloat } from './utilities/hexToRgbaFloat.js';
|
|
7
|
+
import { isRgbaFloat } from './utilities/isRgbaFloat.js';
|
|
8
|
+
const toRgbaFloat = (token, alpha = undefined) => {
|
|
15
9
|
var _a;
|
|
16
|
-
let tokenValue =
|
|
10
|
+
let tokenValue = getTokenValue(token);
|
|
17
11
|
let tokenMixColor = (_a = token.mix) === null || _a === void 0 ? void 0 : _a.color;
|
|
18
12
|
// get hex value from color string
|
|
19
|
-
if (
|
|
20
|
-
tokenValue =
|
|
13
|
+
if (isRgbaFloat(tokenValue)) {
|
|
14
|
+
tokenValue = rgbaFloatToHex(tokenValue, false);
|
|
21
15
|
}
|
|
22
|
-
if (tokenMixColor &&
|
|
23
|
-
tokenMixColor =
|
|
16
|
+
if (tokenMixColor && isRgbaFloat(tokenMixColor)) {
|
|
17
|
+
tokenMixColor = rgbaFloatToHex(tokenMixColor, false);
|
|
24
18
|
}
|
|
25
|
-
let hex =
|
|
19
|
+
let hex = toHex(tokenValue);
|
|
26
20
|
// mix color with mix color and weight
|
|
27
21
|
if (token.mix && token.mix.color && token.mix.weight) {
|
|
28
|
-
hex =
|
|
22
|
+
hex = toHex(mix(tokenValue, tokenMixColor, token.mix.weight));
|
|
29
23
|
}
|
|
30
24
|
// return color as RgbaFloat
|
|
31
|
-
return
|
|
25
|
+
return hexToRgbaFloat(hex, alpha);
|
|
32
26
|
};
|
|
33
27
|
/**
|
|
34
28
|
* @description converts color tokens rgba float with values from 0 - 1
|
|
@@ -36,14 +30,16 @@ const toRgbaFloat = (token, alpha) => {
|
|
|
36
30
|
* @matcher matches all tokens of $type `color`
|
|
37
31
|
* @transformer returns a `rgb` float object
|
|
38
32
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
export const colorToRgbaFloat = {
|
|
34
|
+
name: 'color/rgbaFloat',
|
|
35
|
+
type: 'value',
|
|
41
36
|
transitive: true,
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
filter: isColor,
|
|
38
|
+
transform: (token) => {
|
|
39
|
+
const value = getTokenValue(token);
|
|
44
40
|
// skip if value is already rgb float
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
41
|
+
if (isRgbaFloat(value) && !('mix' in token) && !('alpha' in token))
|
|
42
|
+
return value;
|
|
47
43
|
// convert hex or rgb values to rgba float
|
|
48
44
|
return toRgbaFloat(token, token.alpha);
|
|
49
45
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts cubicBezeir tokens array value to a css cubic-bezier
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `duration`
|
|
6
|
+
* @transformer returns a css cubic-bezier function
|
|
7
|
+
*/
|
|
8
|
+
export declare const cubicBezierToCss: Transform;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isCubicBezier } from '../filters/isCubicBezier.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts cubicBezeir tokens array value to a css cubic-bezier
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `duration`
|
|
6
|
+
* @transformer returns a css cubic-bezier function
|
|
7
|
+
*/
|
|
8
|
+
export const cubicBezierToCss = {
|
|
9
|
+
name: 'cubicBezeir/css',
|
|
10
|
+
type: 'value',
|
|
11
|
+
transitive: true,
|
|
12
|
+
filter: isCubicBezier,
|
|
13
|
+
transform: (token, _config) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const value = (_a = token.$value) !== null && _a !== void 0 ? _a : token.value;
|
|
16
|
+
// throw value of more or less than 4 items in array
|
|
17
|
+
if (value.length !== 4 || value.some((item) => typeof item !== 'number')) {
|
|
18
|
+
throw new Error(`Invalid cubicBezier token ${token.path.join('.')}, must be an array with 4 numbers, but got this instead: ${JSON.stringify(value)}`);
|
|
19
|
+
}
|
|
20
|
+
// return value
|
|
21
|
+
return `cubic-bezier(${value.join(',')})`;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts dimension tokens value to pixel value without unit, ignores `em` as they are relative to the font size of the parent element
|
|
4
4
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher matches all tokens of $type `dimension`
|
|
6
6
|
* @transformer returns a float number
|
|
7
7
|
*/
|
|
8
|
-
export declare const dimensionToPixelUnitless:
|
|
8
|
+
export declare const dimensionToPixelUnitless: Transform;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dimensionToPixelUnitless = void 0;
|
|
4
|
-
const filters_1 = require("../filters");
|
|
1
|
+
import { isDimension } from '../filters/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* @description base font size from options or 16
|
|
7
4
|
* @param options
|
|
@@ -26,25 +23,27 @@ const hasUnit = (value, unit) => {
|
|
|
26
23
|
* @matcher matches all tokens of $type `dimension`
|
|
27
24
|
* @transformer returns a float number
|
|
28
25
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
export const dimensionToPixelUnitless = {
|
|
27
|
+
name: 'dimension/pixelUnitless',
|
|
28
|
+
type: 'value',
|
|
31
29
|
transitive: true,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
30
|
+
filter: isDimension,
|
|
31
|
+
transform: (token, config, options) => {
|
|
32
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
33
|
+
const baseFont = getBasePxFontSize(config);
|
|
34
|
+
const floatVal = parseFloat(token[valueProp]);
|
|
36
35
|
if (isNaN(floatVal)) {
|
|
37
|
-
throw new Error(`Invalid dimension token: '${token.
|
|
36
|
+
throw new Error(`Invalid dimension token: '${token.path.join('.')}: ${token[valueProp]}' is not valid and cannot be transform to 'float' \n`);
|
|
38
37
|
}
|
|
39
38
|
if (floatVal === 0) {
|
|
40
39
|
return 0;
|
|
41
40
|
}
|
|
42
|
-
if (hasUnit(token
|
|
41
|
+
if (hasUnit(token[valueProp], 'rem')) {
|
|
43
42
|
return floatVal * baseFont;
|
|
44
43
|
}
|
|
45
|
-
if (hasUnit(token
|
|
44
|
+
if (hasUnit(token[valueProp], 'px')) {
|
|
46
45
|
return floatVal;
|
|
47
46
|
}
|
|
48
|
-
return token
|
|
47
|
+
return token[valueProp];
|
|
49
48
|
},
|
|
50
49
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
|
|
4
4
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher matches all tokens of $type `dimension`
|
|
6
6
|
* @transformer returns a `rem` string
|
|
7
7
|
*/
|
|
8
|
-
export declare const dimensionToRem:
|
|
8
|
+
export declare const dimensionToRem: Transform;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dimensionToRem = void 0;
|
|
4
|
-
const filters_1 = require("../filters");
|
|
1
|
+
import { isDimension } from '../filters/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* @description base font size from options or 16
|
|
7
4
|
* @param options
|
|
@@ -26,21 +23,23 @@ const hasUnit = (value, unit) => {
|
|
|
26
23
|
* @matcher matches all tokens of $type `dimension`
|
|
27
24
|
* @transformer returns a `rem` string
|
|
28
25
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
export const dimensionToRem = {
|
|
27
|
+
name: 'dimension/rem',
|
|
28
|
+
type: 'value',
|
|
31
29
|
transitive: true,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
30
|
+
filter: isDimension,
|
|
31
|
+
transform: (token, config, options) => {
|
|
32
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
33
|
+
const baseFont = getBasePxFontSize(config);
|
|
34
|
+
const floatVal = parseFloat(token[valueProp]);
|
|
36
35
|
if (isNaN(floatVal)) {
|
|
37
|
-
throw new Error(`Invalid dimension token: '${token.name}: ${token
|
|
36
|
+
throw new Error(`Invalid dimension token: '${token.name}: ${token[valueProp]}' is not valid and cannot be transform to 'rem' \n`);
|
|
38
37
|
}
|
|
39
38
|
if (floatVal === 0) {
|
|
40
39
|
return '0';
|
|
41
40
|
}
|
|
42
|
-
if (hasUnit(token
|
|
43
|
-
return token
|
|
41
|
+
if (hasUnit(token[valueProp], 'rem') || hasUnit(token[valueProp], 'em')) {
|
|
42
|
+
return token[valueProp];
|
|
44
43
|
}
|
|
45
44
|
return `${floatVal / baseFont}rem`;
|
|
46
45
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
|
|
4
4
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher matches all tokens of $type `dimension`
|
|
6
6
|
* @transformer returns an array with the `rem` and `pixel` string
|
|
7
7
|
*/
|
|
8
|
-
export declare const dimensionToRemPxArray:
|
|
8
|
+
export declare const dimensionToRemPxArray: Transform;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dimensionToRemPxArray = void 0;
|
|
4
|
-
const filters_1 = require("../filters");
|
|
1
|
+
import { isDimension } from '../filters/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* @description base font size from options or 16
|
|
7
4
|
* @param options
|
|
@@ -26,20 +23,22 @@ const hasUnit = (value, unit) => {
|
|
|
26
23
|
* @matcher matches all tokens of $type `dimension`
|
|
27
24
|
* @transformer returns an array with the `rem` and `pixel` string
|
|
28
25
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
export const dimensionToRemPxArray = {
|
|
27
|
+
name: 'dimension/remPxArray',
|
|
28
|
+
type: 'value',
|
|
31
29
|
transitive: true,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
30
|
+
filter: isDimension,
|
|
31
|
+
transform: (token, config, options) => {
|
|
32
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
33
|
+
const baseFont = getBasePxFontSize(config);
|
|
34
|
+
const floatVal = parseFloat(token[valueProp]);
|
|
36
35
|
if (isNaN(floatVal)) {
|
|
37
|
-
throw new Error(`Invalid dimension token: '${token.name}: ${token
|
|
36
|
+
throw new Error(`Invalid dimension token: '${token.name}: ${token[valueProp]}' is not valid and cannot be transform to 'rem' \n`);
|
|
38
37
|
}
|
|
39
38
|
if (floatVal === 0) {
|
|
40
39
|
return ['0', '0'];
|
|
41
40
|
}
|
|
42
|
-
if (hasUnit(token
|
|
41
|
+
if (hasUnit(token[valueProp], 'rem') || hasUnit(token[valueProp], 'em')) {
|
|
43
42
|
return [token.value, `${floatVal * baseFont}px`];
|
|
44
43
|
}
|
|
45
44
|
return [`${floatVal / baseFont}rem`, `${floatVal}px`];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts duration tokens string value to number with `ms` unit
|
|
4
4
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher matches all tokens of $type `duration`
|
|
6
6
|
* @transformer returns a css duration
|
|
7
7
|
*/
|
|
8
|
-
export declare const durationToCss:
|
|
8
|
+
export declare const durationToCss: Transform;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.durationToCss = void 0;
|
|
4
|
-
const isDuration_1 = require("../filters/isDuration");
|
|
1
|
+
import { isDuration } from '../filters/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* @description converts duration tokens string value to number with `ms` unit
|
|
7
4
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
8
5
|
* @matcher matches all tokens of $type `duration`
|
|
9
6
|
* @transformer returns a css duration
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export const durationToCss = {
|
|
9
|
+
name: 'duration/css',
|
|
10
|
+
type: 'value',
|
|
13
11
|
transitive: true,
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
filter: isDuration,
|
|
13
|
+
transform: (token, _config, options) => {
|
|
14
|
+
const valueProp = options.usesDtcg ? '$value' : 'value';
|
|
16
15
|
// throw an error if token value is not a string or does not end with `ms`
|
|
17
|
-
if (typeof token
|
|
18
|
-
throw new Error(`duration token value must be a string with an "ms" unit`);
|
|
16
|
+
if (typeof token[valueProp] !== `string` || !(token[valueProp].endsWith(`ms`) || token[valueProp].endsWith(`s`))) {
|
|
17
|
+
throw new Error(`duration token value must be a string with an "ms" || "s" unit, invalid token: ${token.name} with value: ${token[valueProp]}`);
|
|
19
18
|
}
|
|
20
19
|
// get value
|
|
21
|
-
let value = parseInt(token.
|
|
20
|
+
let value = parseInt(token[valueProp].replace('ms', ''));
|
|
22
21
|
let unit = `ms`;
|
|
23
22
|
if (value >= 1000) {
|
|
24
23
|
value = value / 1000;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description retrieves figma attributes from token and adds them to attributes
|
|
4
4
|
* @type attribute transformer — [StyleDictionary.AttributeTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher matches all tokens
|
|
6
6
|
* @transformer returns ab object of figma attributes
|
|
7
7
|
*/
|
|
8
|
-
export declare const figmaAttributes:
|
|
8
|
+
export declare const figmaAttributes: Transform;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.figmaAttributes = void 0;
|
|
4
1
|
const figmaScopes = {
|
|
5
2
|
all: ['ALL_SCOPES'],
|
|
6
3
|
radius: ['CORNER_RADIUS'],
|
|
@@ -41,13 +38,14 @@ const getScopes = (scopes) => {
|
|
|
41
38
|
* @matcher matches all tokens
|
|
42
39
|
* @transformer returns ab object of figma attributes
|
|
43
40
|
*/
|
|
44
|
-
|
|
41
|
+
export const figmaAttributes = {
|
|
42
|
+
name: 'figma/attributes',
|
|
45
43
|
type: `attribute`,
|
|
46
|
-
|
|
44
|
+
transform: (token, platform = {}) => {
|
|
47
45
|
var _a, _b;
|
|
48
|
-
const {
|
|
46
|
+
const { modeOverride, collection, scopes, group, codeSyntax } = ((_a = token.$extensions) === null || _a === void 0 ? void 0 : _a['org.primer.figma']) || {};
|
|
49
47
|
return {
|
|
50
|
-
mode: ((_b = platform.options) === null || _b === void 0 ? void 0 : _b.mode) ||
|
|
48
|
+
mode: modeOverride || ((_b = platform.options) === null || _b === void 0 ? void 0 : _b.mode) || 'default',
|
|
51
49
|
collection,
|
|
52
50
|
group: group || collection,
|
|
53
51
|
scopes: getScopes(scopes),
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform, TransformedToken } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* takes a value and returns it if its a px string if it is a float and the token has a fontSize value in extensions['org.primer.data']
|
|
4
4
|
* @param value
|
|
5
5
|
* @returns string
|
|
6
6
|
*/
|
|
7
|
-
export declare const convertFloatToPixel: (token:
|
|
7
|
+
export declare const convertFloatToPixel: (token: TransformedToken, unitless?: boolean) => any;
|
|
8
8
|
/**
|
|
9
9
|
* @description converts a float value to a pixel value based on the provided fontSize on the tokersn extension
|
|
10
10
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
11
11
|
* @matcher matches all tokens of $type `isNumber`
|
|
12
12
|
* @transformer returns a pixel string
|
|
13
13
|
*/
|
|
14
|
-
export declare const floatToPixel:
|
|
15
|
-
export declare const floatToPixelUnitless:
|
|
14
|
+
export declare const floatToPixel: Transform;
|
|
15
|
+
export declare const floatToPixelUnitless: Transform;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.floatToPixelUnitless = exports.floatToPixel = exports.convertFloatToPixel = void 0;
|
|
4
|
-
const filters_1 = require("../filters");
|
|
1
|
+
import { isNumber } from '../filters/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* takes a value and returns it if its a px string if it is a float and the token has a fontSize value in extensions['org.primer.data']
|
|
7
4
|
* @param value
|
|
8
5
|
* @returns string
|
|
9
6
|
*/
|
|
10
|
-
const convertFloatToPixel = (token, unitless = false) => {
|
|
7
|
+
export const convertFloatToPixel = (token, unitless = false) => {
|
|
11
8
|
var _a, _b, _c, _d, _e, _f;
|
|
12
9
|
// short circut if value is not a number
|
|
13
10
|
if (typeof token.value !== 'number' ||
|
|
@@ -20,22 +17,23 @@ const convertFloatToPixel = (token, unitless = false) => {
|
|
|
20
17
|
// return converted value
|
|
21
18
|
return convertedValue === 0 ? 0 : unitless ? Math.round(convertedValue) : `${Math.round(convertedValue)}px`;
|
|
22
19
|
};
|
|
23
|
-
exports.convertFloatToPixel = convertFloatToPixel;
|
|
24
20
|
/**
|
|
25
21
|
* @description converts a float value to a pixel value based on the provided fontSize on the tokersn extension
|
|
26
22
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
27
23
|
* @matcher matches all tokens of $type `isNumber`
|
|
28
24
|
* @transformer returns a pixel string
|
|
29
25
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
export const floatToPixel = {
|
|
27
|
+
name: 'float/pixel',
|
|
28
|
+
type: 'value',
|
|
32
29
|
transitive: true,
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
filter: isNumber,
|
|
31
|
+
transform: (token) => convertFloatToPixel(token),
|
|
35
32
|
};
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
export const floatToPixelUnitless = {
|
|
34
|
+
name: 'float/pixelUnitless',
|
|
35
|
+
type: 'value',
|
|
38
36
|
transitive: true,
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
filter: isNumber,
|
|
38
|
+
transform: (token) => convertFloatToPixel(token, true),
|
|
41
39
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
|
|
4
4
|
* @param value
|
|
@@ -11,4 +11,4 @@ export declare const parseFontFamily: (value: unknown) => string;
|
|
|
11
11
|
* @matcher matches all tokens of $type `fontFamily`
|
|
12
12
|
* @transformer returns a string
|
|
13
13
|
*/
|
|
14
|
-
export declare const fontFamilyToCss:
|
|
14
|
+
export declare const fontFamilyToCss: Transform;
|