Change URL once primary and/or secondary colors have been selected
edelstone opened this issue · comments
Adding the colors to a specialized URL would allow the link to be shared and bookmarked easily.
Got this via email:
Thanks for the handy Material Design Palette Generator. It would be great if we could bookmark it with the primary/secondary colors in the URL, like https://materialpalettes.com/?primary=#2f5597. Is that something you would consider implementing?
Hmm, honestly what would be awesome would be some kind of hosted API that accepts "hex color(s)" (maybe "primary", "secondary") and sends back some JSON data with the palette(s) in RGB-hex. I'm working on an offline generator for this, but I wish Google had the source for this in one of their material components. The "theme" component is not very sophisticated and requires manual entry for the actual colors.
Got as far as looking through "Color Tool" source to find that in the end they're literally just calling chroma.js lighten
and darken
(since that tool doesn't do the palette generator...).
Anyway, stumbled upon this project on this quest. Thanks for hosting it!
So I tinkered around with the code, and I'm not sure what's going on exactly, but it looks like the function U()
in main.js
, which supposedly takes in a hsl value, doesn't seem to be accurate. in the place where we set the primary color, if I replace the U
function's arguments with 0
, 1
and 0.5
, this is the color I get:
While actually the color with HSL values 0, 1 and 0.5 looks like this:
So yeah, I'm not sure why that's happening.
@JorensM Yeah me either. You may have read in the README that it's all Google's obfuscated code doing the color calculations. Likely not something we should attempt to change but feel free to work around it.
@edelstone I guess I'll pass this one since I don't want to break something somewhere else haha. Maybe someone braver than me will come along and give it a go!
@JorensM not a problem. Thanks for looking!