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

[Feature Request] Custom Icon Colors #2260

Open
deniszholob opened this issue Mar 28, 2024 · 2 comments
Open

[Feature Request] Custom Icon Colors #2260

deniszholob opened this issue Mar 28, 2024 · 2 comments

Comments

@deniszholob
Copy link

deniszholob commented Mar 28, 2024

While there is a way to change folder colors, it would be great if icons could change as well.
Something similar proposed in #768

For example the Angular icon set contains 7 different preset colors associated with a filename.something.ts

Angular (red)
Angular-component (blue)
etc...

Godot had 2, blue and green
Lots of others just have 1

What would be great is if developers could have their own associations based on whatever color they want, instead of having to add various color icons into the repo

"material-icon-theme.files.associations": {
    "*.model.ts": { name: "angular", color: "#ef00ff" },
    "*.component.gd": { name: "godot", color: "#ffc400" },
    "*.tscn": { name: "godot", color: "#00ff04" },
    "*.gd" : "godot"
  },

Ideas on implementation:

  • Have an "accent" id or class property for color in svgs that can be searched for and the fill color replaced with provided custom color
  • Recoloring icons with a filter as a whole? Not sure if this is as usefull
@PKief
Copy link
Owner

PKief commented Mar 29, 2024

Thanks for the idea, it sounds very nice. Personally, I think it's too much effort and it's not a feature which is highly requested. There might be various edge cases where this might not work properly as an icon can have multiple colors, too. I mean we're talking about more than 900 icons where we would need to figure out how it's possible or not. So that's why I'm not sure if I want to spend some effort here. But we can keep this issue open if someone else might find some time and makes a proposal

@deniszholob
Copy link
Author

deniszholob commented Mar 29, 2024

I took a look at icons more closely and yeah... there are some rainbow colored ones like appsscript or gcp or figma
I think the simplest solution then is just applying a color filter on an svg if a user provides a custom color

I made a proof of concept https://deniszholob.github.io/svg-colorizer-poc/index.html
Here is my repo https://github.com/deniszholob/svg-colorizer-poc
Mainly this file https://github.com/deniszholob/svg-colorizer-poc/blob/main/util/colorizer.js#L49
with helpers from https://github.com/deniszholob/svg-colorizer-poc/blob/main/util/color.util.js#L130

Escentially i was thinking of the photoshop/photopea hue/saturation filter when pressing the "colorize" button. So it applies the coolor but keeps the shade. Thats where the adjustHue and calculateHueAngle function comes into play. We just find how to get to the target color from the initial color.

I did this for figma icon, then ran it through all the icons in this repo on the other page
https://deniszholob.github.io/svg-colorizer-poc/mat-icons.html

So i think using this code for colorizing and adding some code to modify the config in this repo to accept optional colorizer color we can make this happen

SVG Colorizer POC

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