textual icon indicating copy to clipboard operation
textual copied to clipboard

color: auto support

Open willmcgugan opened this issue 3 years ago • 6 comments
trafficstars

I'm wondering if we should have a auto value for the color rule, which selects white or black, whichever has better contrast.

This could also work in conjunction with optional opacity.

color: auto 95%;
color: auto 75%;

I'm considering this because the default color theme pre-calculates such colors and leaves you to specifiy them as CSS variables, which seems redundant.

i.e.

background: $primary-background-lighten-2;
color: $text-primary-background-lighten-2;

But if we have color: auto, that can go on the base widget, and we can omit color entirely.

willmcgugan avatar Jun 09 '22 15:06 willmcgugan

@darrenburns @DrBenton Thoughts?

willmcgugan avatar Jun 09 '22 15:06 willmcgugan

I'm kind of on the fence for this because I can see it (or something like it) has value, but at the same time I don't think my gut reaction when I see "color: auto" is that it would pick either black or white.

As it stands when you set a background colour, doesn't the text colour already automatically get set such that it's readable?

darrenburns avatar Jun 10 '22 09:06 darrenburns

I feel it makes sense since on virtual every interface, text is black or white (with a hint of alpha). Perhaps there is a better term than auto?

As it stands when you set a background colour, doesn't the text colour already automatically get set such that it's readable?

Not as such, but there is a precalculated contrasting color (black or white) for ever CSS color variable.

willmcgugan avatar Jun 10 '22 10:06 willmcgugan

Did we solve your problem?

Consider buying the Textualize developers a coffee to say thanks.

Textualize

github-actions[bot] avatar Jun 14 '22 09:06 github-actions[bot]

I'm not sure I totally understand the sense of that task... Does it mean that we should be able to write something like this? :slightly_smiling_face:

background: auto; /* = "black" for light theme, "white" for dark theme ? */
color: auto; /* the opposite of this ☝ ? */

...and then see background's auto be replaced with black, while color's auto would be replaced with white? (for light theme, at least - for a dark theme I guess it would be the opposite)

In which case, we would likely need to created a mapping of which properties refer to "background-ish" colours by default, and which ones to "text-ish" colours, so we can replace auto with the right colour?

But again, I might have got this completely wrong :sweat_smile:

olivierphi avatar Jun 24 '22 14:06 olivierphi

It would just be "color" that respects auto. Basically picking white or black, whatever has best contrast.

willmcgugan avatar Jun 24 '22 15:06 willmcgugan

Did we solve your problem?

Consider buying the Textualize developers a coffee to say thanks.

Textualize

github-actions[bot] avatar Sep 13 '22 15:09 github-actions[bot]