@primer/primitives 9.1.2 → 10.0.0-rc.29e661a3
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 +1 -2
- package/dist/build/PrimerStyleDictionary.js +51 -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/isDeprecated.d.ts +3 -3
- package/dist/build/filters/isDeprecated.js +2 -6
- 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 +48 -44
- 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 +5 -7
- package/dist/build/platforms/css.d.ts +1 -1
- package/dist/build/platforms/css.js +19 -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 +2 -2
- package/dist/build/schemas/baseToken.js +4 -7
- package/dist/build/schemas/borderToken.d.ts +5 -5
- 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 +20 -15
- package/dist/build/schemas/colorToken.js +24 -24
- package/dist/build/schemas/designToken.js +28 -31
- package/dist/build/schemas/dimensionToken.d.ts +5 -5
- package/dist/build/schemas/dimensionToken.js +14 -17
- package/dist/build/schemas/dimensionValue.js +7 -10
- package/dist/build/schemas/durationToken.d.ts +5 -5
- package/dist/build/schemas/durationToken.js +8 -11
- package/dist/build/schemas/durationValue.js +4 -7
- package/dist/build/schemas/fontFamilyToken.d.ts +5 -5
- package/dist/build/schemas/fontFamilyToken.js +13 -16
- package/dist/build/schemas/fontWeightToken.d.ts +5 -5
- package/dist/build/schemas/fontWeightToken.js +14 -17
- package/dist/build/schemas/fontWeightValue.js +4 -7
- package/dist/build/schemas/numberToken.d.ts +5 -5
- 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 +5 -5
- package/dist/build/schemas/shadowToken.js +23 -26
- package/dist/build/schemas/stringToken.d.ts +5 -5
- 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 +5 -5
- package/dist/build/schemas/typographyToken.js +14 -17
- package/dist/build/schemas/validTokenType.js +9 -13
- package/dist/build/schemas/viewportRangeToken.d.ts +5 -5
- 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/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 +9 -10
- package/dist/build/transformers/figmaAttributes.d.ts +2 -2
- package/dist/build/transformers/figmaAttributes.js +3 -5
- 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 +24 -24
- package/dist/build/transformers/index.js +24 -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/functional/themes/dark-colorblind.css +4 -4
- package/dist/css/functional/themes/dark-high-contrast.css +20 -20
- package/dist/css/functional/themes/light-high-contrast.css +14 -14
- package/dist/css/functional/typography/typography.css +20 -20
- package/dist/css/primitives.css +20 -20
- 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 +18 -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 +2310 -3186
- package/dist/docs/functional/themes/dark-dimmed.json +2300 -2794
- package/dist/docs/functional/themes/dark-high-contrast.json +2520 -5038
- package/dist/docs/functional/themes/dark-tritanopia.json +2351 -3003
- package/dist/docs/functional/themes/dark.json +2270 -2270
- package/dist/docs/functional/themes/light-colorblind.json +2298 -3124
- package/dist/docs/functional/themes/light-high-contrast.json +2419 -4645
- package/dist/docs/functional/themes/light-tritanopia.json +2330 -2990
- package/dist/docs/functional/themes/light.json +2260 -2260
- package/dist/docs/functional/typography/typography.json +206 -206
- package/dist/figma/dimension/dimension.json +489 -489
- package/dist/figma/figma.json +11 -3
- package/dist/figma/scales/dark-dimmed.json +38 -38
- package/dist/figma/scales/dark-high-constrast.json +38 -38
- package/dist/figma/scales/dark.json +35 -35
- package/dist/figma/scales/light-high-constrast.json +40 -40
- package/dist/figma/scales/light.json +40 -40
- package/dist/figma/shadows/dark-colorblind.json +280 -280
- package/dist/figma/shadows/dark-dimmed.json +280 -280
- package/dist/figma/shadows/dark-high-contrast.json +280 -280
- package/dist/figma/shadows/dark-tritanopia.json +280 -280
- package/dist/figma/shadows/dark.json +280 -280
- package/dist/figma/shadows/light-colorblind.json +281 -281
- package/dist/figma/shadows/light-high-contrast.json +281 -281
- package/dist/figma/shadows/light-tritanopia.json +281 -281
- package/dist/figma/shadows/light.json +281 -281
- package/dist/figma/themes/dark-colorblind.json +4991 -5854
- package/dist/figma/themes/dark-dimmed.json +5314 -5799
- package/dist/figma/themes/dark-high-contrast.json +4210 -6679
- package/dist/figma/themes/dark-tritanopia.json +5165 -5817
- package/dist/figma/themes/dark.json +5534 -5537
- package/dist/figma/themes/light-colorblind.json +4857 -5669
- package/dist/figma/themes/light-high-contrast.json +4198 -6372
- package/dist/figma/themes/light-tritanopia.json +4901 -5529
- package/dist/figma/themes/light.json +5349 -5349
- package/dist/figma/typography/typography.json +112 -156
- package/dist/internalCss/dark-colorblind.css +4 -4
- package/dist/internalCss/dark-high-contrast.css +20 -20
- package/dist/internalCss/light-high-contrast.css +14 -14
- 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 +12 -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 +1171 -2047
- package/dist/styleLint/functional/themes/dark-dimmed.json +1160 -1654
- package/dist/styleLint/functional/themes/dark-high-contrast.json +1307 -3825
- package/dist/styleLint/functional/themes/dark-tritanopia.json +1232 -1884
- package/dist/styleLint/functional/themes/dark.json +1140 -1140
- package/dist/styleLint/functional/themes/light-colorblind.json +1198 -2024
- package/dist/styleLint/functional/themes/light-high-contrast.json +1270 -3496
- package/dist/styleLint/functional/themes/light-tritanopia.json +1205 -1865
- package/dist/styleLint/functional/themes/light.json +1130 -1130
- package/dist/styleLint/functional/typography/typography.json +114 -114
- package/package.json +19 -10
- package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +4 -4
- package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +6 -0
- package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +21 -3
- package/src/tokens/functional/color/dark/primitives-dark.json5 +3 -3
- package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +4 -1
- package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +4 -1
- package/src/tokens/functional/color/light/primitives-light.json5 +2 -2
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.namePathToDotNotation = void 0;
|
|
4
|
-
const utilities_1 = require("../utilities");
|
|
1
|
+
import { upperCaseFirstCharacter } from '../utilities/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* camelCase
|
|
7
4
|
* @scope custom camelCase implementation should only be used within `name path to dot notation` transformer
|
|
@@ -12,7 +9,7 @@ const utilities_1 = require("../utilities");
|
|
|
12
9
|
const camelCase = (string) => {
|
|
13
10
|
return string
|
|
14
11
|
.split(/[\s-_+]+/g)
|
|
15
|
-
.map((stringPart, index) => (index === 0 ? stringPart :
|
|
12
|
+
.map((stringPart, index) => (index === 0 ? stringPart : upperCaseFirstCharacter(stringPart)))
|
|
16
13
|
.join('');
|
|
17
14
|
};
|
|
18
15
|
/**
|
|
@@ -21,9 +18,10 @@ const camelCase = (string) => {
|
|
|
21
18
|
* @matcher omitted to match all tokens
|
|
22
19
|
* @transformer returns `string` in dot.notation
|
|
23
20
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
export const namePathToDotNotation = {
|
|
22
|
+
name: 'name/pathToDotNotation',
|
|
23
|
+
type: 'name',
|
|
24
|
+
transform: (token, options) => {
|
|
27
25
|
return ([options === null || options === void 0 ? void 0 : options.prefix, ...token.path]
|
|
28
26
|
// remove undefined if exists
|
|
29
27
|
.filter((part) => typeof part === 'string' && part !== '@')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const transformNamePathToFigma: (token:
|
|
1
|
+
import type { PlatformConfig, Transform, TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
export declare const transformNamePathToFigma: (token: TransformedToken, options?: PlatformConfig) => string;
|
|
3
3
|
/**
|
|
4
4
|
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a specific figma name
|
|
5
5
|
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
6
6
|
* @matcher omitted to match all tokens
|
|
7
7
|
* @transformer returns `string`
|
|
8
8
|
*/
|
|
9
|
-
export declare const namePathToFigma:
|
|
9
|
+
export declare const namePathToFigma: Transform;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.namePathToFigma = exports.transformNamePathToFigma = void 0;
|
|
4
|
-
const transformNamePathToFigma = (token, options) => {
|
|
1
|
+
export const transformNamePathToFigma = (token, options) => {
|
|
5
2
|
let pathArray = token.path.filter((part) => part !== '@');
|
|
6
3
|
if (['fgColor', 'borderColor', 'bgColor'].includes(pathArray[0]) && pathArray.length === 3) {
|
|
7
4
|
pathArray = [pathArray[0], `${pathArray[1]}-${pathArray[2]}`];
|
|
@@ -11,14 +8,14 @@ const transformNamePathToFigma = (token, options) => {
|
|
|
11
8
|
.filter((part) => typeof part === 'string' && part !== '@')
|
|
12
9
|
.join('/'));
|
|
13
10
|
};
|
|
14
|
-
exports.transformNamePathToFigma = transformNamePathToFigma;
|
|
15
11
|
/**
|
|
16
12
|
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a specific figma name
|
|
17
13
|
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
18
14
|
* @matcher omitted to match all tokens
|
|
19
15
|
* @transformer returns `string`
|
|
20
16
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
export const namePathToFigma = {
|
|
18
|
+
name: 'name/pathToFigma',
|
|
19
|
+
type: 'name',
|
|
20
|
+
transform: transformNamePathToFigma,
|
|
24
21
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a kebab-case string, preserves casing of parts
|
|
4
4
|
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher omitted to match all tokens
|
|
6
6
|
* @transformer returns `string` kebab-case
|
|
7
7
|
*/
|
|
8
|
-
export declare const namePathToKebabCase:
|
|
8
|
+
export declare const namePathToKebabCase: Transform;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.namePathToKebabCase = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a kebab-case string, preserves casing of parts
|
|
6
3
|
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
7
4
|
* @matcher omitted to match all tokens
|
|
8
5
|
* @transformer returns `string` kebab-case
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export const namePathToKebabCase = {
|
|
8
|
+
name: 'name/pathToKebabCase',
|
|
9
|
+
type: 'name',
|
|
10
|
+
transform: (token, options) => {
|
|
13
11
|
return ([options === null || options === void 0 ? void 0 : options.prefix, ...token.path]
|
|
14
12
|
// remove undefined if exists
|
|
15
13
|
.filter((part) => typeof part === 'string' && part !== '@')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a PascalCase string, preserves casing of parts
|
|
4
4
|
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher omitted to match all tokens
|
|
6
6
|
* @transformer returns `string` PascalCase
|
|
7
7
|
*/
|
|
8
|
-
export declare const namePathToPascalCase:
|
|
8
|
+
export declare const namePathToPascalCase: Transform;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.namePathToPascalCase = void 0;
|
|
4
|
-
const toPascalCase_1 = require("../utilities/toPascalCase");
|
|
1
|
+
import { toPascalCase } from '../utilities/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a PascalCase string, preserves casing of parts
|
|
7
4
|
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
8
5
|
* @matcher omitted to match all tokens
|
|
9
6
|
* @transformer returns `string` PascalCase
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export const namePathToPascalCase = {
|
|
9
|
+
name: 'name/pathToPascalCase',
|
|
10
|
+
type: 'name',
|
|
11
|
+
transform: (token, options) => toPascalCase([(options === null || options === void 0 ? void 0 : options.prefix) || '', ...token.path]),
|
|
14
12
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a slash/notation string
|
|
4
4
|
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
5
|
* @matcher omitted to match all tokens
|
|
6
6
|
* @transformer returns `string` on slash/notation
|
|
7
7
|
*/
|
|
8
|
-
export declare const namePathToSlashNotation:
|
|
8
|
+
export declare const namePathToSlashNotation: Transform;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.namePathToSlashNotation = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a slash/notation string
|
|
6
3
|
* @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
7
4
|
* @matcher omitted to match all tokens
|
|
8
5
|
* @transformer returns `string` on slash/notation
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export const namePathToSlashNotation = {
|
|
8
|
+
name: 'name/pathToSlashNotation',
|
|
9
|
+
type: 'name',
|
|
10
|
+
transform: (token, options) => {
|
|
13
11
|
return ([options === null || options === void 0 ? void 0 : options.prefix, ...token.path]
|
|
14
12
|
// remove undefined if exists
|
|
15
13
|
.filter((part) => typeof part === 'string' && part !== '@')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts w3c shadow tokens in css shadow string
|
|
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 `shadow`
|
|
6
6
|
* @transformer returns css shadow `string`
|
|
7
7
|
*/
|
|
8
|
-
export declare const shadowToCss:
|
|
8
|
+
export declare const shadowToCss: Transform;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const alpha_1 = require("./utilities/alpha");
|
|
7
|
-
const checkRequiredTokenProperties_1 = require("./utilities/checkRequiredTokenProperties");
|
|
8
|
-
const getTokenValue_1 = require("./utilities/getTokenValue");
|
|
1
|
+
import { toHex } from 'color2k';
|
|
2
|
+
import { isShadow } from '../filters/index.js';
|
|
3
|
+
import { alpha } from './utilities/alpha.js';
|
|
4
|
+
import { checkRequiredTokenProperties } from './utilities/checkRequiredTokenProperties.js';
|
|
5
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
9
6
|
/**
|
|
10
7
|
* @description converts w3c shadow tokens in css shadow string
|
|
11
8
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
12
9
|
* @matcher matches all tokens of $type `shadow`
|
|
13
10
|
* @transformer returns css shadow `string`
|
|
14
11
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export const shadowToCss = {
|
|
13
|
+
name: 'shadow/css',
|
|
14
|
+
type: 'value',
|
|
17
15
|
transitive: true,
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
filter: isShadow,
|
|
17
|
+
transform: (token) => {
|
|
20
18
|
// extract value
|
|
21
|
-
const
|
|
19
|
+
const value = getTokenValue(token);
|
|
20
|
+
const valueProp = token.$value ? '$value' : 'value';
|
|
22
21
|
// turn value into array
|
|
23
22
|
const shadowValues = !Array.isArray(value) ? [value] : value;
|
|
24
23
|
return shadowValues
|
|
@@ -26,9 +25,9 @@ exports.shadowToCss = {
|
|
|
26
25
|
// if value === string it was probably already transformed
|
|
27
26
|
if (typeof shadow === 'string')
|
|
28
27
|
return shadow;
|
|
29
|
-
|
|
28
|
+
checkRequiredTokenProperties(shadow, ['color', 'offsetX', 'offsetY', 'blur', 'spread']);
|
|
30
29
|
/*css box shadow: inset? | offset-x | offset-y | blur-radius | spread-radius | color */
|
|
31
|
-
return `${shadow.inset === true ? 'inset ' : ''}${shadow.offsetX} ${shadow.offsetY} ${shadow.blur} ${shadow.spread} ${
|
|
30
|
+
return `${shadow.inset === true ? 'inset ' : ''}${shadow.offsetX} ${shadow.offsetY} ${shadow.blur} ${shadow.spread} ${toHex(alpha(getTokenValue(Object.assign(Object.assign({}, token), { [valueProp]: shadow }), 'color'), shadow.alpha || 1, token))}`;
|
|
32
31
|
})
|
|
33
32
|
.join(', ');
|
|
34
33
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description converts typograhy token value to css font shorthand
|
|
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 `typography`
|
|
6
6
|
* @transformer returns a css font string
|
|
7
7
|
*/
|
|
8
|
-
export declare const typographyToCss:
|
|
8
|
+
export declare const typographyToCss: Transform;
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const fontFamilyToCss_1 = require("./fontFamilyToCss");
|
|
7
|
-
const fontWeightToNumber_1 = require("./fontWeightToNumber");
|
|
8
|
-
const getTokenValue_1 = require("./utilities/getTokenValue");
|
|
1
|
+
import { isTypography } from '../filters/index.js';
|
|
2
|
+
import { checkRequiredTokenProperties } from './utilities/checkRequiredTokenProperties.js';
|
|
3
|
+
import { parseFontFamily } from './fontFamilyToCss.js';
|
|
4
|
+
import { parseFontWeight } from './fontWeightToNumber.js';
|
|
5
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
9
6
|
/**
|
|
10
7
|
* @description converts typograhy token value to css font shorthand
|
|
11
8
|
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
12
9
|
* @matcher matches all tokens of $type `typography`
|
|
13
10
|
* @transformer returns a css font string
|
|
14
11
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export const typographyToCss = {
|
|
13
|
+
name: 'typography/css',
|
|
14
|
+
type: 'value',
|
|
17
15
|
transitive: true,
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
filter: isTypography,
|
|
17
|
+
transform: (token) => {
|
|
20
18
|
// extract value
|
|
21
|
-
const value =
|
|
19
|
+
const value = getTokenValue(token);
|
|
22
20
|
// validate token properties
|
|
23
|
-
|
|
21
|
+
checkRequiredTokenProperties(value, ['fontWeight', 'fontSize', 'fontFamily']);
|
|
24
22
|
// format output
|
|
25
|
-
return `${value.fontStyle || ''} ${
|
|
23
|
+
return `${value.fontStyle || ''} ${parseFontWeight(getTokenValue(token, 'fontWeight'))} ${value.fontSize}${value.lineHeight ? `/${value.lineHeight}` : ''} ${parseFontFamily(getTokenValue(token, 'fontFamily'))}`
|
|
26
24
|
.trim()
|
|
27
25
|
.replace(/\s\s+/g, ' ');
|
|
28
26
|
},
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.alpha = void 0;
|
|
4
|
-
const color2k_1 = require("color2k");
|
|
1
|
+
import { rgba, parseToRgba } from 'color2k';
|
|
5
2
|
/**
|
|
6
3
|
* alpha
|
|
7
4
|
* @description takes a colors string like hex or rgba and returns an rgba color with the specified alpha value
|
|
@@ -9,12 +6,11 @@ const color2k_1 = require("color2k");
|
|
|
9
6
|
* @param desiredAlpha number
|
|
10
7
|
* @returns rgba value
|
|
11
8
|
*/
|
|
12
|
-
const alpha = (color, desiredAlpha, token) => {
|
|
13
|
-
const [r, g, b, a] =
|
|
9
|
+
export const alpha = (color, desiredAlpha, token) => {
|
|
10
|
+
const [r, g, b, a] = parseToRgba(color);
|
|
14
11
|
if (a < 1 && desiredAlpha < 1) {
|
|
15
12
|
// eslint-disable-next-line no-console
|
|
16
13
|
console.warn(`🚨 You are setting an alpha value of "${desiredAlpha}" for a color with an alpha value (${color}). The previous alpha value will be disregarded as if the color would have been 100% opaque.${token !== undefined ? `\n ↳ Token: "${token.name}" in file: "${token.filePath}"` : ''}`);
|
|
17
14
|
}
|
|
18
|
-
return
|
|
15
|
+
return rgba(r, g, b, desiredAlpha);
|
|
19
16
|
};
|
|
20
|
-
exports.alpha = alpha;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkRequiredTokenProperties = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* checks if all required properties exist on token
|
|
6
3
|
* @param object - tokenValue
|
|
7
4
|
* @param array - property names
|
|
8
5
|
* @returns void or throws error
|
|
9
6
|
*/
|
|
10
|
-
const checkRequiredTokenProperties = (tokenValue, requiredProperties) => {
|
|
7
|
+
export const checkRequiredTokenProperties = (tokenValue, requiredProperties) => {
|
|
11
8
|
for (const prop of requiredProperties) {
|
|
12
9
|
if (prop in tokenValue === false) {
|
|
13
10
|
throw new Error(`Missing property: ${prop} on token with value ${JSON.stringify(tokenValue)}`);
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
13
|
};
|
|
17
|
-
exports.checkRequiredTokenProperties = checkRequiredTokenProperties;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const getTokenValue: (token:
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
|
+
export declare const getTokenValue: (token: TransformedToken, property?: string) => any;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
throw new invalidTokenError_1.invalidTokenValueError(token);
|
|
1
|
+
import { invalidTokenValueError, invalidTokenValuePropertyError } from './invalidTokenError.js';
|
|
2
|
+
export const getTokenValue = (token, property) => {
|
|
3
|
+
var _a;
|
|
4
|
+
const value = (_a = token.$value) !== null && _a !== void 0 ? _a : token.value;
|
|
5
|
+
if (value === undefined) {
|
|
6
|
+
throw new invalidTokenValueError(token);
|
|
8
7
|
}
|
|
9
8
|
// for composite token if subproperty is needed
|
|
10
|
-
if (typeof property === 'string' &&
|
|
11
|
-
throw new
|
|
9
|
+
if (typeof property === 'string' && value[property] === undefined) {
|
|
10
|
+
throw new invalidTokenValuePropertyError(token, property);
|
|
12
11
|
}
|
|
13
12
|
if (typeof property === 'string') {
|
|
14
|
-
return
|
|
13
|
+
return value[property];
|
|
15
14
|
}
|
|
16
|
-
return
|
|
15
|
+
return value;
|
|
17
16
|
};
|
|
18
|
-
exports.getTokenValue = getTokenValue;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasSpaceInString = void 0;
|
|
4
|
-
const hasSpaceInString = (string) => {
|
|
1
|
+
export const hasSpaceInString = (string) => {
|
|
5
2
|
if (typeof string !== 'string') {
|
|
6
3
|
throw new TypeError(`Invalid input. Input must be a string, ${typeof string} provided`);
|
|
7
4
|
}
|
|
8
5
|
return /\s/g.test(string);
|
|
9
6
|
};
|
|
10
|
-
exports.hasSpaceInString = hasSpaceInString;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RgbaFloat } from './isRgbaFloat';
|
|
1
|
+
import type { RgbaFloat } from './isRgbaFloat.js';
|
|
2
2
|
export declare const hexToRgbaFloat: (hex: string, alpha?: number) => RgbaFloat;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hexToRgbaFloat = void 0;
|
|
4
|
-
const hexToRgbaFloat = (hex, alpha) => {
|
|
1
|
+
export const hexToRgbaFloat = (hex, alpha) => {
|
|
5
2
|
// retrieve spots from hex value (hex 3, hex 4, hex 6 or hex 8)
|
|
6
3
|
let result;
|
|
7
4
|
if (hex.length > 5) {
|
|
@@ -30,4 +27,3 @@ const hexToRgbaFloat = (hex, alpha) => {
|
|
|
30
27
|
a: alpha !== undefined ? alpha : result[4] ? parseInt(result[4], 16) / 255 : 1,
|
|
31
28
|
};
|
|
32
29
|
};
|
|
33
|
-
exports.hexToRgbaFloat = hexToRgbaFloat;
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invalidTokenValuePropertyError = exports.invalidTokenValueError = void 0;
|
|
4
|
-
const namePathToDotNotation_1 = require("../namePathToDotNotation");
|
|
1
|
+
import { namePathToDotNotation } from '../namePathToDotNotation.js';
|
|
5
2
|
const composeValueErrorMessage = (token) => {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
const originalValue = (_a = token.original.$value) !== null && _a !== void 0 ? _a : token.original.value;
|
|
5
|
+
const value = (_b = token.$value) !== null && _b !== void 0 ? _b : token.value;
|
|
6
6
|
// eslint-disable-next-line i18n-text/no-en
|
|
7
|
-
return `Invalid token "${
|
|
7
|
+
return `Invalid token "${namePathToDotNotation.transform(token, {}, {})}" in file "${token.filePath}". Transformed value: "${JSON.stringify(value)}". ${originalValue ? `Original value: "${JSON.stringify(originalValue)}" ` : ''}This may be due to referencing a token that does not exists.`;
|
|
8
8
|
};
|
|
9
9
|
const composeValuePropertyErrorMessage = (token, property) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const originalValue = (_a = token.original.$value) !== null && _a !== void 0 ? _a : token.original.value;
|
|
12
|
+
const value = (_b = token.$value) !== null && _b !== void 0 ? _b : token.value;
|
|
10
13
|
// eslint-disable-next-line i18n-text/no-en
|
|
11
|
-
return `Invalid property "${property}" of token "${
|
|
14
|
+
return `Invalid property "${property}" of token "${namePathToDotNotation.transform(token, {}, {})}" in file "${token.filePath}". Transformed property value: "${value[property]}". ${originalValue ? `Original value: "${originalValue[property]}" ` : ''}This may be due to referencing a token that does not exists.`;
|
|
12
15
|
};
|
|
13
|
-
class invalidTokenValueError extends Error {
|
|
16
|
+
export class invalidTokenValueError extends Error {
|
|
14
17
|
constructor(token) {
|
|
15
18
|
super(composeValueErrorMessage(token));
|
|
16
19
|
Error.captureStackTrace(this, invalidTokenValueError);
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
class invalidTokenValuePropertyError extends Error {
|
|
22
|
+
export class invalidTokenValuePropertyError extends Error {
|
|
21
23
|
constructor(token, property) {
|
|
22
24
|
super(composeValuePropertyErrorMessage(token, property));
|
|
23
25
|
Error.captureStackTrace(this, invalidTokenValuePropertyError);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
exports.invalidTokenValuePropertyError = invalidTokenValuePropertyError;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRgbaFloat = void 0;
|
|
4
1
|
// check if a value is an rgba float object
|
|
5
|
-
const isRgbaFloat = (value) => {
|
|
2
|
+
export const isRgbaFloat = (value) => {
|
|
6
3
|
if (value &&
|
|
7
4
|
typeof value === `object` &&
|
|
8
5
|
'r' in value &&
|
|
@@ -21,4 +18,3 @@ const isRgbaFloat = (value) => {
|
|
|
21
18
|
}
|
|
22
19
|
return false;
|
|
23
20
|
};
|
|
24
|
-
exports.isRgbaFloat = isRgbaFloat;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const color2k_1 = require("color2k");
|
|
1
|
+
import { rgba, parseToRgba } from 'color2k';
|
|
4
2
|
/**
|
|
5
3
|
* Mixes two colors together. Taken from sass's implementation.
|
|
6
4
|
*/
|
|
@@ -8,8 +6,8 @@ function mix(color1, color2, weight) {
|
|
|
8
6
|
const normalize = (n, index) =>
|
|
9
7
|
// 3rd index is alpha channel which is already normalized
|
|
10
8
|
index === 3 ? n : n / 255;
|
|
11
|
-
const [r1, g1, b1, a1] =
|
|
12
|
-
const [r2, g2, b2, a2] =
|
|
9
|
+
const [r1, g1, b1, a1] = parseToRgba(color1).map(normalize);
|
|
10
|
+
const [r2, g2, b2, a2] = parseToRgba(color2).map(normalize);
|
|
13
11
|
// The formula is copied from the original Sass implementation:
|
|
14
12
|
// http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
|
|
15
13
|
const normalizedWeight = 2 * weight - 1;
|
|
@@ -23,9 +21,9 @@ function mix(color1, color2, weight) {
|
|
|
23
21
|
const g = Math.round((g1 * weight1 + g2 * weight2) * 255);
|
|
24
22
|
const b = Math.round((b1 * weight1 + b2 * weight2) * 255);
|
|
25
23
|
const a = a2 * weight + a1 * (1 - weight);
|
|
26
|
-
return
|
|
24
|
+
return rgba(r, g, b, a);
|
|
27
25
|
}
|
|
28
|
-
|
|
26
|
+
export default mix;
|
|
29
27
|
// Number* weight = ARGR("$weight", Number, 0, 100);
|
|
30
28
|
// double p = weight->value()/100;
|
|
31
29
|
// double w = 2*p - 1;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rgbaFloatToHex = void 0;
|
|
4
|
-
const rgbaFloatToHex = ({ r, g, b, a }, alpha = true) => {
|
|
1
|
+
export const rgbaFloatToHex = ({ r, g, b, a }, alpha = true) => {
|
|
5
2
|
const values = [r, g, b, alpha === true && a && a < 1 ? a : undefined].filter(item => item !== undefined);
|
|
6
3
|
if (r > 1 || r < 0 || g > 1 || g < 0 || b > 1 || b < 0) {
|
|
7
4
|
throw new Error('Invalid RgbaFloat value. R, G and B values must be between 0 and 1.');
|
|
@@ -12,4 +9,3 @@ const rgbaFloatToHex = ({ r, g, b, a }, alpha = true) => {
|
|
|
12
9
|
.padStart(2, '0'))
|
|
13
10
|
.join('')}`;
|
|
14
11
|
};
|
|
15
|
-
exports.rgbaFloatToHex = rgbaFloatToHex;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definition for w3c border composite token value
|
|
3
|
+
* @link https://design-tokens.github.io/community-group/format/#border
|
|
4
|
+
*/
|
|
5
|
+
export type StrokeStyleString = 'solid' | 'dashed' | 'dotted' | 'double' | 'groove' | 'ridge' | 'outset' | 'inset'
|
|
6
|
+
export type BorderTokenValue = {
|
|
7
|
+
color: string
|
|
8
|
+
width: string
|
|
9
|
+
style: StrokeStyleString
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type {LocalOptions, PlatformConfig} from 'style-dictionary/types'
|
|
2
|
+
|
|
3
|
+
export type PlatformInitializer = (
|
|
4
|
+
// the filename including the extension (e.g. `.css`) and any subfolders after the buildPath (e.g. `functional`)
|
|
5
|
+
outputFile: string,
|
|
6
|
+
// the prefix is prepended to all tokens
|
|
7
|
+
prefix: string | undefined,
|
|
8
|
+
// the build path in which the `outputFile` is placed
|
|
9
|
+
buildPath: string,
|
|
10
|
+
options?: LocalOptions,
|
|
11
|
+
) => PlatformConfig
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definition for w3c shadow composite token value
|
|
3
|
+
* @link https://design-tokens.github.io/community-group/format/#shadow
|
|
4
|
+
*/
|
|
5
|
+
export type ShadowTokenValue = {
|
|
6
|
+
color: string
|
|
7
|
+
offsetX: string
|
|
8
|
+
offsetY: string
|
|
9
|
+
blur: string
|
|
10
|
+
spread: string
|
|
11
|
+
// custom non w3c values
|
|
12
|
+
inset?: boolean
|
|
13
|
+
alpha?: number
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type {Config, PlatformConfig} from 'style-dictionary/types'
|
|
2
|
+
|
|
3
|
+
export type ConfigGeneratorOptions = {
|
|
4
|
+
buildPath: string
|
|
5
|
+
prefix?: string
|
|
6
|
+
themed?: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type StyleDictionaryConfigGenerator = (
|
|
10
|
+
outputName: string,
|
|
11
|
+
source: string[],
|
|
12
|
+
include: string[],
|
|
13
|
+
options: ConfigGeneratorOptions,
|
|
14
|
+
platforms?: Record<string, PlatformConfig | undefined>,
|
|
15
|
+
) => Config
|