Skip to content

Commit

Permalink
feat: add sample for token deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
feerglas committed Apr 6, 2020
1 parent f07c5c4 commit 23d9a81
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
19 changes: 19 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const StyleDictionary = require('style-dictionary').extend(__dirname + '/config.json');
const fs = require('fs');
const _ = require('lodash');


console.log('Build started...');
console.log('\n==============================================');

StyleDictionary.registerFormat({
name: 'custom/format/scss',
formatter: _.template(fs.readFileSync(__dirname + '/templates/web-scss.template'))
});

// FINALLY, BUILD ALL THE PLATFORMS
StyleDictionary.buildAllPlatforms();


console.log('\n==============================================');
console.log('\nBuild completed!');
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"files": [
{
"destination": "_variables.scss",
"format": "scss/variables"
"format": "custom/format/scss"
},
{
"destination": "_variables.map.flat.scss",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"husky": "^4.2.3",
"lodash": "^4.17.15",
"semantic-release": "^17.0.4",
"semantic-release-slack-bot": "^1.6.1"
},
"files": [
"dist/"
],
"scripts": {
"build": "./node_modules/style-dictionary/bin/style-dictionary build",
"build": "node ./build.js",
"lint": "./node_modules/@prantlf/jsonlint/lib/cli.js -q ./properties/**/*.json",
"semantic-release": "semantic-release"
},
Expand Down
7 changes: 6 additions & 1 deletion properties/color/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"medium": {"value": "#C60018"},
"dark" : {"value": "#A20013"}
},
"white": {"value": "#FFFFFF"}
"white": {"value": "#FFFFFF"},
"green": {
"value": "#FFFFFF",
"deprecated": true,
"deprecated_comment": "Please use \"red\""
}
}
}
}
17 changes: 17 additions & 0 deletions templates/web-scss.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

<% _.each(allProperties, function(prop) {
var output = "";
if(prop.deprecated) {
output += "// Notice: the following value is deprecated";
if(prop.deprecated_comment) {
output += " (" + prop.deprecated_comment + ")";
}
output += "\n";
}
output += "$" + prop.name + ": " + prop.value + ";";
if(prop.comment) {
output += " // " + prop.comment;
}
output += "\n";
print(output);
}); %>

0 comments on commit 23d9a81

Please sign in to comment.