react-switch icon indicating copy to clipboard operation
react-switch copied to clipboard

Add support for hex colors with alpha values

Open jackstenglein opened this issue 3 years ago • 3 comments

Allows colors to be specified in #rrggbbaa format as well as the currently-supported formats.

jackstenglein avatar Nov 05 '21 21:11 jackstenglein

Hi @jackstenglein, thanks for the PR.

IE11 doesn't have support for 8-digit hex values, so this has to be written in a way that regular hex-values don't get converted to 8-digit values.

I'm not opposed to adding this since it's such a small thing, but could you try to convince me why alpha values is something people would want? I don't recall anyone asking for it previously.

markusenglund avatar Nov 08 '21 14:11 markusenglund

@markusenglund Thanks for the quick response. I'll rewrite this to avoid breaking IE11. As for why this is useful, I can only speak for myself. I personally want this change because the designs I am implementing call for me to use an off-green color at a 30% opacity. Without this PR, passing my 8-digit hex causes the switch to have the incorrect colors. While I can manually convert my 8-digit hex to a 6-digit hex, this only works if I know the background color that the switch will be sitting on. This therefore requires me to manually go through my designs, find each place the switch is used, and manually calculate the 6-digit hex depending on the background color behind the switch. Personally I would prefer to just pass the 8-digit hex. Of course, if you know a better way to do what I am describing, then I am happy to close this PR and do that instead.

jackstenglein avatar Nov 08 '21 20:11 jackstenglein

Alright. I'd be happy to merge this if you rewrite it to support IE. Keep in mind that it'll probably be a few months until I do a new release on NPM.

markusenglund avatar Nov 09 '21 09:11 markusenglund