-
Notifications
You must be signed in to change notification settings - Fork 197
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
Transform certain X11 colors with no CSS equivalent #787
Conversation
* master: Add the `force_sign` arg to several numeric formatters (#793)
Open question:
|
Named CSS3 colors are now detected and normalized to hexadecimal values before hitting |
R/data_color.R
Outdated
# translate certain color names (CSS exclusive names) if necessary | ||
if (!all(grepl("^#", colors))) { | ||
|
||
named_colors <- tolower(colors[!grepl("^#", colors)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify conditional logic (both 378 and 382) by reusing the variable you'll need anyway.
R/data_color.R
Outdated
if (any(named_colors %in% css_exclusive_color_names())) { | ||
|
||
colors <- | ||
vapply( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vectorize please
* master: Add padding options for heading and column labels (#795)
R/data_color.R
Outdated
colors[is_css_excl_named] <- | ||
names( | ||
css_exclusive_color_names()[ | ||
match(tolower(colors[is_css_excl_named]), css_exclusive_color_names()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch css_exclusive_color_names
's names to values and values to names
R/data_color.R
Outdated
unname( | ||
css_exclusive_colors()[ | ||
match(colors[is_css_excl_named], names(css_exclusive_colors())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unname( | |
css_exclusive_colors()[ | |
match(colors[is_css_excl_named], names(css_exclusive_colors())) | |
unname(css_exclusive_colors()[colors[is_css_excl_named]]) |
* master: Transform certain X11 colors with no CSS equivalent (#787)
This PR intercepts named colors just before sass compilation and replaces X11 color names with no CSS color equivalent with a hexadecimal color. This should likely be done in more places where colors serve as inputs (e.g.,
cell_fill()
) being careful to only apply the transformation in the HTML context.The X11 color names that don't work as CSS color names are the shades of gray (e.g.,
gray1
,gray85
,grey50
, etc.). The ones that do work but yield small-to-large differences between X11 and CSS are the numbered variants in some colors (e.g.,Azure2
, etc.).Fortunately, the gt package has a utility function to handle the conversion from X11 color name to hexadecimal color code (
html_color()
). This is used only in those cases where X11 colors need transformation.Fixes: #712