Created
April 19, 2017 21:23
-
-
Save shawnbot/dbf272d33867e150be1b65f8bc255529 to your computer and use it in GitHub Desktop.
Design tokens for Jekyll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colorBlue: '#00f' | |
colorGreen: '#0f0' | |
colorRed: '#f00' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
--- | |
// 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