Skip to content

Commit

Permalink
fix: don't run examples during package check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Sobolewski committed Jun 30, 2023
1 parent 68531d9 commit f354274
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 56 deletions.
71 changes: 39 additions & 32 deletions inst/examples/Button3.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,48 @@ library(shinyjs)
# This example app shows how to use a Fluent UI Button to trigger a file upload.
# File upload is not natively supported by shiny.fluent, so shinyjs is used
# to trigger the file upload input.
ui <- fluentPage(
useShinyjs(),
Stack(
tokens = list(
childrenGap = 10L
),
horizontal = TRUE,
DefaultButton.shinyInput(
inputId = "uploadFileButton",
text = "Upload File",
iconProps = list(iconName = "Upload")
),
div(
style = "
visibility: hidden;
height: 0;
width: 0;
",
fileInput(
inputId = "uploadFile",
label = NULL
ui <- function(id) {
ns <- NS(id)
fluentPage(
useShinyjs(),
Stack(
tokens = list(
childrenGap = 10L
),
horizontal = TRUE,
DefaultButton.shinyInput(
inputId = ns("uploadFileButton"),
text = "Upload File",
iconProps = list(iconName = "Upload")
),
div(
style = "
visibility: hidden;
height: 0;
width: 0;
",
fileInput(
inputId = ns("uploadFile"),
label = NULL
)
)
)
),
textOutput("file_path")
)
),
textOutput("file_path")
)
}

server <- function(input, output) {
observeEvent(input$uploadFileButton, {
click("uploadFile")
})
server <- function(id) {
moduleServer(id, function(input, output, session) {
observeEvent(input$uploadFileButton, {
click("uploadFile")
})

output$file_path <- renderText({
input$uploadFile$name
output$file_path <- renderText({
input$uploadFile$name
})
})
}

shinyApp(ui, server)
if (interactive()) {
shinyApp(ui("app"), function(input, output) server("app"))
}
55 changes: 31 additions & 24 deletions inst/examples/Button4.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,39 @@ library(shinyjs)
# This example app shows how to use a Fluent UI Button to trigger a file download.
# File download is not natively supported by shiny.fluent, so shinyjs is used
# to trigger the file upload input.
ui <- fluentPage(
useShinyjs(),
DefaultButton.shinyInput(
"downloadButton",
text = "Download",
iconProps = list(iconName = "Download")
),
div(
style = "visibility: hidden;",
downloadButton("download", label = "")
ui <- function(id) {
ns <- NS(id)
fluentPage(
useShinyjs(),
DefaultButton.shinyInput(
inputId = ns("downloadButton"),
text = "Download",
iconProps = list(iconName = "Download")
),
div(
style = "visibility: hidden;",
downloadButton(ns("download"), label = "")
)
)
)
}

server <- function(input, output, session) {
observeEvent(input$downloadButton, {
click("download")
})
server <- function(id) {
moduleServer(id, function(input, output, session) {
observeEvent(input$downloadButton, {
click("download")
})

output$download <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
write.csv(iris, file)
}
)
output$download <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
write.csv(iris, file)
}
)
})
}

shinyApp(ui, server)
if (interactive()) {
shinyApp(ui("app"), function(input, output) server("app"))
}

0 comments on commit f354274

Please sign in to comment.