Skip to content

Commit

Permalink
tests and bootstrap bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jan 17, 2024
1 parent 4780b56 commit 3df02c0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/style_bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ style_bootstrap <- function(x,
css_start <- sprintf(".table td.%s, th.%s { ", settings$id[row], settings$id[row])
css_complete <- paste(c(css_start, paste0(settings$bootstrap[row], collapse="; "), "}"), collapse = " ")
# hack: avoid css duplication
if (css_complete %in% css_done) {
if (!css_complete %in% css_done) {
out <- bootstrap_setting(out, css_complete, component = "css")
css_done <- c(css_done, css_complete)
}
Expand Down
6 changes: 5 additions & 1 deletion R/style_tabularray.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ style_tabularray <- function(x,

# hex must be treated differently in LaTeX
cols <- c(color, background)
cols_done <- NULL
if (!is.null(cols)) {
hex <- cols[grepl("^#", cols)]
for (h in hex) {
b <- sprintf(
"\\tinytableDefineColor{%s}{HTML}{%s}",
sub("^#", "c", h), sub("^#", "", h))
out <- tabularray_insert(out, content = b, type = "body")
if (!b %in% cols_done) {
out <- tabularray_insert(out, content = b, type = "body")
cols_done <- c(cols_done, b)
}
}
}
if (!is.null(background)) {
Expand Down
7 changes: 6 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ meta <- function(x, get, set) {
# some rows may be added, which changes how the style is applied
eval_style <- function(x) {
out <- x
m <- meta(x)

for (l in meta(x)$lazy_style) {
for (l in m$lazy_style) {
l[["x"]] <- out
out <- eval(eval(l))
}

m <- meta(x)
m$lazy_style <- list()
attr(out, "tinytable_meta") <- m

return(out)
}
2 changes: 1 addition & 1 deletion vignettes/tutorial.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ bg <- hcl.colors(20, "Inferno")
fg <- ifelse(as.matrix(k) < 17, tail(bg, 1), head(bg, 1))
fs <- 1:20
tt(k, width = .5, theme = "void") |>
tt(k, width = .5, theme = "void", align = "ccccc") |>
style_tt(
i = 1:4,
j = 1:5,
Expand Down

0 comments on commit 3df02c0

Please sign in to comment.