Skip to content

Commit

Permalink
Merge pull request #1868 from olivroy/refactor-misc
Browse files Browse the repository at this point in the history
Improve access to option values + use htmltools to create some css code
  • Loading branch information
rich-iannone authored Sep 3, 2024
2 parents 86c8741 + b16093f commit 340f5d7
Show file tree
Hide file tree
Showing 22 changed files with 1,900 additions and 1,865 deletions.
18 changes: 18 additions & 0 deletions R/dt_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ dt_options_get_value <- function(data, option) {
dt_options$value[[which(dt_options$parameter == option)]]
}

# Get a list of option values
dt_options_get_values <- function(data) {
dt_options <- dt_options_get(data = data)[c("parameter", "value")]
# Similar to tibble::deframe
res <- vctrs::vec_set_names(dt_options$value, dt_options$parameter)
class(res) <- c("gt_option", class(res))
res
}

#' @export
`$.gt_option` <- function(x, name) {
out <- .subset2(x, name)
if (is.null(out)) {
cli::cli_abort("Can't find option {.val {name}}.")
}
out
}

default_fonts_vec <-
c(
"system-ui", "Segoe UI", "Roboto", "Helvetica", "Arial", "sans-serif",
Expand Down
Loading

0 comments on commit 340f5d7

Please sign in to comment.