diff --git a/README.md b/README.md index 310b0e101..e4918d9e5 100644 --- a/README.md +++ b/README.md @@ -280,11 +280,11 @@ const StyleDictionary = require('style-dictionary').extend('config.json'); StyleDictionary.registerTransform({ name: 'time/seconds', type: 'value', - matcher: function(prop) { - return prop.attributes.category === 'time'; + matcher: function(token) { + return token.attributes.category === 'time'; }, - transformer: function(prop) { - return (parseInt(prop.original.value) / 1000).toString() + 's'; + transformer: function(token) { + return (parseInt(token.original.value) / 1000).toString() + 's'; } }); diff --git a/docs/extending.md b/docs/extending.md index 3222e47f8..361902c85 100644 --- a/docs/extending.md +++ b/docs/extending.md @@ -20,11 +20,11 @@ const StyleDictionary = require('style-dictionary').extend('config.json'); StyleDictionary.registerTransform({ name: 'time/seconds', type: 'value', - matcher: function(prop) { - return prop.attributes.category === 'time'; + matcher: function(token) { + return token.attributes.category === 'time'; }, - transformer: function(prop) { - return (parseInt(prop.original.value) / 1000).toString() + 's'; + transformer: function(token) { + return (parseInt(token.original.value) / 1000).toString() + 's'; } }); @@ -40,8 +40,8 @@ const StyleDictionary = require('style-dictionary').extend('config.json'); StyleDictionary.registerTransform({ name: 'name/uppercase', type: 'name', - transformer: function(prop) { - return prop.path.join('_').toUpperCase(); + transformer: function(token) { + return token.path.join('_').toUpperCase(); } }); diff --git a/lib/common/transforms.js b/lib/common/transforms.js index ff7f12441..bedfc394f 100644 --- a/lib/common/transforms.js +++ b/lib/common/transforms.js @@ -412,7 +412,7 @@ module.exports = { * Transforms the value into a Color class for Compose * * ```kotlin - * // Matches: prop.attributes.category === 'color' + * // Matches: token.attributes.category === 'color' * // Returns: * Color(0xFF009688) * ``` @@ -422,8 +422,8 @@ module.exports = { 'color/composeColor': { type: 'value', matcher: isColor, - transformer: function (prop) { - var str = Color(prop.value).toHex8(); + transformer: function (token) { + var str = Color(token.value).toHex8(); return 'Color(0x' + str.slice(6) + str.slice(0,6) + ')' } }, @@ -742,7 +742,7 @@ module.exports = { * Transforms the value from a REM size on web into a scale-independent pixel (sp) value for font sizes in Compose. It WILL scale the number by a factor of 16 (or the value of 'basePxFontSize' on the platform in your config). * * ```kotlin - * // Matches: prop.attributes.category === 'size' && prop.attributes.type === 'font' + * // Matches: token.attributes.category === 'size' && token.attributes.type === 'font' * // Returns: * "16.0.sp" * ``` @@ -752,10 +752,10 @@ module.exports = { 'size/compose/remToSp': { type: 'value', matcher: isFontSize, - transformer: function(prop, options) { - const val = parseFloat(prop.value); + transformer: function(token, options) { + const val = parseFloat(token.value); const baseFont = getBasePxFontSize(options); - if (isNaN(val)) throwSizeError(prop.name, prop.value, 'sp'); + if (isNaN(val)) throwSizeError(token.name, token.value, 'sp'); return (val * baseFont).toFixed(2) + '.sp'; } }, @@ -765,7 +765,7 @@ module.exports = { * Transforms the value from a REM size on web into a density-independent pixel (dp) value for font sizes in Compose. It WILL scale the number by a factor of 16 (or the value of 'basePxFontSize' on the platform in your config). * * ```kotlin - * // Matches: prop.attributes.category === 'size' && prop.attributes.type !== 'font' + * // Matches: token.attributes.category === 'size' && token.attributes.type !== 'font' * // Returns: * "16.0.dp" * ``` @@ -775,10 +775,10 @@ module.exports = { 'size/compose/remToDp': { type: 'value', matcher: isNotFontSize, - transformer: function(prop, options) { - const val = parseFloat(prop.value); + transformer: function(token, options) { + const val = parseFloat(token.value); const baseFont = getBasePxFontSize(options); - if (isNaN(val)) throwSizeError(prop.name, prop.value, 'dp'); + if (isNaN(val)) throwSizeError(token.name, token.value, 'dp'); return (val * baseFont).toFixed(2) + '.dp'; } }, @@ -787,7 +787,7 @@ module.exports = { * Adds the .em Compose extension to the end of a number. Does not scale the value * * ```kotlin - * // Matches: prop.attributes.category === 'size' && prop.attributes.type === 'font' + * // Matches: token.attributes.category === 'size' && token.attributes.type === 'font' * // Returns: * "16.0em" * ``` @@ -797,9 +797,9 @@ module.exports = { 'size/compose/em': { type: 'value', matcher: isFontSize, - transformer: function(prop) { - const val = parseFloat(prop.value); - if (isNaN(val)) throwSizeError(prop.name, prop.value, 'em'); + transformer: function(token) { + const val = parseFloat(token.value); + if (isNaN(val)) throwSizeError(token.name, token.value, 'em'); return val + '.em'; } },