From cfa2422be8d5ebdad726bf75f105dc230fe59578 Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Tue, 18 Jun 2019 12:53:41 -0700 Subject: [PATCH] fix(format): adding configurable name to sass map name (#291) Fix #290 --- lib/common/formats.js | 6 +++++- lib/common/templates/scss/map-deep.template | 2 +- lib/common/templates/scss/map-flat.template | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/common/formats.js b/lib/common/formats.js index b2ec669e4..c4056045f 100644 --- a/lib/common/formats.js +++ b/lib/common/formats.js @@ -98,6 +98,8 @@ module.exports = { /** * Creates a SCSS file with a flat map based on the style dictionary * + * Name the map by adding a 'mapName' attribute on the file object in your config. + * * @memberof Formats * @kind member * @example @@ -123,7 +125,9 @@ module.exports = { }, /** - * Creates a SCSS file with a deep map based on the style dictionary + * Creates a SCSS file with a deep map based on the style dictionary. + * + * Name the map by adding a 'mapName' attribute on the file object in your config. * * @memberof Formats * @kind member diff --git a/lib/common/templates/scss/map-deep.template b/lib/common/templates/scss/map-deep.template index bb6cf7a27..b3b424099 100644 --- a/lib/common/templates/scss/map-deep.template +++ b/lib/common/templates/scss/map-deep.template @@ -44,7 +44,7 @@ // output the list of tokens as a Sass nested map // (the values are pointing to the variables) // - print(`$tokens: ${processJsonNode(properties, 0)};\n`); + print(`$${this.mapName||'tokens'}: ${processJsonNode(properties, 0)};\n`); // recursive function to process a properties JSON node // diff --git a/lib/common/templates/scss/map-flat.template b/lib/common/templates/scss/map-flat.template index 91913ad4f..823b1c3bf 100644 --- a/lib/common/templates/scss/map-flat.template +++ b/lib/common/templates/scss/map-flat.template @@ -28,7 +28,7 @@ print('\n'); var output = ''; - output += '$tokens: (\n'; + output += `$${this.mapName||'tokens'}: (\n`; output += allProperties.map(function(prop){ var line = ''; if(prop.comment) {