reveal.js icon indicating copy to clipboard operation
reveal.js copied to clipboard

Fix light/dark bakground detection for backgrounds specified with hsl()

Open tlsa opened this issue 5 years ago • 1 comments

Adds support for HSL(A) colors to the color parsing code.

Previously with the default theme, a light HSL-specified background did not change the text color to dark, making the text unreadable.

You can see the problem that this pull request fixes with the following slide, and the default theme:

<section data-background-color="hsl(0, 30%, 100%)">Slide 1</section>

The README states, "All CSS color formats are supported, including hex values, keywords, rgba() or hsl()".

tlsa avatar Jul 04 '19 18:07 tlsa

Thanks for the PR!

From some quick testing in Chrome/FF I think getComputedStyle(...).backgroundColor is always in rgb/rgba format, even if the color was specified in hsl. Maybe instead of adding a hsl parser, we could read the rgb color from the background element that way? Will need to experiment a bit more.

hakimel avatar Mar 05 '20 13:03 hakimel