diff --git a/R/module_picks.R b/R/module_picks.R index 3efc37c8..8c218817 100644 --- a/R/module_picks.R +++ b/R/module_picks.R @@ -59,20 +59,20 @@ picks_ui.picks <- function(id, picks, container) { ns <- shiny::NS(id) badge_label <- shiny::uiOutput(ns("summary"), container = htmltools::tags$span) content <- lapply(picks, function(x) .pick_ui(id = ns(methods::is(x)))) - htmltools::tags$div( - if (missing(container)) { + if (missing(container)) { + htmltools::tags$div( if (all(vapply(picks, is_pick_fixed, logical(1)))) { - fixed_picks(id = ns("inputs"), badge_label) + badge_fixed(id = ns("inputs"), badge_label) } else { badge_dropdown(id = ns("inputs"), label = badge_label, htmltools::tagList(content)) } - } else { - if (!any(sapply(htmltools::tags, identical, container))) { - stop("Container should be one of `htmltools::tags`") - } - container(content) + ) + } else { + if (!any(sapply(htmltools::tags, identical, container))) { + stop("Container should be one of `htmltools::tags`") } - ) + htmltools::tags$div(container(content)) + } } #' @rdname picks_module diff --git a/R/ui_containers.R b/R/ui_containers.R index 7990d5ae..fd1adf42 100644 --- a/R/ui_containers.R +++ b/R/ui_containers.R @@ -52,13 +52,18 @@ badge_dropdown <- function(id, label, content) { #' @param label (`shiny.tag`) Label displayed on the component #' @keywords internal #' @noRd -fixed_picks <- function(id, label) { +badge_fixed <- function(id, label) { ns <- shiny::NS(id) - htmltools::tags$div( - id = ns("fixed_picks_badge"), - class = "fixed-picks", - htmltools::tags$label(label), - htmltools::tags$i(bsicons::bs_icon("lock-fill")) + htmltools::tagList( + htmltools::singleton(htmltools::tags$head( + htmltools::includeCSS(system.file("badge-dropdown", "style.css", package = "teal.picks")) + )), + htmltools::tags$div( + id = ns("fixed_badge"), + class = "fixed-picks", + htmltools::tags$label(label), + htmltools::tags$i(bsicons::bs_icon("lock-fill")) + ) ) }