-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: support setting currentColor directly #76
Conversation
@hudochenkov could you give this a look? I'm happy to resolve the merge conflicts. But I'm not gonna invest that time if it's gonna happen again when v7 comes around 😉 |
Honestly, I don't see the need of another option. I think this could be done with existing features. E. g. with |
Hey @hudochenkov thanks for replying 😃 In our design system That's why we went with the simplest approach and just added &--delete::before {
background-image: svg-load(
"24x24/delete.svg",
- color: env(--color-text)
+ currentColor: env(--color-text)
);
} With the resulting change in output: .icon--delete:before {
- background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' color='%23767676'%3E%3Cpath fill='currentColor' fill-rule='evenodd' d='M6 19V7h12v12a2 2 0 01-2 2H8a2 2 0 01-2-2zM5 5a1 1 0 011-1h12a1 1 0 011 1v1H5V5zm5-2h4a1 1 0 011 1H9a1 1 0 011-1z'/%3E%3C/svg%3E");
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23767676' fill-rule='evenodd' d='M6 19V7h12v12a2 2 0 01-2 2H8a2 2 0 01-2-2zM5 5a1 1 0 011-1h12a1 1 0 011 1v1H5V5zm5-2h4a1 1 0 011 1H9a1 1 0 011-1z'/%3E%3C/svg%3E");
} Reducing the generated CSS by 3kBIf all it takes me to search/replace |
Thank you for an extended answer! Have you tried to use Maybe @TrySound has better idea. |
Ah I must have missed it when reading the docs. It looks like it can almost do the job, it just needs to change its signature: -options.transform(svg, path)
+options.transform(svg, path, params) Then transform should in theory be able to solve the same problem 🤔 Gimmie a minute! |
Turns out |
Gonna continue this in a fork |
Replacing currentColor instead of setting
color
as a root param minifies a bit better, especially on small SVGs.