|
| 1 | +library(shiny) |
| 2 | +library(bslib) |
| 3 | + |
| 4 | +ui <- page_fixed( |
| 5 | + h1("Dynamic Sidebars"), |
| 6 | + tags$head(tags$title("bslib | Tests | Dynamic Sidebars")), |
| 7 | + div(id = "neutral-focus-zone", tabindex = "-1"), |
| 8 | + layout_column_wrap( |
| 9 | + width = 1 / 2, |
| 10 | + card( |
| 11 | + id = "card-no-inputs", |
| 12 | + full_screen = TRUE, |
| 13 | + card_header("Nothing to focus on here"), |
| 14 | + shiny::p( |
| 15 | + "This is a boring card with just some plain text.", |
| 16 | + "There's something to read here but there aren't any inputs to focus on.", |
| 17 | + "Tabbing will only move focus to the \"Close\" button." |
| 18 | + ) |
| 19 | + ), |
| 20 | + card( |
| 21 | + id = "card-with-inputs", |
| 22 | + full_screen = TRUE, |
| 23 | + card_header("Inputs, oh my!"), |
| 24 | + shiny::p( |
| 25 | + "Here's a bit of text! This card does have stuff to focus on, and the", |
| 26 | + "first focusable element is automatically focused when the card is expanded.", |
| 27 | + "Try tabbing through the inputs, you can't leave!" |
| 28 | + ), |
| 29 | + layout_column_wrap( |
| 30 | + width = "200px", |
| 31 | + class = "mb-3", |
| 32 | + card( |
| 33 | + id = "card-with-inputs-left", |
| 34 | + full_screen = TRUE, |
| 35 | + card_title("Left Column", class = "mb-3"), |
| 36 | + shiny::selectInput("letter", "Letter", letters, selected = "a"), |
| 37 | + shiny::selectizeInput("letter2", "Letter 2", letters, selected = "b", multiple = TRUE), |
| 38 | + shiny::dateRangeInput("dates", "Pick a Date") |
| 39 | + ), |
| 40 | + card( |
| 41 | + id = "card-with-inputs-right", |
| 42 | + full_screen = TRUE, |
| 43 | + card_title("Right Column", class = "mb-3"), |
| 44 | + shiny::sliderInput("slider", "Pick a Number", min = 1, max = 10, value = 5), |
| 45 | + shiny::textInput("word", "Word", "hello"), |
| 46 | + shiny::textAreaInput("sentence", "Sentence", "hello world") |
| 47 | + ) |
| 48 | + ), |
| 49 | + shiny::actionButton("go", "Go") |
| 50 | + ), |
| 51 | + card( |
| 52 | + id = "card-with-plot", |
| 53 | + full_screen = TRUE, |
| 54 | + card_header("A plotly plot"), |
| 55 | + textInput("search", "Search", "search or something"), |
| 56 | + plotly::plot_ly(x = rnorm(1e4), y = rnorm(1e4)) |
| 57 | + ) |
| 58 | + ) |
| 59 | +) |
| 60 | + |
| 61 | +server <- function(input, output, session) { |
| 62 | + # no server logic |
| 63 | +} |
| 64 | + |
| 65 | +shinyApp(ui, server) |
0 commit comments