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

Add parseCssColors() function #155

Merged
merged 9 commits into from
Feb 19, 2020
Merged

Add parseCssColors() function #155

merged 9 commits into from
Feb 19, 2020

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented Feb 18, 2020

parseCssColors takes CSS colors as strings, removes insignificant whitespace, decodes them to RGB (including hsl()), and returns strings in #RRGGBB(AA) form. (Note that IE11 doesn't support #RRGGBBAA; the point of this isn't to send the return values to the browser, but for them to be used in R.)

We've needed this in a few packages already (gt, shiny, bootstraplib); seems like a good time to robustify and centralize this logic.

Testing notes

This feature has comprehensive unit tests.

R/colors.R Show resolved Hide resolved
R/colors.R Outdated Show resolved Hide resolved
@jcheng5
Copy link
Member Author

jcheng5 commented Feb 18, 2020

Didn't realize the HSL-to-RGB conversion was in the spec: https://www.w3.org/TR/css-color-3/#hsl-color

R/colors.R Outdated Show resolved Hide resolved
R/colors.R Outdated Show resolved Hide resolved
R/colors.R Outdated Show resolved Hide resolved
R/colors.R Outdated Show resolved Hide resolved
R/colors.R Outdated Show resolved Hide resolved
R/colors.R Show resolved Hide resolved
@jcheng5 jcheng5 marked this pull request as ready for review February 19, 2020 15:48
@jcheng5 jcheng5 requested a review from cpsievert February 19, 2020 15:48
Copy link
Collaborator

@cpsievert cpsievert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done! 🎉

@jcheng5 jcheng5 merged commit 11f0a9f into master Feb 19, 2020
@cpsievert cpsievert deleted the joe/feature/parse-css-colors branch June 16, 2020 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants