question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Added color to mixin & sprite (support for variables in styles)

See original GitHub issue

Hey, 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:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
cascornelissencommented, Jun 1, 2018

@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.

2reactions
cascornelissencommented, May 27, 2018

Hey @TillmannD, if you want (and have the time) you can check out the progress by installing the plugin from the vars branch:

npm install --save-dev cascornelissen/svg-spritemap-webpack-plugin#vars

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 ❤️

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found