From db8d0c7f6abd700d3b4cbdc2d13e34c3002d1aa1 Mon Sep 17 00:00:00 2001 From: Veerle van Leemput Date: Sun, 28 Apr 2024 11:46:41 +0200 Subject: [PATCH] allow color to be passed as name --- R/update-app.R | 8 ++++++++ vignettes/update-app.Rmd | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/R/update-app.R b/R/update-app.R index bbe5d0b9..1870e0a7 100644 --- a/R/update-app.R +++ b/R/update-app.R @@ -15,6 +15,14 @@ #' #' @export updateF7App <- function(options, session = shiny::getDefaultReactiveDomain()) { + + # if color in options, convert color to hex + if (!is.null(options$color)) { + if (options$color %in% getF7Colors()) { + options$color <- colorToHex(options$color) + } + } + sendCustomMessage("update-app", options, session) } diff --git a/vignettes/update-app.Rmd b/vignettes/update-app.Rmd index 5272b6a2..6eaa5ffa 100644 --- a/vignettes/update-app.Rmd +++ b/vignettes/update-app.Rmd @@ -143,9 +143,10 @@ shinyApp( } ) ``` -TODO: shinylive example -Note that the given `color` should be a valid hexadecimal color. You can call `updateF7App` multiple times, and the app will update the given configuration settings accordingly. +Note that the color can both be a color of `getF7Colors()` (like "primary", "pink" or "teal") or a hexadecimal color. You can call `updateF7App` multiple times, and the app will update the given configuration settings accordingly. + +TODO: shinylive example ### Updating component configuration