From 355a94ced16e23d9bb0ee5a9b2accbf7fc8e08e4 Mon Sep 17 00:00:00 2001 From: DivadNojnarg Date: Sun, 24 Mar 2024 00:31:42 +0100 Subject: [PATCH] tiny update: f7Toggle example --- R/f7-inputs.R | 40 +--------------------------- R/f7Skeleton.R | 68 ++++++++++++++++++++++------------------------- man/f7Skeleton.Rd | 62 +++++++++++++++++++++--------------------- man/toggle.Rd | 37 +++----------------------- 4 files changed, 66 insertions(+), 141 deletions(-) diff --git a/R/f7-inputs.R b/R/f7-inputs.R index 033a0898..3c2636c7 100644 --- a/R/f7-inputs.R +++ b/R/f7-inputs.R @@ -2320,38 +2320,6 @@ updateF7Stepper <- function(inputId, min = NULL, max = NULL, #' "teal, "lime", "deeporange", "gray", "white", "black". #' #' @rdname toggle -#' @examples -#' # f7Toggle -#' if (interactive()) { -#' library(shiny) -#' library(shinyMobile) -#' -#' shinyApp( -#' ui = f7Page( -#' title = "My app", -#' f7SingleLayout( -#' navbar = f7Navbar(title = "f7Toggle"), -#' f7Toggle( -#' inputId = "toggle", -#' label = "My toggle", -#' color = "pink", -#' checked = TRUE -#' ), -#' verbatimTextOutput("test"), -#' f7Toggle( -#' inputId = "toggle2", -#' label = "My toggle 2" -#' ), -#' verbatimTextOutput("test2") -#' ) -#' ), -#' server = function(input, output) { -#' output$test <- renderPrint(input$toggle) -#' output$test2 <- renderPrint(input$toggle2) -#' } -#' ) -#' } -#' # #' @export f7Toggle <- function(inputId, label, checked = FALSE, color = NULL) { toggleCl <- "toggle" @@ -2378,12 +2346,6 @@ f7Toggle <- function(inputId, label, checked = FALSE, color = NULL) { #' #' \code{updateF7Toggle} changes the value of a toggle input on the client. #' -#' @param inputId The id of the input object. -#' @param checked Whether the toggle is TRUE or FALSE. -#' @param color -#' Toggle color: NULL or "primary", "red", "green", "blue", -#' "pink", "yellow", "orange", "purple", "deeppurple", "lightblue", -#' "teal, "lime", "deeporange", "gray", "white", "black". #' @param session The Shiny session object. #' #' @export @@ -2420,7 +2382,7 @@ f7Toggle <- function(inputId, label, checked = FALSE, color = NULL) { #' observeEvent(input$update, { #' updateF7Toggle( #' inputId = "toggle", -#' checked = TRUE, +#' checked = !input$toggle, #' color = "green" #' ) #' }) diff --git a/R/f7Skeleton.R b/R/f7Skeleton.R index c02b5060..cf17fa5b 100644 --- a/R/f7Skeleton.R +++ b/R/f7Skeleton.R @@ -16,53 +16,49 @@ #' #' @examples #' if (interactive()) { -#' library(shiny) -#' library(shinyMobile) +#' library(shiny) +#' library(shinyMobile) #' -#' shinyApp( -#' ui = f7Page( -#' title = "Skeletons", -#' f7SingleLayout( -#' navbar = f7Navbar(title = "f7Skeleton"), -#' f7Card( -#' title = "Card header", -#' "This is a simple card with plain text, +#' shinyApp( +#' ui = f7Page( +#' title = "Skeletons", +#' f7SingleLayout( +#' navbar = f7Navbar(title = "f7Skeleton"), +#' f7Card( +#' title = "Card header", +#' "This is a simple card with plain text, #' but cards can also contain their own header, #' footer, list view, image, or any other element.", -#' footer = tagList( -#' f7Button(color = "blue", label = "My button", href = "https://www.google.com"), -#' f7Badge("Badge", color = "green") -#' ) -#' ), -#' +#' ), #' f7List( -#' f7ListItem( -#' href = "https://www.google.com", -#' title = "Item 1" -#' ), -#' f7ListItem( -#' href = "https://www.google.com", -#' title = "Item 2" -#' ) +#' f7ListItem( +#' href = "https://www.google.com", +#' title = "Item 1" +#' ), +#' f7ListItem( +#' href = "https://www.google.com", +#' title = "Item 2" +#' ) #' ) -#' ) -#' ), -#' server = function(input, output, session) { -#' observeEvent(TRUE, { -#' f7Skeleton(".card", "fade", 2) -#' }, once = TRUE) -#' } -#' ) +#' ) +#' ), +#' server = function(input, output, session) { +#' observeEvent(TRUE, +#' { +#' f7Skeleton(".card", "fade", 2) +#' }, +#' once = TRUE +#' ) +#' } +#' ) #' } f7Skeleton <- function( target = ".card", effect = c("fade", "blink", "pulse"), duration = NULL, - session = shiny::getDefaultReactiveDomain() -) { - + session = shiny::getDefaultReactiveDomain()) { effect <- match.arg(effect) - message <-dropNulls( + message <- dropNulls( list( target = target, effect = effect, diff --git a/man/f7Skeleton.Rd b/man/f7Skeleton.Rd index 86964b76..89784a4c 100644 --- a/man/f7Skeleton.Rd +++ b/man/f7Skeleton.Rd @@ -30,42 +30,40 @@ Nice loading overlay for UI elements. } \examples{ if (interactive()) { - library(shiny) - library(shinyMobile) + library(shiny) + library(shinyMobile) - shinyApp( - ui = f7Page( - title = "Skeletons", - f7SingleLayout( - navbar = f7Navbar(title = "f7Skeleton"), - f7Card( - title = "Card header", - "This is a simple card with plain text, + shinyApp( + ui = f7Page( + title = "Skeletons", + f7SingleLayout( + navbar = f7Navbar(title = "f7Skeleton"), + f7Card( + title = "Card header", + "This is a simple card with plain text, but cards can also contain their own header, footer, list view, image, or any other element.", - footer = tagList( - f7Button(color = "blue", label = "My button", href = "https://www.google.com"), - f7Badge("Badge", color = "green") - ) - ), - + ), f7List( - f7ListItem( - href = "https://www.google.com", - title = "Item 1" - ), - f7ListItem( - href = "https://www.google.com", - title = "Item 2" - ) + f7ListItem( + href = "https://www.google.com", + title = "Item 1" + ), + f7ListItem( + href = "https://www.google.com", + title = "Item 2" + ) ) - ) - ), - server = function(input, output, session) { - observeEvent(TRUE, { - f7Skeleton(".card", "fade", 2) - }, once = TRUE) - } - ) + ) + ), + server = function(input, output, session) { + observeEvent(TRUE, + { + f7Skeleton(".card", "fade", 2) + }, + once = TRUE + ) + } + ) } } diff --git a/man/toggle.Rd b/man/toggle.Rd index 2e97f182..e9924bee 100644 --- a/man/toggle.Rd +++ b/man/toggle.Rd @@ -15,11 +15,11 @@ updateF7Toggle( ) } \arguments{ -\item{inputId}{The id of the input object.} +\item{inputId}{Toggle input id.} \item{label}{Toggle label.} -\item{checked}{Whether the toggle is TRUE or FALSE.} +\item{checked}{Whether to check the toggle. FALSE by default.} \item{color}{Toggle color: NULL or "primary", "red", "green", "blue", "pink", "yellow", "orange", "purple", "deeppurple", "lightblue", @@ -33,37 +33,6 @@ updateF7Toggle( \code{updateF7Toggle} changes the value of a toggle input on the client. } \examples{ -# f7Toggle -if (interactive()) { - library(shiny) - library(shinyMobile) - - shinyApp( - ui = f7Page( - title = "My app", - f7SingleLayout( - navbar = f7Navbar(title = "f7Toggle"), - f7Toggle( - inputId = "toggle", - label = "My toggle", - color = "pink", - checked = TRUE - ), - verbatimTextOutput("test"), - f7Toggle( - inputId = "toggle2", - label = "My toggle 2" - ), - verbatimTextOutput("test2") - ) - ), - server = function(input, output) { - output$test <- renderPrint(input$toggle) - output$test2 <- renderPrint(input$toggle2) - } - ) -} -# # Update f7Toggle if (interactive()) { library(shiny) @@ -94,7 +63,7 @@ if (interactive()) { observeEvent(input$update, { updateF7Toggle( inputId = "toggle", - checked = TRUE, + checked = !input$toggle, color = "green" ) })