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

Alpha hex support #1013

Open
Soviut opened this issue Oct 31, 2012 · 11 comments
Open

Alpha hex support #1013

Soviut opened this issue Oct 31, 2012 · 11 comments

Comments

@Soviut
Copy link

Soviut commented Oct 31, 2012

#697 proposes single and double character hex color support (eg: #E would convert to #EEEEEE).

In the spirit of this, I'm proposing support for alpha hex support.

#FF000080

The extra two hex digits at the end would represent the alpha/opacity. LESS could convert this to:

rgba(255, 0, 0, 0.5)

Producing a pure red with 50% opacity.

@lukeapage
Copy link
Member

will this get in the way of the old IE 8 hex digits? As I remember that begins with alpha.. where as here you would expect it to end in alpha.. Plus I imagine taking an old css sheet and suddenly accepting 8 hex digits and then outputting rgba would also break things.

@Synchro
Copy link
Member

Synchro commented Oct 31, 2012

Yes, while I agree that #RRGGBBAA makes more sense to me, that would indeed clash with argb (#AARRGGBB) that's already in LESS. Admittedly it's done via a function, not a language construct, but it would seem to make sense to use the same format in both if we're to do that.

@Soviut
Copy link
Author

Soviut commented Oct 31, 2012

I didn't realize IE had 8 digit hex. LESS could still normalize this but it could potentially break existing IE-specific sheets. Somehow, I doubt many people are using said IE-specific hex values these day though.

That, or support the #AARRGGBB format throughout. But I think that is backwards-looking.

@lukeapage
Copy link
Member

.. just recently someone went to the trouble of extending dotless to leave these type of hex values alone

dotless/dotless@52ba9a4

TBH I think I see more gain in allowing #E then stepping into the minefield of 8 digit hex

@Synchro
Copy link
Member

Synchro commented Oct 31, 2012

Yes, I don't think this is really worth doing.

@Soviut
Copy link
Author

Soviut commented Oct 31, 2012

Perhaps as a sub-proposal, some way of indicating that the colour is ARGB vs RGBA?

#RRGGBBAA

versus

##AARRGGBB

or

#RRGGBB,AA
#RRGGBB|AA
#RRGGBB_AA

@lukeapage
Copy link
Member

closing due to general lack of support for this feature.

@ashsearle
Copy link

Can this be reopened bearing in mind 4 and 8-digit hex are defined in CSS Color Module Level 4
and already supported in various browsers?

@matthew-dean
Copy link
Member

I assume Less could auto-convert #RRGGBBAA to rgba()?

@seven-phases-max
Copy link
Member

Yes, it's just a matter of adding add a few lines to handle #4 and #8 cases everywhere (it's not too many) #3 and #6 things are parsed.

@stale stale bot added the stale label Mar 17, 2018
@less less deleted a comment from stale bot Mar 17, 2018
@stale stale bot removed the stale label Mar 17, 2018
@LordPachelbel
Copy link

LordPachelbel commented Jul 2, 2021

I don't know when it happened, but at some point rgba() became able to convert #rrggbbaa colors to rgba().

Example:
box-shadow: 0 3px 6px rgba(#00000029); will output as box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16078431);

It isn't documented but it should be, so I did so in this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants