Skip to content

Latest commit

 

History

History
94 lines (71 loc) · 2.24 KB

README.md

File metadata and controls

94 lines (71 loc) · 2.24 KB

Task 1

Step 1

Use rhino::init() to create a new Rhino app in task1 directory.

Step 2

  • Enable automatic reloading with shiny::devmode().
  • Run the app with shiny::runApp().
  • Edit the displayed message in app/main.R and see how the app automatically reloads.

Step 3

Copy over the following code to main.R:

box::use(
  shiny,
  shiny.fluent[...],
)

#' @export
ui = function(id) {
  ns <- shiny$NS(id)
  shiny$tagList(
    ColorPicker.shinyInput(ns("color"), value="#0000FF"),
    shiny$verbatimTextOutput(ns("text")))
}

#' @export
server <- function(id) {
  shiny$moduleServer(id, function(input, output, session) {
    output$text <- shiny$renderText({
      paste("Color:", input$color)
    })
  })
}

Install the missing dependencies with rhino::pkg_install() and run the app.

Step 4

Step 5

Rename main.R to app.R and copy over the following code:

library(shiny)
library(shiny.fluent)

ui <- div(
  Calendar.shinyInput("date"),
  verbatimTextOutput("text"),
)

server <- function(input, output, session) {
  output$text <- renderText({
    paste("Date:", input$date)
  })
}

shinyApp(ui = ui, server = server)

Set legacy_entrypoint: app_dir in rhino.yml and rerun the app.

Step 6

  • Rename app/app.R back to app/main.R.
  • Remove the shinyApp(ui = ui, server = server) line.
  • Set legacy_entrypoint: source and rerun the app.

Step 7

  • Replace library() calls with box::use().
  • Set legacy_entrypoint: box_top_level and rerun the app.

Step 8

  • Modify the ui and server to make them into a Shiny module.
  • Remove the legacy_entrypoint setting and rerun the app.