-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve unsupported features docs (#192)
* docs: add upload ad download buttons examples * chore: add shinyjs to Suggests for examples to run * fix: show only uploaded file name * fix: don't run examples during package check * chore: build docs * fix: typing * chore: build docs * fix: missing ns --------- Co-authored-by: Jakub Sobolewski <jakub.sobolewski@appsilon.com>
- Loading branch information
Showing
8 changed files
with
204 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ Suggests: | |
rmarkdown, | ||
sass, | ||
shiny.router, | ||
shinyjs, | ||
sortable, | ||
stringi, | ||
testthat (>= 3.0.0), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
# Example 3 | ||
library(shiny) | ||
library(shiny.fluent) | ||
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 <- 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(ns("file_path")) | ||
) | ||
} | ||
|
||
server <- function(id) { | ||
moduleServer(id, function(input, output, session) { | ||
observeEvent(input$uploadFileButton, { | ||
click("uploadFile") | ||
}) | ||
|
||
output$file_path <- renderText({ | ||
input$uploadFile$name | ||
}) | ||
}) | ||
} | ||
|
||
if (interactive()) { | ||
shinyApp(ui("app"), function(input, output) server("app")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
# Example 4 | ||
library(shiny) | ||
library(shiny.fluent) | ||
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 download. | ||
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(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) | ||
} | ||
) | ||
}) | ||
} | ||
|
||
if (interactive()) { | ||
shinyApp(ui("app"), function(input, output) server("app")) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.