8000 Add a function to generate styled tables from presets by rich-iannone · Pull Request #987 · rstudio/gt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a function to generate styled tables from presets #987

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

Merged
merged 31 commits into from
Jul 20, 2022

Conversation

rich-iannone
Copy link
Member

This PR adds the opt_stylize() function to enable the styling of a table based on a numbered style and color.

Fixes: #238

* master: (214 commits)
  Update .Rbuildignore
  Change names of vector formatting fns
  Update x_time.Rd
  Update x_markdown.Rd
  Update x_datetime.Rd
  Update format_vec.R
  Update x_bytes.Rd
  Update x_date.Rd
  Update format_vec.R
  Add note about data generation
  Update x_currency.Rd
  Update x_bytes.Rd
  Update format_vec.R
  Update help files using roxygen
  Update format_vec.R
  Update x_scientific.Rd
  Update x_integer.Rd
  Update format_vec.R
  Update x_integer.Rd
  Update x_number.Rd
  ...
8000
@rich-iannone rich-iannone requested a review from cscheid July 12, 2022 19:59
Copy link
Member
@cscheid cscheid left a comment

Choose a reason for hiding this comment

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

I have a couple of questions this time.

@rich-iannone rich-iannone requested a review from cscheid July 15, 2022 15:46
@rich-iannone
Copy link
Member Author

One thing I need to do is check contrast levels (with white text on dark backgrounds). I don't think I have enough contrast in some cases and I'd like to pass all the checks at https://webaim.org/resources/contrastchecker/ before finalizing this.

@rich-iannone rich-iannone marked this pull request as draft July 15, 2022 15:55
@cscheid
Copy link
Member
cscheid commented Jul 15, 2022

One thing I need to do is check contrast levels (with white text on dark backgrounds). I don't think I have enough contrast in some cases and I'd like to pass all the checks at https://webaim.org/resources/contrastchecker/ before finalizing this.

Cool, that's great. Please ask @batpigandme about a11y. It's a good important thing to check for those, but we should be using the same tooling across the org (it's possible you have already, in which case no need to check again!)

@rich-iannone
Copy link
Member Author

Hey @batpigandme , I've been working on this PR for the opt_stylize() function that adds a few themes with various color combinations and I could use your expertise on the matter.

The function essentially styles a gt table using a base color and a style preset (any number from 1 to 6). With the output tables I was able to visually check all of the resulting color combinations of computed text color with their matching background colors and then go a bit further with some contrast checking tools. Here's an example of how to produce a table with the new theme feature (and a screen capture of the table is below):

exibble %>%
  gt(rowname_col = "row", groupname_col = "group") %>%
  summary_rows(
    groups = "grp_a",
    columns = c(num, currency),
    fns = list(
      min = ~min(., na.rm = TRUE),
      max = ~max(., na.rm = TRUE)
    )) %>%
  grand_summary_rows(
    columns = currency,
    fns = list(
      total = ~sum(., na.rm = TRUE)
    )) %>%
  tab_source_note(source_note = "This is a source note.") %>%
  tab_footnote(
    footnote = "This is a footnote.",
    locations = cells_body(columns = 1, rows = 1)
  ) %>%
  tab_header(
    title = "The title of the table",
    subtitle = "The table's subtitle"
  ) %>%
  opt_stylize(style = 6, color = "cyan")

opt_stylize_blue_1

I was able to manually check every combination of text and background color using the following two things:

Is this enough? Or did I miss something, perhaps a better piece of tooling? Happy to show all of this to you in a video call anytime.

@rich-iannone rich-iannone marked this pull request as ready for review July 15, 2022 19:58
@batpigandme
Copy link
Contributor

Great job, Rich! If the color contrasts pass those, you're good to go!

@rich-iannone
8000
Copy link
Member Author

Thanks, @batpigandme ! I feel much better about eventually merging this in now.

@cscheid would you be able to re-review (when you’re back, that is) and possibly approve?

Copy link
Member
@cscheid cscheid left a comment

Choose a reason for hiding this comment

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

lgtm

@rich-iannone rich-iannone merged commit 3a8e0de into master Jul 20, 2022
@rich-iannone rich-iannone deleted the color-themes branch July 20, 2022 19:59
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.

Create table themes
3 participants
0