Skip to content

Commit

Permalink
issue88: ident (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock authored Jan 20, 2024
1 parent 99e71e0 commit 0344545
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/group_bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ group_bootstrap_row <- function(x, i, j, indent = 1, ...) {
idx <- insert_values(seq_len(m$nrows), rep(NA, length(i)), i)
idx_old <- idx$new[!is.na(idx$old)]
idx_new <- idx$new[is.na(idx$old)]
out <- style_tt(out, i = idx_old, j = 1, indent = indent)
# cannot be style_tt, because we already have a string bootstrap table at this stage
out <- style_bootstrap(out, i = idx_old, j = 1, indent = indent)

dots <- list(...)
dots[["j"]] <- NULL
Expand Down
3 changes: 3 additions & 0 deletions R/style_bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ style_bootstrap <- function(x,
settings$bootstrap <- vectorize_bootstrap(settings$bootstrap, color, "color: %s;")
settings$bootstrap <- vectorize_bootstrap(settings$bootstrap, background, "background-color: %s;")
settings$bootstrap <- vectorize_bootstrap(settings$bootstrap, width, "width: %s;")
if (indent > 0) {
settings$bootstrap <- paste(settings$bootstrap, sprintf("padding-left: %sem;", indent), sep = "")
}

# unique IDs for each CSS style combination
id <- sapply(unique(settings$bootstrap), function(k) get_id(stem = "tinytable_css_"))
Expand Down
4 changes: 4 additions & 0 deletions inst/tinytest/test-html.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ tab <- tt(iris[1:10,]) |>
group_tt(j = list("Sepal" = 1:2, "Petal" = 3:4))
expect_equal_to_reference(clean(tab), "_tinysnapshot/html-issue58.rds")

# Issue #88: indent
tab <- tt(iris[1:10,]) |>
style_tt(i = 2:4, indent = 3)
expect_equal_to_reference(clean(tab), "_tinysnapshot/html-issue88.rds")

# tutorial.qmd: heatmap
k <- data.frame(matrix(1:20, ncol = 5))
Expand Down

0 comments on commit 0344545

Please sign in to comment.