Added color to mixin & sprite (support for variables in styles)
See original GitHub issueHey, first of all thanks for the great plugin!
I missed the color prop in the mixin, so I added the fill prop in the formatter files & icon.scss. Are there any plans to integrate the color, size prop to the scss/less in the future?
Thats what I’ve done, it works perfectly for me:
scss-formatter.js:
svg.setAttribute('fill', '%fill%');
styles.scss:
@mixin sprite($name, $fill: #000) {
$sprite: str-replace(map-get($sprites, $name),'%25fill%25',$fill);
background: url($sprite) center no-repeat;
}
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
I only changed the scss cause I only use scss in my proj. Maybe I will integrate the size in the sprite mixin as well.
BR Tillmann
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Solution: Add new styles with our variables, mixins, and sprite ...
Join John Riviello for an in-depth discussion in this video, Solution: Add new styles with our variables, mixins, and sprite tools, part of...
Read more >svg-spritemap-webpack-plugin/variables.md at master - GitHub
Variables. One of the benefits of SVGs is the ability to style them through CSS. This plugin is aimed at using inline SVGs...
Read more >How to use CSS variables with Sass Mixins - Medium
Use any opacity variant of any of the brand colours without adding complexity. Apply changes to any brand colour by editing just one...
Read more >Multi-Colored SVG Symbol Icons with CSS Variables | frontstuff
Passing the CSS variables in the mixin through @content is optional. If you do it outside, the compiled CSS will be the same....
Read more >LESS: Mixin and variable names by variable value
2. Do not create variables and mixins for every single image property and for every single CSS property. Note that all images of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@TillmannD, great to hear! I’m hoping to test it some more this evening and will release a version containing this feature this weekend if I can find the time.
Hey @TillmannD, if you want (and have the time) you can check out the progress by installing the plugin from the
vars
branch:The feature feels complete to me, the documentation has been updated and I’ve written some basic tests. I’ll be testing it on some projects myself in the next week or so and will release it when I’m sure everything works correctly.
If you (or anyone else) has feedback on this feature I’d be glad to receive it in this thread ❤️