SmaRPanel: SmaRPanel

View source: R/SmaRPanel.R

SmaRPanelR Documentation

SmaRPanel

Description

Custom collapsible panel for the SmaRP Shiny app.

Usage

SmaRPanel(id, ..., title = NULL, collapsed = NA)

Arguments

id

The unique id of the panel.

...

UI elements to be displayed in the panel body.

title

The title to be displayed in the panel heading.

collapsed

Whether the panel should be created as collapsed or expanded. If NA (the default), a non-collapsible panel is created.

Details

All elements of the panel are specified with additional classes "panel-smarp", "panel-heading-smarp", "panel-title-smarp", "panel-body-smarp", used for CSS customization. Similarly, the collapse actionButton() is defined with no label nor icon and has a custom class "btn-collapse-smarp", to be used for CSS customization via the :after pseudo-element.

Value

The UI definition of the panel.

Examples

if (interactive()) {
  library(shiny)
  long_title <- "Lorem ipsum dolor sit amet, consectetur adipisicing elit."
  ui <- fluidPage(
    tags$head(
      includeCSS(system.file("application/www/style.css", package = "SmaRP"))
    ),
    titlePanel("SmaRPanel"),
    icon("cog"),
    fluidRow(
      column(2L, SmaRPanel(
        id = "simple-panel", title = long_title,
        verticalLayout(textInput("a", "A"), textInput("b", "B"))
      )),
      column(2L, SmaRPanel(
        id = "collapsed-panel", title = long_title,
        verticalLayout(textInput("a", "A"), textInput("b", "B")),
        collapsed = FALSE
      )),
      column(2L, SmaRPanel(
        id = "expanded-panel", title = long_title,
        verticalLayout(textInput("a", "A"), textInput("b", "B")),
        collapsed = TRUE
      )),
      column(2L, SmaRPanel(
        id = "no-title-panel",
        verticalLayout(textInput("a", "A"), textInput("b", "B"))
      )),
      column(2L, SmaRPanel(
        id = "no-title-expanded-panel",
        verticalLayout(textInput("a", "A"), textInput("b", "B")),
        collapsed = FALSE
      ))
    )
  )
  server <- function(input, output) {}
  runApp(shinyApp(ui = ui, server = server), launch.browser = TRUE)
}

miraisolutions/SmaRP documentation built on March 23, 2022, 6:46 a.m.