Skip to content

Instantly share code, notes, and snippets.

@shawnbot
Created April 19, 2017 21:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnbot/dbf272d33867e150be1b65f8bc255529 to your computer and use it in GitHub Desktop.
Save shawnbot/dbf272d33867e150be1b65f8bc255529 to your computer and use it in GitHub Desktop.
Design tokens for Jekyll
colorBlue: '#00f'
colorGreen: '#0f0'
colorRed: '#f00'
---
---
// SCSS variables
{% for token in site.data.tokens %}
${{ token[0] }}: {{ token[1] }};
{% endfor %}
// or as a map
$tokens: ({% for token in site.data.tokens %}
{{ token[0] }}: {{ token[1] }},
{% endfor %});
// then you'd create variables like so:
// $color-blue: map-get($tokens, colorBlue);
// generate utility classes for each color
{% for token in site.data.tokens %}
{% unless token[0] contains 'color' %}{% continue %}{% endunless %}
{% assign name = token[0] | replace: 'color', '' | downcase %}
.fg-{{ name }} { color: {{ token[1] }}; }
.bg-{{ name }} { background-color: {{ token[1] }}; }
{% endfor %}
// or CSS variables!
:root {
{% for token in site.data.tokens %}
--{{ token[0] }}: {{ token[1] }};
{% endfor %}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment