A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/r4ds/scenes below:

shinyworks/scenes: Switch Between Alternative 'shiny' UIs

scenes

The goal of {scenes} is to make it easy to switch a {shiny} app between alternative UIs. It was designed to abstract the login-wrapper concept implemented in {shinyslack}.

Install the released version of {scenes} from CRAN:

install.packages("scenes")

Or install the development version of scenes from GitHub with:

# install.packages("remotes")
remotes::install_github("shinyworks/scenes")

You can see a demonstration of {scenes} here.

Some examples of how you might use {scenes} to switch between different UIs in a Shiny app:

The Login Wrapper example might look like this:

library(shiny)
library(scenes)

# Define the different scenes for the app
login_ui <- fluidPage(
  textInput("username", "Username"),
  passwordInput("password", "Password"),
  actionButton("login", "Login")
)

main_ui <- fluidPage(
  h1("Welcome"),
  textOutput("username")
)

# Use the `set_scene()` function to define the different scenes, and
# `change_scene()` to switch between them.
ui <- change_scene(
  set_scene(
    main_ui,
    req_has_cookie(
      "validate_login",
      validation_fn = my_validation_fn
    )
  ),
  fall_through = login_ui
)

server <- function(input, output, session) {
  observeEvent(input$login, {
    use_cookies_package_to_save_cookie_fn(input$username, input$password)
  })

  output$username <- renderText({
    input$username
  })
}

shinyApp(ui = ui, server = server)

See {shinyslack} for a fully implemented example.

Other packages have implemented features in this domain.

Please note that the scenes project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4