Learn R Programming

shinyMobile (version 0.7.0)

f7Panel: Create a Framework7 panel

Description

Build a Framework7 panel

Usage

f7Panel(
  ...,
  inputId = NULL,
  title = NULL,
  side = c("left", "right"),
  theme = c("dark", "light"),
  effect = c("reveal", "cover"),
  resizable = FALSE
)

Arguments

...

Panel content. Slot for f7PanelMenu, if used as a sidebar.

inputId

Panel unique id. This is to access the input$id giving the panel state, namely open or closed.

title

Panel title.

side

Panel side: "left" or "right".

theme

Panel background color: "dark" or "light".

effect

Whether the panel should behave when opened: "cover" or "reveal".

resizable

Whether to enable panel resize. FALSE by default.

Examples

Run this code
# NOT RUN {
if (interactive()) {
 library(shiny)
 library(shinyMobile)
 shiny::shinyApp(
   ui = f7Page(
     title = "My app",
     init = f7Init(skin = "ios", theme = "light"),
     f7SingleLayout(
       navbar = f7Navbar(
         title = "Single Layout",
         hairline = FALSE,
         shadow = TRUE,
         left_panel = TRUE,
         right_panel = TRUE
       ),
       panels = tagList(
         f7Panel(side = "left", inputId = "mypanel1"),
         f7Panel(side = "right", inputId = "mypanel2")
       ),
       toolbar = f7Toolbar(
         position = "bottom",
         icons = TRUE,
         hairline = FALSE,
         shadow = FALSE,
         f7Link(label = "Link 1", src = "https://www.google.com"),
         f7Link(label = "Link 2", src = "https://www.google.com", external = TRUE)
       ),
       # main content
       f7Shadow(
         intensity = 10,
         hover = TRUE,
         f7Card(
           title = "Card header",
           sliderInput("obs", "Number of observations", 0, 1000, 500),
           h1("You only see me by opening the left panel"),
           plotOutput("distPlot"),
           footer = tagList(
             f7Button(color = "blue", label = "My button", src = "https://www.google.com"),
             f7Badge("Badge", color = "green")
           )
         )
       )
     )
   ),
   server = function(input, output, session) {

     observeEvent(input$mypanel2, {

       state <- if (input$mypanel2) "open" else "closed"

       f7Toast(
         session,
         text = paste0("Right panel is ", state),
         position = "center",
         closeTimeout = 1000,
         closeButton = FALSE
       )
     })

     output$distPlot <- renderPlot({
       if (input$mypanel1) {
         dist <- rnorm(input$obs)
         hist(dist)
       }
     })
   }
 )
}
# }

Run the code above in your browser using DataLab