rstudio / bslib

Tools for theming Shiny and R Markdown via Bootstrap 3, 4, or 5.
https://rstudio.github.io/bslib/
Other
443 stars 50 forks source link

feat(card): Report full screen state as a Shiny input #1006

Closed gadenbuie closed 4 months ago

gadenbuie commented 4 months ago

Closes #962

When card() is given an id, e.g. card(id = "my_card"), the full screen state of the card is now reported as input$my_card$full_screen.

Note: this PR builds on #1005 but could be rebased on main to decouple.

Example

library(shiny)
# library(bslib)
pkgload::load_all()

ui <- page_fixed(
  card(
    card_header("Hello card!"),
    "A regular full-screenable card.",
    id = "my_card",
    full_screen = TRUE
  ),
  value_box(
    title = "Hello value box!",
    value = "$1,234,567",
    id = "my_value_box",
    full_screen = TRUE
  ),
  div(
    verbatimTextOutput("debug"),
    style = htmltools::css(
      z_index = 9999,
      position = "absolute",
      bottom = "2rem",
      left = "2rem",
      right = "2rem"
    )
  )
)

server <- function(input, output, session) {
  output$debug <- renderPrint({
    str(
      list(
        my_card = input$my_card,
        my_value_box = input$my_value_box
      )
    )
  })
}

shinyApp(ui, server)
cpsievert commented 4 months ago

Note: this PR builds on https://github.com/rstudio/bslib/pull/1005 but could be rebased on main to decouple.

Please do rebase off main as I have more reservations about that PR.