Skip to content

Commit

Permalink
feat: automatically replace hard coded fill and stroke colors in inli…
Browse files Browse the repository at this point in the history
…ned SVGs with CSS custom prop placeholders
  • Loading branch information
sghoweri committed Sep 3, 2019
1 parent c11aa05 commit dad8745
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/components/bolt-icon/src/icon.twig
Expand Up @@ -18,6 +18,13 @@
{% include "@bolt-components-icons/#{name}.svg" %}
{% endset %}

{{ svgIcon | replace({'<svg ': '<svg ' ~ 'class="' ~ attributes.class ~ '"'}) }}
{{ svgIcon
| replace('/fill="((?!.*(none|#FFFFFF))[^"]+)"/', 'fill="var(--bolt-theme-icon, currentColor)"')
| replace('fill="#FFFFFF', 'fill="rgba(var(--bolt-theme-background), 1)"')
| replace('<svg ', '<svg ' ~ 'class="' ~ attributes.class ~ '"')
| replace('/<!--(.*)-->/Uis', '')
| replace('/height="([^"]+)"/', '')
| replace('/width="([^"]+)"/', '')
}}
{% endif %}
</bolt-icon>

0 comments on commit dad8745

Please sign in to comment.