@justeat/pie-design-tokens
Advanced tools
Comparing version 6.6.0 to 6.7.0
const { | ||
CONSTANTS, | ||
convertGlobalTokenValueToStylesValue, | ||
convertHexValueToRGB, | ||
convertWordToPascalCase, | ||
@@ -21,5 +22,7 @@ getConvertedShadowsToBoxShadowValues, | ||
let currentThemeTokens = {}; | ||
/** | ||
* Returns a token value using the specified category and name properties passed in. | ||
* Also handles some special cases (such as rgba format for colour aliases). | ||
* Also handles some special cases (such as rgb format with opacity for colour aliases). | ||
* | ||
@@ -35,3 +38,3 @@ * @param {string} category – Object key referencing the category of global token to access (i.e. color, font, radius) | ||
// If the category is a color and it includes a pipe character, then it'll be in the format `ALIAS_NAME|OPACITY` or `ALIAS_NAME,PERCENTAGE%` | ||
// So we need to replace the ALIAS_NAME with the global value and then convert that hex value to an RGBA | ||
// So we need to replace the ALIAS_NAME with the global token value and then convert that hex value to RGB | ||
// if not, then we can just convert the alias using the global values we have | ||
@@ -41,4 +44,6 @@ if (baseCategory === 'color' && name.includes('|')) { | ||
varName = `${baseCategory}-${nameParts[0]}`; | ||
const globalColorTokens = currentThemeTokens.color[GLOBAL_TOKEN_KEY]; | ||
const hexValue = globalColorTokens[nameParts[0]]; | ||
return `rgba(${getScssVarValue(varName)}, ${nameParts[1]})`; | ||
return convertHexValueToRGB(hexValue, nameParts[1]); | ||
} else if (baseCategory === 'color' && name.includes('%')) { | ||
@@ -160,2 +165,4 @@ // We just care about the % for HSL calculations | ||
currentThemeTokens = themeTokens; | ||
// e.g. color/font/spacing | ||
@@ -162,0 +169,0 @@ categoryKeys.forEach((category) => { |
@@ -175,3 +175,3 @@ const fs = require('fs'); | ||
/** | ||
* Converts a given hex value to rgb value with optional opacity parametr. | ||
* Converts a given hex value to rgb value with optional opacity parameter. | ||
* @param {string} hexCode – hex colour code | ||
@@ -178,0 +178,0 @@ * @param {string} opacity – optional opacity value |
@@ -2095,3 +2095,3 @@ { | ||
}, | ||
"version": "6.6.0" | ||
"version": "6.7.0" | ||
} |
{ | ||
"name": "@justeat/pie-design-tokens", | ||
"version": "6.6.0", | ||
"version": "6.7.0", | ||
"description": "Design Tokens for the PIE Component System", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
549179
7134