From 3d8548d933f2cdeb250f3577b44f9162201b1040 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Mon, 6 Mar 2023 14:04:19 -0500 Subject: [PATCH 01/97] Rename filter controls with `filter_` prefix I think it's a little easier to understand, especially if you were to drop into an example halfway through the article --- vignettes/sidebar-create-contents.R | 6 ++--- vignettes/sidebars.Rmd | 34 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/vignettes/sidebar-create-contents.R b/vignettes/sidebar-create-contents.R index 97f995cb1..950eba27c 100644 --- a/vignettes/sidebar-create-contents.R +++ b/vignettes/sidebar-create-contents.R @@ -8,9 +8,9 @@ library(plotly) dat <- SharedData$new(dplyr::sample_n(diamonds, 1000)) # Sidebar elements (e.g., filter controls) -cut <- filter_select("cut", "Cut", dat, ~cut) -clarity <- filter_select("clarity", "Clarity", dat, ~clarity) -color <- filter_select("color", "Color", dat, ~color) +filter_cut <- filter_select("cut", "Cut", dat, ~cut) +filter_color <- filter_select("color", "Color", dat, ~color) +filter_clarity <- filter_select("clarity", "Clarity", dat, ~clarity) # Main elements (e.g., plots) plot_price <- plot_ly(dat, x = ~price) diff --git a/vignettes/sidebars.Rmd b/vignettes/sidebars.Rmd index 23d800b6a..b53c4037a 100644 --- a/vignettes/sidebars.Rmd +++ b/vignettes/sidebars.Rmd @@ -107,7 +107,7 @@ To show the same `sidebar()` on every page (i.e., create a "global" sidebar), pa ```{r navbar-global, render=render_as_iframe, out.width="100%", out.extra='height=600px scrolling="no" seamless="seamless" frameBorder="0"'} page_navbar( title = "Global sidebar", - sidebar = sidebar(cut, clarity), + sidebar = sidebar(filter_cut, filter_clarity), nav("Page 1", plot_price, plot_carat), nav("Page 2", plot_depth) ) @@ -120,7 +120,7 @@ With a global sidebar, the `fillable` argument controls whether the _main conten ```{r navbar-global-fillable, render=render_as_iframe, out.width="100%", out.extra='height=600px scrolling="no" seamless="seamless" frameBorder="0"'} page_navbar( title = "Global sidebar w/ fill", - sidebar = sidebar(cut, clarity), + sidebar = sidebar(filter_cut, filter_clarity), fillable = TRUE, nav("Page 1", plot_price, plot_carat), nav("Page 2", plot_depth) @@ -138,10 +138,10 @@ shinyApp( page_navbar( title = "Dynamic sidebar", sidebar = sidebar( - cut, clarity, + filter_cut, filter_clarity, conditionalPanel( "input.nav === 'Page 2'", - color + filter_color ) ), id = "nav", @@ -172,7 +172,7 @@ page_navbar( nav( "Page 1", layout_sidebar( - sidebar(cut, clarity, width = 175), + sidebar(filter_cut, filter_clarity, width = 175), plot_price ), br(), @@ -196,7 +196,7 @@ page_navbar( layout_sidebar( fillable = TRUE, border = FALSE, - sidebar(cut, clarity), + sidebar(filter_cut, filter_clarity), plot_price ) ), @@ -220,7 +220,7 @@ page_fixed( h1("My scrolling page", class = "lead fs-2 my-3"), layout_sidebar( height = 325, - sidebar(cut, clarity), + sidebar(filter_cut, filter_clarity), "Scroll down for another plot πŸ‘‡", plot_price, plot_carat ), @@ -228,7 +228,7 @@ page_fixed( layout_sidebar( height = 350, fillable = TRUE, - sidebar(color, position = "right"), + sidebar(filter_color, position = "right"), "No scrolling here", plot_price, plot_carat ), @@ -256,7 +256,7 @@ page_fill( layout_sidebar( border = FALSE, border_radius = FALSE, - sidebar(cut, clarity), + sidebar(filter_cut, filter_clarity), "Scroll down for another plot πŸ‘‡", plot_price, plot_carat ) @@ -278,7 +278,7 @@ card( full_screen = TRUE, card_header("Filter diamond price by cut and clarity"), card_sidebar( - sidebar(cut, clarity, open = FALSE), + sidebar(filter_cut, filter_clarity, open = FALSE), plot_price, fillable = TRUE ) @@ -307,7 +307,7 @@ Remember that, just like `layout_sidebar()` and `card()`, `navs_tab_card()` size ```{r} navs_tab_card( title = "Global sidebar", - sidebar = sidebar(cut, clarity), + sidebar = sidebar(filter_cut, filter_clarity), height = 450, full_screen = TRUE, wrapper = card_body_fill, @@ -324,10 +324,10 @@ Sometimes it's helpful to have the sidebar controls change depending on what pag dynamic <- navs_tab_card( title = "Dynamic sidebar", sidebar = sidebar( - cut, clarity, + filter_cut, filter_clarity, conditionalPanel( "input.nav === 'Page 2'", - color + filter_color ) ), id = "nav", @@ -363,7 +363,7 @@ navs_tab_card( nav( "Tab 1", card_sidebar( - sidebar(cut, clarity), + sidebar(filter_cut, filter_clarity), plot_price, fillable = TRUE ) @@ -388,7 +388,7 @@ library(shiny) ui <- page_navbar( title = "Sidebar example", id = "nav", - sidebar = sidebar(id = "sidebar", cut, clarity), + sidebar = sidebar(id = "sidebar", filter_cut, filter_clarity), nav("Page 1", plot_price), nav("Page 2", plot_carat, plot_depth) ) @@ -443,9 +443,9 @@ page_fill( "Left and right sidebar" ), layout_sidebar( - sidebar(cut, clarity), + sidebar(filter_cut, filter_clarity), layout_sidebar( - sidebar(color, position = "right", open = FALSE), + sidebar(filter_color, position = "right", open = FALSE), plot_price, border = FALSE ), From 21efc6c0f2eaa165e0daad2cdaf480d506d96576 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Mon, 6 Mar 2023 14:04:52 -0500 Subject: [PATCH 02/97] remove trailing invisible space --- vignettes/sidebars.Rmd | 60 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/vignettes/sidebars.Rmd b/vignettes/sidebars.Rmd index b53c4037a..449673015 100644 --- a/vignettes/sidebars.Rmd +++ b/vignettes/sidebars.Rmd @@ -25,7 +25,7 @@ render_as_iframe <- function(x, options, ...) { file <- file.path(lbl, paste0(lbl, ".html")) x <- tagList(x, tags$head(tags$style(".plotly { height: 250px !important; } .modebar-container { display: none; }"))) tryCatch( - save_html(x, file), + save_html(x, file), error = function(e) { stop("Don't know how to render ", class(x)[[1]], " as an