From 659d6ebdb946b2dde49f9b138f43b1ff20fe8b06 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Mar 2024 00:18:25 +0530 Subject: [PATCH] unify tags --- R/draggable_buckets.R | 12 +++++----- R/include_css_js.R | 2 +- R/nested_closeable_modal.R | 2 +- R/optionalInput.R | 16 ++++++------- R/panel_group.R | 2 +- R/plot_with_settings.R | 26 +++++++++++----------- R/standard_layout.R | 24 ++++++++++---------- R/table_with_settings.R | 10 ++++----- R/verbatim_popup.R | 6 ++--- man/nested_closeable_modal.Rd | 2 +- man/optionalSelectInput.Rd | 12 +++++----- man/plot_with_settings.Rd | 8 +++---- man/standard_layout.Rd | 4 ++-- tests/testthat/test-standard_layout.R | 2 +- vignettes/custom-basic-table-arguments.Rmd | 2 +- vignettes/custom-ggplot2-arguments.Rmd | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/R/draggable_buckets.R b/R/draggable_buckets.R index fc92fca6..86c4be7d 100644 --- a/R/draggable_buckets.R +++ b/R/draggable_buckets.R @@ -66,12 +66,12 @@ draggable_buckets <- function(input_id, label, elements = character(), buckets) elements_iterator$it <- 0 shiny::tagList( - shiny::singleton(shiny::tags$head( + shiny::singleton(tags$head( shiny::includeScript(system.file("widgets/draggable_buckets.js", package = "teal.widgets")) )), include_css_files("draggable_buckets.css"), shiny::div( - shiny::tags$span(label), + tags$span(label), render_unbucketed_elements(elements = elements, elements_iterator = elements_iterator, widget_id = input_id), render_buckets(buckets = buckets, elements_iterator = elements_iterator, widget_id = input_id), class = "draggableBuckets", @@ -81,7 +81,7 @@ draggable_buckets <- function(input_id, label, elements = character(), buckets) } render_unbucketed_elements <- function(elements, elements_iterator, widget_id) { - shiny::tags$div( + tags$div( lapply(elements, function(element) { elements_iterator$it <- elements_iterator$it + 1 render_draggable_element( @@ -115,7 +115,7 @@ render_buckets <- function(buckets, elements_iterator, widget_id) { } render_draggable_element <- function(value, id, widget_id) { - shiny::tags$div( + tags$div( value, id = id, class = "element", @@ -128,8 +128,8 @@ render_draggable_element <- function(value, id, widget_id) { } render_bucket <- function(name, elements = NULL, elements_iterator = NULL, widget_id = NULL) { - shiny::tags$div( - shiny::tags$div( + tags$div( + tags$div( paste0(name, ":"), class = "bucket-name", ondragover = "allowDrop(event)", diff --git a/R/include_css_js.R b/R/include_css_js.R index 98b22607..d59a5636 100644 --- a/R/include_css_js.R +++ b/R/include_css_js.R @@ -16,5 +16,5 @@ include_css_files <- function(pattern = "*") { if (length(css_files) == 0) { return(NULL) } - return(shiny::singleton(shiny::tags$head(lapply(css_files, shiny::includeCSS)))) + return(shiny::singleton(tags$head(lapply(css_files, shiny::includeCSS)))) } diff --git a/R/nested_closeable_modal.R b/R/nested_closeable_modal.R index 7a77d530..0c080189 100644 --- a/R/nested_closeable_modal.R +++ b/R/nested_closeable_modal.R @@ -49,7 +49,7 @@ #' footer = NULL, #' easyClose = TRUE #' ), -#' div( +#' tags$div( #' "This modal can be closed by running", tags$code("$('#modal_1').modal('hide')"), #' "in the JS console!", #' "Note that removing the parent will remove the child. diff --git a/R/optionalInput.R b/R/optionalInput.R index a38f45c2..135c4bf0 100644 --- a/R/optionalInput.R +++ b/R/optionalInput.R @@ -53,7 +53,7 @@ #' } #' #' ui <- ui_grid( -#' div( +#' tags$div( #' optionalSelectInput( #' inputId = "c1", #' label = "Fixed choices", @@ -63,7 +63,7 @@ #' ), #' verbatimTextOutput(outputId = "c1_out") #' ), -#' div( +#' tags$div( #' optionalSelectInput( #' inputId = "c2", #' label = "Single choice", @@ -72,7 +72,7 @@ #' ), #' verbatimTextOutput(outputId = "c2_out") #' ), -#' div( +#' tags$div( #' optionalSelectInput( #' inputId = "c3", #' label = "NULL choices", @@ -80,7 +80,7 @@ #' ), #' verbatimTextOutput(outputId = "c3_out") #' ), -#' div( +#' tags$div( #' optionalSelectInput( #' inputId = "c4", #' label = "Default", @@ -89,7 +89,7 @@ #' ), #' verbatimTextOutput(outputId = "c4_out") #' ), -#' div( +#' tags$div( #' optionalSelectInput( #' inputId = "c5", #' label = "Named vector", @@ -98,7 +98,7 @@ #' ), #' verbatimTextOutput(outputId = "c5_out") #' ), -#' div( +#' tags$div( #' selectInput( #' inputId = "c6_choices", label = "Update choices", choices = letters, multiple = TRUE #' ), @@ -243,7 +243,7 @@ optionalSelectInput <- function(inputId, # nolint label_help ) - div( + tags$div( include_css_files(pattern = "picker_input"), # when selected values in ui_picker change @@ -280,7 +280,7 @@ optionalSelectInput <- function(inputId, # nolint ) tags$script(js) }, - div(ui_picker, ui_fixed) + tags$div(ui_picker, ui_fixed) ) } diff --git a/R/panel_group.R b/R/panel_group.R index 0ff51d38..256c7e74 100644 --- a/R/panel_group.R +++ b/R/panel_group.R @@ -184,7 +184,7 @@ panel_item <- function(title, ..., collapsed = TRUE, input_id = NULL) { tagList( include_css_files(pattern = "panel.css"), - shiny::tags$head(shiny::includeScript(system.file("js/panel_group.js", package = "teal.widgets"))), + tags$head(shiny::includeScript(system.file("js/panel_group.js", package = "teal.widgets"))), res_tag ) }) diff --git a/R/plot_with_settings.R b/R/plot_with_settings.R index 6f3c3316..97cbb627 100644 --- a/R/plot_with_settings.R +++ b/R/plot_with_settings.R @@ -7,8 +7,8 @@ plot_with_settings_ui <- function(id) { ns <- NS(id) tagList( - shiny::singleton(shiny::tags$head( - shiny::tags$script( + shiny::singleton(tags$head( + tags$script( # nolint start sprintf( '$(document).on("shiny:connected", function(e) { @@ -185,10 +185,10 @@ plot_with_settings_ui <- function(id) { #' id = "plot_with_settings" #' ), #' fluidRow( -#' column(4, h3("Brush"), verbatimTextOutput("brushing_data")), -#' column(4, h3("Click"), verbatimTextOutput("clicking_data")), -#' column(4, h3("DblClick"), verbatimTextOutput("dblclicking_data")), -#' column(4, h3("Hover"), verbatimTextOutput("hovering_data")) +#' column(4, tags$h3("Brush"), verbatimTextOutput("brushing_data")), +#' column(4, tags$h3("Click"), verbatimTextOutput("clicking_data")), +#' column(4, tags$h3("DblClick"), verbatimTextOutput("dblclicking_data")), +#' column(4, tags$h3("Hover"), verbatimTextOutput("hovering_data")) #' ) #' ) #' @@ -331,7 +331,7 @@ plot_with_settings_srv <- function(id, }) output$slider_ui <- renderUI({ - div( + tags$div( optionalSliderInputValMinMax( inputId = ns("height"), label = "Plot height", @@ -411,7 +411,7 @@ plot_with_settings_srv <- function(id, output$plot_out_main <- renderUI({ req(plot_suppress(plot_r())) - div( + tags$div( align = graph_align, plotOutput( ns("plot_main"), @@ -452,11 +452,11 @@ plot_with_settings_srv <- function(id, observeEvent(input$expand, { showModal( - div( + tags$div( class = "plot-modal", modalDialog( easyClose = TRUE, - div( + tags$div( class = "plot-modal-sliders", optionalSliderInputValMinMax( inputId = ns("height_in_modal"), @@ -486,11 +486,11 @@ plot_with_settings_srv <- function(id, round = TRUE ) ), - div( + tags$div( class = "float-right", type_download_ui(ns("modal_downbutton")) ), - div( + tags$div( align = "center", uiOutput(ns("plot_out_modal"), class = "plot_out_container") ) @@ -551,7 +551,7 @@ type_download_ui <- function(id) { right = TRUE, label = "", inputId = ns("downl"), - div( + tags$div( radioButtons(ns("file_format"), label = "File type", choices = c("png" = "png", "pdf" = "pdf", "svg" = "svg"), diff --git a/R/standard_layout.R b/R/standard_layout.R index 73423bef..6336a35a 100644 --- a/R/standard_layout.R +++ b/R/standard_layout.R @@ -22,8 +22,8 @@ #' @examples #' library(shiny) #' standard_layout( -#' output = white_small_well(h3("Tests")), -#' encoding = div( +#' output = white_small_well(tags$h3("Tests")), +#' encoding = tags$div( #' tags$label("Encodings", class = "text-primary"), #' panel_item( #' "Tests", @@ -58,34 +58,34 @@ standard_layout <- function(output, # if encoding=NULL then forms is placed below output - tag_output <- div( + tag_output <- tags$div( class = "well", - div(class = "pre-output", pre_output), - div(class = "output", output), - div(class = "post-output", post_output) + tags$div(class = "pre-output", pre_output), + tags$div(class = "output", output), + tags$div(class = "post-output", post_output) ) tag_enc_out <- if (!is.null(encoding)) { tagList( - div( + tags$div( class = "col-md-3", - div(class = "well", encoding), + tags$div(class = "well", encoding), if (is.null(forms)) { NULL } else { - div(class = "form-group", forms) + tags$div(class = "form-group", forms) } ), - div(class = "col-md-9", tag_output) + tags$div(class = "col-md-9", tag_output) ) } else { - div( + tags$div( class = "col-md-12", tag_output, if (is.null(forms)) { NULL } else { - div(class = "form-group", forms) + tags$div(class = "form-group", forms) } ) } diff --git a/R/table_with_settings.R b/R/table_with_settings.R index 9d34ebe6..c0dda267 100644 --- a/R/table_with_settings.R +++ b/R/table_with_settings.R @@ -107,11 +107,11 @@ table_with_settings_srv <- function(id, table_r, show_hide_signal = reactive(TRU observeEvent(input$expand, { showModal( - div( + tags$div( class = "table-modal", modalDialog( easyClose = TRUE, - div( + tags$div( class = "float-right", type_download_ui_table(ns("modal_downbutton")) ), @@ -137,7 +137,7 @@ type_download_ui_table <- function(id) { right = TRUE, label = "", inputId = ns("dwnl"), - div( + tags$div( class = "modal-download-ui-table-container", radioButtons(ns("file_format"), label = "File type", @@ -149,7 +149,7 @@ type_download_ui_table <- function(id) { ), conditionalPanel( condition = paste0("input['", ns("file_format"), "'] != '.csv'"), - div( + tags$div( class = "lock-btn", title = "on / off", shinyWidgets::prettyToggle( @@ -166,7 +166,7 @@ type_download_ui_table <- function(id) { animation = "pulse" ) ), - div( + tags$div( class = "paginate-ui", shinyWidgets::numericInputIcon( inputId = ns("lpp"), diff --git a/R/verbatim_popup.R b/R/verbatim_popup.R index 18e54a5f..49fe06ac 100644 --- a/R/verbatim_popup.R +++ b/R/verbatim_popup.R @@ -42,7 +42,7 @@ verbatim_popup_ui <- function(id, button_label, type = c("button", "link"), ...) shiny::tagList( shiny::singleton( - shiny::tags$head(shiny::includeScript(system.file("js/verbatim_popup.js", package = "teal.widgets"))) + tags$head(shiny::includeScript(system.file("js/verbatim_popup.js", package = "teal.widgets"))) ), shinyjs::useShinyjs(), do.call(ui_function, c(ui_args, list(...))) @@ -118,7 +118,7 @@ button_click_observer <- function(click_event, shiny::modalDialog( shiny::tagList( include_css_files(pattern = "verbatim_popup"), - shiny::tags$div( + tags$div( class = "mb-4", shiny::actionButton( paste0(copy_button_id, 1), @@ -127,7 +127,7 @@ button_click_observer <- function(click_event, ), shiny::modalButton("Dismiss") ), - shiny::tags$pre(id = copied_area_id, modal_content()), + tags$pre(id = copied_area_id, modal_content()), ), title = modal_title, footer = shiny::tagList( diff --git a/man/nested_closeable_modal.Rd b/man/nested_closeable_modal.Rd index 4cd24999..642c1fd6 100644 --- a/man/nested_closeable_modal.Rd +++ b/man/nested_closeable_modal.Rd @@ -59,7 +59,7 @@ ui <- fluidPage( footer = NULL, easyClose = TRUE ), - div( + tags$div( "This modal can be closed by running", tags$code("$('#modal_1').modal('hide')"), "in the JS console!", "Note that removing the parent will remove the child. diff --git a/man/optionalSelectInput.Rd b/man/optionalSelectInput.Rd index a9939a75..b4dad9b0 100644 --- a/man/optionalSelectInput.Rd +++ b/man/optionalSelectInput.Rd @@ -97,7 +97,7 @@ ui_grid <- function(...) { } ui <- ui_grid( - div( + tags$div( optionalSelectInput( inputId = "c1", label = "Fixed choices", @@ -107,7 +107,7 @@ ui <- ui_grid( ), verbatimTextOutput(outputId = "c1_out") ), - div( + tags$div( optionalSelectInput( inputId = "c2", label = "Single choice", @@ -116,7 +116,7 @@ ui <- ui_grid( ), verbatimTextOutput(outputId = "c2_out") ), - div( + tags$div( optionalSelectInput( inputId = "c3", label = "NULL choices", @@ -124,7 +124,7 @@ ui <- ui_grid( ), verbatimTextOutput(outputId = "c3_out") ), - div( + tags$div( optionalSelectInput( inputId = "c4", label = "Default", @@ -133,7 +133,7 @@ ui <- ui_grid( ), verbatimTextOutput(outputId = "c4_out") ), - div( + tags$div( optionalSelectInput( inputId = "c5", label = "Named vector", @@ -142,7 +142,7 @@ ui <- ui_grid( ), verbatimTextOutput(outputId = "c5_out") ), - div( + tags$div( selectInput( inputId = "c6_choices", label = "Update choices", choices = letters, multiple = TRUE ), diff --git a/man/plot_with_settings.Rd b/man/plot_with_settings.Rd index 32289b17..696af751 100644 --- a/man/plot_with_settings.Rd +++ b/man/plot_with_settings.Rd @@ -154,10 +154,10 @@ ui <- fluidPage( id = "plot_with_settings" ), fluidRow( - column(4, h3("Brush"), verbatimTextOutput("brushing_data")), - column(4, h3("Click"), verbatimTextOutput("clicking_data")), - column(4, h3("DblClick"), verbatimTextOutput("dblclicking_data")), - column(4, h3("Hover"), verbatimTextOutput("hovering_data")) + column(4, tags$h3("Brush"), verbatimTextOutput("brushing_data")), + column(4, tags$h3("Click"), verbatimTextOutput("clicking_data")), + column(4, tags$h3("DblClick"), verbatimTextOutput("dblclicking_data")), + column(4, tags$h3("Hover"), verbatimTextOutput("hovering_data")) ) ) diff --git a/man/standard_layout.Rd b/man/standard_layout.Rd index b0630dec..dbc66938 100644 --- a/man/standard_layout.Rd +++ b/man/standard_layout.Rd @@ -41,8 +41,8 @@ the left. This is the layout used by the \code{teal} modules. \examples{ library(shiny) standard_layout( - output = white_small_well(h3("Tests")), - encoding = div( + output = white_small_well(tags$h3("Tests")), + encoding = tags$div( tags$label("Encodings", class = "text-primary"), panel_item( "Tests", diff --git a/tests/testthat/test-standard_layout.R b/tests/testthat/test-standard_layout.R index 6cd3e1b2..86f0a1bf 100644 --- a/tests/testthat/test-standard_layout.R +++ b/tests/testthat/test-standard_layout.R @@ -105,7 +105,7 @@ testthat::test_that("Basic output", { testthat::expect_equal( standard_layout( output = tags$div(), pre_output = tags$div(), - post_output = tags$div(), encoding = tags$div(), forms = div() + post_output = tags$div(), encoding = tags$div(), forms = tags$div() ), tags$div( class = "row", diff --git a/vignettes/custom-basic-table-arguments.Rmd b/vignettes/custom-basic-table-arguments.Rmd index 8dac63b1..b13067b4 100644 --- a/vignettes/custom-basic-table-arguments.Rmd +++ b/vignettes/custom-basic-table-arguments.Rmd @@ -56,7 +56,7 @@ basic_table_args <- list( ui <- fluidPage( shinyjs::useShinyjs(), - div(verbatimTextOutput("table1")) + tags$div(verbatimTextOutput("table1")) ) server <- function(input, output, session) { diff --git a/vignettes/custom-ggplot2-arguments.Rmd b/vignettes/custom-ggplot2-arguments.Rmd index 5c9dd6f6..2fa795f5 100644 --- a/vignettes/custom-ggplot2-arguments.Rmd +++ b/vignettes/custom-ggplot2-arguments.Rmd @@ -74,7 +74,7 @@ user_ggplot2_args <- list( ui <- fluidPage( shinyjs::useShinyjs(), - div(plotOutput("plot1")) + tags$div(plotOutput("plot1")) ) server <- function(input, output, session) {