-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add colors utilities #121
Add colors utilities #121
Conversation
Local function get_base_color(), conversions hex <=> rgb, rgb color mixer, and global function get_color()
Use a single if statement for each property and concatenate to displayed_color then execute mail.get_color(displayed_color) instead of making many combined if statements
Could break the code, the hex convert to rgb always run on 6-chars
Didn't yet read all of it but here's what I think about current colors.lua and shortcuts: I'd suggest either direct math or caching for colors.lua. Also I feel that single letter shortcuts aren't really improvement but instead makes it harder to follow what is actually happening as you have to think about meaning of those codes. If you like you could implement it with |
☝️ The color.lua code is a bit overkill imo but if you think it is needed 🤷 |
imo better code: (should be more performant too) local colors = {
["h"] = "colorstr"
}
function mail.get_color(style)
return color[style]
end |
Instead of one-letter symbols, it now supports tables of identifiers or single strings
Sorry for being late, I reworked the utility using the following syntax : mail.get_color("header")
mail.get_color({"selected", "important"}) Note that in the utility itself, the table as suggested by @Niklp09 is called Hope this one will be ok for you 👍 |
This is a rework of mail colors. It is a prerequisite for #102, as the addition of it will add many colors. So, it has the following changes :
init.lua
/util/colors.lua
mail.get_color()
which returns a color from mixed base colors. It overpasses the mix if there is only one color given.get_base_color()
. The inheritor ofinit.lua
. It uses shortcuts of one letter to be simplified and notably for the use ofmail.get_color()
. Of course, comments to tell what is what.mail.colors
An example of use :
mail.colors.imp_add_sel
mail.get_color("ias")
,mail.get_color("sai")
...You can note that the new utility is independent from order.
NB : I wrote the whole code in less than 1 hour, so the review should be quick =)