Use design tokens to store brand colors, font families, class lists, or any other reusable value from your design system that gets used across multiple teams or applications. Crucial for design systems and essential for small design teams that need to manage consistency across multiple dev teams.
This workflow approach is a simple example of how to easily integrate design tokens into your project simply using Gulp. This is a really easy task to accomplish that no one talks about (and one that you'll find almost zero documentation on how-to accomplish it in a real world project).
To illustrate the power of design tokens, the .json files in the design-tokens directory are organized into some common modules. When you run gulpfile.js, it:
- merges all the design token
.jsonfiles into one - outputs the merge
.jsonfile (this is your single-source-of-truth-file all teams would consume) into the root of the project - converts the merged
.jsonfile into a.scssfile that gets dumped into yourscsspartials (never commit this file) - compiles all your
.scssfiles (I'm pulling in Tachyons for my example) - loads the
.jsontokens file into gulp'sdataobject which makes your tokens available to your templating system (I use Nunjucks because it's the best JS templating language out there) - puts it all together and outputs a simple
HTMLtemplate that relies on some of the token values
- Run
npm install - Run
npm run buildorgulp buildto start up the project - Move around directories and files as needed (just make sure to update paths where necessary)
Hit me up on twitter: @mindsculpt