Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
24 changes: 20 additions & 4 deletions R/card.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#' together into one `wrapper` call (e.g. given `card("a", "b",
#' card_body("c"), "d")`, `wrapper` would be called twice, once with `"a"` and
#' `"b"` and once with `"d"`).
#' @param id Provide a unique identifier for the `card()` or `value_box()` to
#' report its state to Shiny. For example, using `id = "my_card"`, you can
#' observe the card's full screen state with `input$my_card$full_screen`.
#'
#' @return A [htmltools::div()] tag.
#'
Expand Down Expand Up @@ -70,21 +73,34 @@
#' )
#' )
#'
card <- function(..., full_screen = FALSE, height = NULL, max_height = NULL, min_height = NULL, fill = TRUE, class = NULL, wrapper = card_body) {

card <- function(
...,
full_screen = FALSE,
height = NULL,
max_height = NULL,
min_height = NULL,
fill = TRUE,
class = NULL,
wrapper = card_body,
id = NULL
) {
args <- rlang::list2(...)
argnames <- rlang::names2(args)

attribs <- args[nzchar(argnames)]
children <- as_card_items(args[!nzchar(argnames)], wrapper = wrapper)

if (full_screen && is.null(attribs$id)) {
is_shiny_input <- !is.null(id)

if (full_screen && is.null(id)) {
# a11y: full screen cards need an ID for aria-controls on the toggle button
attribs$id <- paste0("bslib-card-", p_randomInt(1000, 10000))
id <- paste0("bslib-card-", p_randomInt(1000, 10000))
}

tag <- div(
id = id,
class = "card bslib-card bslib-mb-spacing",
class = if (is_shiny_input) "bslib-card-input",
style = css(
height = validateCssUnit(height),
max_height = validateCssUnit(max_height),
Expand Down
2 changes: 2 additions & 0 deletions R/value-box.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ value_box <- function(
max_height = NULL,
fill = TRUE,
class = NULL,
id = NULL,
theme_color = deprecated()
) {
dots <- separate_arguments(...)
Expand Down Expand Up @@ -158,6 +159,7 @@ value_box <- function(
class,
if (!is.null(showcase)) showcase_layout$class
),
id = id,
full_screen = full_screen,
height = height,
max_height = max_height,
Expand Down
43 changes: 33 additions & 10 deletions inst/components/dist/components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions inst/components/dist/components.js.map

Large diffs are not rendered by default.

Loading