Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to use currentColor for svg icons #59

Open
ctwhome opened this issue Aug 21, 2023 · 2 comments
Open

Not possible to use currentColor for svg icons #59

ctwhome opened this issue Aug 21, 2023 · 2 comments

Comments

@ctwhome
Copy link

ctwhome commented Aug 21, 2023

The current implementation uses the tag setting the icon as a background-image from the css. In this manner, it is impossible to use the currentColor variable that comes with the SVG. (https://stackoverflow.com/questions/13367868/how-to-modify-the-fill-color-of-an-svg-image-when-being-served-as-background-ima)

A possible solution is to apply a mask to each icon from the global theme, but it doesn't work well with all icons

background-color:<theme>;
    -webkit-mask-image: url(icon.svg);
    mask-image: url(icon.svg);

The best approach would be to insert the svg inside of each toolbar component instead of using the tag

For the previous example, the you would replace :

<DropDownItem on:click class="item">
  <i class="icon image" />
  <span class="text">Image</span>
</DropDownItem>

with

<DropDownItem on:click class="item">
  <svg src="images/icons/image.svg">
  <span class="text">Image</span>
</DropDownItem>

This way the currentColor variable will take the text color.

@umaranis
Copy link
Owner

Hi @ctwhome ,

If I understand it correctly, the suggested solution will make the SVG part of the component itself.

The downside is the user will lose the ability to change the SVG using CSS. What do you think about this downside?

@ctwhome
Copy link
Author

ctwhome commented Aug 23, 2023

Why not let the user choose their own svg with a placeholder with ? I am thinking of how important is to be able to theme. Any application with a dark theme will be broken this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants