inst/examples/01-simple/app.R

### ----------------------------------------------------------------- ###
### An example written by pure Shiny ----
### ----------------------------------------------------------------- ###

library(shiny)
library(shinyNotes)

### Initialize shinyNotes
#set_notes_folder_path(folder.path = tempdir())
create_notes_folder()

ui <- fluidPage(
  tabsetPanel(
    tabPanel("Notes", 
             tableOutput("notes_tbl")
    ),
    tabPanel("New note",
             icon = icon("plus-circle"),
             textInput("title", label = "Title", value = ""),
             textAreaInput("body", label = "Note", value = "", height = "100px"),
             actionButton("save", "Save")
    )
  )
)

server <- function(input, output, session) {
  
  list <- reactive({
    shinyNotes:::notes_as_data_frame()
  })
  output$notes_tbl <- renderTable({
    list()
  })
  
  title <- reactive({input$title})
  body <- reactive({input$body})
    
  observeEvent(input$save, {
    new_note(
      title = title(),
      content = body()
    )
  })
  
}

shinyApp(ui, server)
strboul/shinyNotes documentation built on June 2, 2019, 10:56 p.m.