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

Simplify conditions, use vctrs, use dev covr for test-coverage #1939

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Minor refactoring of code. Conditions, vctrs
olivroy committed Jan 7, 2025
commit 4a1c12f25b4fa2101d9ea85e65c79e2e6436b28d
2 changes: 1 addition & 1 deletion R/gt_group.R
Original file line number Diff line number Diff line change
@@ -796,7 +796,7 @@ grp_options <- function(
dplyr::bind_rows(
dplyr::inner_join(
new_df,
dplyr::select(opts_df, -value),
dplyr::select(opts_df, -"value"),
by = "parameter"
),
dplyr::anti_join(opts_df, new_df, by = "parameter")
2 changes: 1 addition & 1 deletion R/render_as_i_html.R
Original file line number Diff line number Diff line change
@@ -397,7 +397,7 @@ render_as_ihtml <- function(data, id) {
# for defaultExpanded = TRUE
expand_groupname_col <- TRUE
# modify data_tbl to include
data_tbl <- dplyr::bind_cols(
data_tbl <- vctrs::vec_cbind(
data_tbl,
data_tbl0[ , groupname_col, drop = FALSE]
)
2 changes: 1 addition & 1 deletion R/tab_options.R
Original file line number Diff line number Diff line change
@@ -906,7 +906,7 @@ tab_options <- function(
dplyr::bind_rows(
dplyr::inner_join(
new_df,
dplyr::select(opts_df, -value),
dplyr::select(opts_df, -"value"),
by = "parameter"
),
dplyr::anti_join(opts_df, new_df, by = "parameter")
12 changes: 6 additions & 6 deletions R/utils_render_grid.R
Original file line number Diff line number Diff line change
@@ -104,17 +104,17 @@ create_heading_component_g <- function(data) {

title_styles <- NA_character_
if ("title" %in% styles_tbl$locname) {
title_style_rows <- vctrs::vec_slice(styles_tbl, styles_tbl$locname == "title")
if (nrow(title_style_rows) > 0) {
title_styles <- title_style_rows$html_style
title_styles <- vctrs::vec_slice(styles_tbl$html_style, styles_tbl$locname == "title")
if (length(title_styles) == 0) {
title_styles <- NA_character_
}
}

subtitle_styles <- NA_character_
if (subtitle_defined && "subtitle" %in% styles_tbl$locname) {
subtitle_style_rows <- vctrs::vec_slice(styles_tbl, styles_tbl$locname == "subtitle")
if (nrow(subtitle_style_rows) > 0) {
subtitle_styles <- subtitle_style_rows$html_style
subtitle_styles <- vctrs::vec_slice(styles_tbl$html_style, styles_tbl$locname == "subtitle")
if (length(subtitle_styles) == 0) {
subtitle_styles <- NA_character_
}
}

21 changes: 11 additions & 10 deletions R/utils_render_html.R
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ styles_to_html <- function(styles) {
style <- as.character(x)
} else if (all(names(x) != "")) {
x <- cell_style_to_html(x)
style <- gsub(";;", ";", paste0(names(x), ": ", x, ";", collapse = " "))
style <- gsub(";;", ";", paste0(names(x), ": ", x, ";", collapse = " "), fixed = TRUE)
} else {
style <- as.character(x)
}
@@ -417,11 +417,11 @@ create_heading_component_h <- function(data) {
# Get the style attrs for the title
if ("title" %in% styles_tbl$locname) {

title_style_rows <- styles_tbl[styles_tbl$locname == "title", ]

if (nrow(title_style_rows) > 0) {
title_styles <- title_style_rows$html_style
} else {
title_styles <- vctrs::vec_slice(
styles_tbl$html_style,
styles_tbl$locname == "title"
)
if (length(title_styles) == 0) {
title_styles <- NULL
}

@@ -450,11 +450,12 @@ create_heading_component_h <- function(data) {

# Get the style attrs for the subtitle
if (subtitle_defined && "subtitle" %in% styles_tbl$locname) {
subtitle_style_rows <- styles_tbl[styles_tbl$locname == "subtitle", ]
subtitle_styles <- vctrs::vec_slice(
styles_tbl$html_style,
styles_tbl$locname == "subtitle"
)

if (nrow(subtitle_style_rows) > 0) {
subtitle_styles <- subtitle_style_rows$html_style
} else {
if (length(subtitle_styles) == 0) {
subtitle_styles <- NULL
}

2 changes: 1 addition & 1 deletion R/z_utils_render_footnotes.R
Original file line number Diff line number Diff line change
@@ -236,7 +236,7 @@ resolve_footnotes_styles <- function(data, tbl_type) {
# Re-combine `tbl_not_column_cells`
# with `tbl_column_cells`
tbl <-
dplyr::bind_rows(
vctrs::vec_rbind(
tbl_not_column_cells,
tbl_column_cells
)