Skip to content

Commit

Permalink
Allow for stub.font.weight, table.font.size to work to style rown…
Browse files Browse the repository at this point in the history
…ames and row group labels. Part of rstudio#1693
  • Loading branch information
olivroy committed Jul 11, 2024
1 parent b7a25a9 commit 6e4c21d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

* Interactive tables now respect more styling options.

* `column_labels.background.color`, `row_group.background.color`, `row_group.font.weight`, `table_body.hlines.style`,
`table.font.weight`.
* `column_labels.background.color`, `row_group.background.color`, `row_group.font.weight`, `table_body.hlines.style`,
`table.font.weight`, `table.font.size`, `stub.font.weight` (#1693).


# gt 0.11.0

Expand Down
16 changes: 15 additions & 1 deletion R/render_as_i_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,24 @@ render_as_ihtml <- function(data, id) {
column_labels_border_bottom_color <- opt_val(data = data, option = "column_labels_border_bottom_color")
# Don't allow NA
column_labels_background_color = opt_val(data = data, option = "column_labels_background_color")
# Apply stub font weight to
stub_font_weight <- opt_val(data = data, option = "stub_font_weight")

if (is.na(column_labels_background_color)) {
# apply all column labels formatting to both heading + groupCol styling (nothing specific for spanners styling in gt?)
column_labels_background_color <- "transparent"
}
# Part of #1307
borderless_borders <- opt_val(data = data, option = "table_body_hlines_style") == "none"

column_labels_font_weight <- opt_val(data = data, option = "column_labels_font_weight")
# Apply font weight to groupname_col title
row_group_font_weight = opt_val(data = data, "row_group_font_weight")
table_body_font_weight = opt_val(data = data, "table_font_weight")
# for row names + summary label
stub_font_weight <- opt_val(data = data, "stub_font_weight")
# #1693 table font size
table_font_size <- opt_val(data = data, "table_font_size")

emoji_symbol_fonts <-
c(
Expand All @@ -212,6 +221,9 @@ render_as_ihtml <- function(data, id) {
# Create colDef row name with special ".rownames" from reactable.
row_name_col_def <- list(reactable::colDef(
name = rowname_label,
style = list(
fontWeight = stub_font_weight
)
# TODO pass on other attributes of row names column if necessary.
))
names(row_name_col_def) <- ".rownames"
Expand Down Expand Up @@ -536,7 +548,9 @@ render_as_ihtml <- function(data, id) {
highlightColor = NULL,
cellPadding = NULL,
style = list(
fontFamily = font_family_str
`font-family` = font_family_str,
#1693
fontSize = table_font_size
),
tableStyle = list(
borderTopStyle = column_labels_border_top_style,
Expand Down

0 comments on commit 6e4c21d

Please sign in to comment.