From 374f75795e062b61d97b10ac67608fa820b7ed5f Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 3 Nov 2025 11:02:45 -0500 Subject: [PATCH 01/33] Initial toolbar container --- DESCRIPTION | 1 + NAMESPACE | 1 + R/toolbar.R | 32 ++++++++++++++++++++ inst/components/scss/toolbar.scss | 50 +++++++++++++++++++++++++++++++ man/toolbar.Rd | 21 +++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 R/toolbar.R create mode 100644 inst/components/scss/toolbar.scss create mode 100644 man/toolbar.Rd diff --git a/DESCRIPTION b/DESCRIPTION index c20469d01..e755ac721 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -115,6 +115,7 @@ Collate: 'shiny-devmode.R' 'sidebar.R' 'staticimports.R' + 'toolbar.R' 'tooltip.R' 'utils-deps.R' 'utils-shiny.R' diff --git a/NAMESPACE b/NAMESPACE index 27d4445aa..4d613fd84 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -152,6 +152,7 @@ export(toggle_popover) export(toggle_sidebar) export(toggle_switch) export(toggle_tooltip) +export(toolbar) export(tooltip) export(update_popover) export(update_submit_textarea) diff --git a/R/toolbar.R b/R/toolbar.R new file mode 100644 index 000000000..3fabf5cfb --- /dev/null +++ b/R/toolbar.R @@ -0,0 +1,32 @@ +#' Add a toolbar to a UI element +#' +#' @description +#' Display additional information when focusing (or hovering over) a UI element. +#' +#' @param ... UI elements for the toolbar. +#' @param align A character string. +#' @param size STUFF HERE +#' +#' @return Returns a toolbar container. +#' +#' @export +toolbar <- function( + ..., + align = c("right", "left"), + size = c("sm", "md", "lg") +) { + align <- rlang::arg_match(align) + size <- rlang::arg_match(size) + + tag <- htmltools::div( + class = "bslib-toolbar", + "data-align" = align, + "data-size" = size, + rlang::list2(...), + component_dependencies() + ) + + as_fragment( + tag_require(tag, version = 5, caller = "toolbar()") + ) +} diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss new file mode 100644 index 000000000..8b162659e --- /dev/null +++ b/inst/components/scss/toolbar.scss @@ -0,0 +1,50 @@ +/* Toolbar */ +.bslib-toolbar { + display: flex; + align-items: center; + gap: 0.5rem; + + /* Toolbar options */ + + &[data-align="left"] { + margin-right: auto; + align-items: flex-start; + } + + &[data-align="right"] { + margin-left: auto; + align-items: flex-end; + } + + &[data-size="sm"] { + font-size: 0.8rem; + } + + &[data-size="md"] { + font-size: 1rem; + } + + &[data-size="lg"] { + font-size: 1.25rem; + } + + /* Adjustments to other elements */ + + &, + &>* { + margin-bottom: 0 !important; + width: auto; + } + + >.form-group.shiny-input-container, .form-group.shiny-input-container>* { + width: auto; + margin-bottom: 0; + min-width: 0; + } + + /* Ensure card headers with toolbars use flexbox for alignment */ + .card-header:has(> &) { + display: flex; + align-items: center; + } +} \ No newline at end of file diff --git a/man/toolbar.Rd b/man/toolbar.Rd new file mode 100644 index 000000000..9c6fb45b8 --- /dev/null +++ b/man/toolbar.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/toolbar.R +\name{toolbar} +\alias{toolbar} +\title{Add a toolbar to a UI element} +\usage{ +toolbar(..., align = c("right", "left"), size = c("sm", "md", "lg")) +} +\arguments{ +\item{...}{UI elements for the toolbar.} + +\item{align}{A character string.} + +\item{size}{STUFF HERE} +} +\value{ +Returns a toolbar container. +} +\description{ +Display additional information when focusing (or hovering over) a UI element. +} From ed1a07e8ce820adc858149862cecc90d996eb326 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 3 Nov 2025 11:15:13 -0500 Subject: [PATCH 02/33] Updates --- R/toolbar.R | 11 +++++++---- man/toolbar.Rd | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/R/toolbar.R b/R/toolbar.R index 3fabf5cfb..5f8891b54 100644 --- a/R/toolbar.R +++ b/R/toolbar.R @@ -1,13 +1,16 @@ #' Add a toolbar to a UI element #' #' @description -#' Display additional information when focusing (or hovering over) a UI element. +#' A toolbar which can contain buttons, inputs, and other UI elements +#' in a small form suitable for inclusion in card headers, +#' footers, and other small places. #' #' @param ... UI elements for the toolbar. -#' @param align A character string. -#' @param size STUFF HERE +#' @param align Determines if toolbar should be aligned to the right or left. +#' Must be one of "right" or "left". +#' @param size The size of the toolbar. Must be one of "sm", "md", or "lg". #' -#' @return Returns a toolbar container. +#' @return Returns a toolbar. #' #' @export toolbar <- function( diff --git a/man/toolbar.Rd b/man/toolbar.Rd index 9c6fb45b8..ffdc940c3 100644 --- a/man/toolbar.Rd +++ b/man/toolbar.Rd @@ -9,13 +9,16 @@ toolbar(..., align = c("right", "left"), size = c("sm", "md", "lg")) \arguments{ \item{...}{UI elements for the toolbar.} -\item{align}{A character string.} +\item{align}{Determines if toolbar should be aligned to the right or left. +Must be one of "right" or "left".} -\item{size}{STUFF HERE} +\item{size}{The size of the toolbar. Must be one of "sm", "md", or "lg".} } \value{ -Returns a toolbar container. +Returns a toolbar. } \description{ -Display additional information when focusing (or hovering over) a UI element. +A toolbar which can contain buttons, inputs, and other UI elements +in a small form suitable for inclusion in card headers, +footers, and other small places. } From 04bd68b6cd2e748a26014976d8a69f6f1319df99 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 3 Nov 2025 11:31:31 -0500 Subject: [PATCH 03/33] Minor updates --- R/toolbar.R | 6 +++--- inst/components/scss/toolbar.scss | 12 +++++++++++ inst/examples-shiny/testapp.R | 35 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 inst/examples-shiny/testapp.R diff --git a/R/toolbar.R b/R/toolbar.R index 5f8891b54..340721788 100644 --- a/R/toolbar.R +++ b/R/toolbar.R @@ -18,6 +18,7 @@ toolbar <- function( align = c("right", "left"), size = c("sm", "md", "lg") ) { + dots <- separate_arguments(...) align <- rlang::arg_match(align) size <- rlang::arg_match(size) @@ -29,7 +30,6 @@ toolbar <- function( component_dependencies() ) - as_fragment( - tag_require(tag, version = 5, caller = "toolbar()") - ) + tag_require(tag, version = 5, caller = "toolbar()") + as_fragment(tag) } diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index 8b162659e..4336218f6 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -18,14 +18,26 @@ &[data-size="sm"] { font-size: 0.8rem; + + & > * { + font-size: 0.8rem; + } } &[data-size="md"] { font-size: 1rem; + + & > * { + font-size: 1rem; + } } &[data-size="lg"] { font-size: 1.25rem; + + & > * { + font-size: 1.25rem; + } } /* Adjustments to other elements */ diff --git a/inst/examples-shiny/testapp.R b/inst/examples-shiny/testapp.R new file mode 100644 index 000000000..b9dc0b553 --- /dev/null +++ b/inst/examples-shiny/testapp.R @@ -0,0 +1,35 @@ +library(shiny) +library(bslib) + +ui <- page_fillable( + tags$head( + tags$link(rel = "stylesheet", type = "text/css", href = "styles.css") + ), + card( + card_header( + "Card 1 header", + toolbar( + align = "right", + size = "sm", + input_switch("check", "Pick me!"), + ) + ), + p("Card 1 body"), + sliderInput("slider", "Slider", 0, 10, 5), + max_height = "500px", + card_footer() + ), + toolbar( + align = "left", + actionButton("test", NULL, icon = icon("calendar")) + ) +) + +server <- function(input, output) { + observe({ + print(input$bgc) + }) +} + + +shinyApp(ui = ui, server = server) From 8f6d6f11d7788fd08d15d68703cebea20e3f57be Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 3 Nov 2025 16:09:43 -0500 Subject: [PATCH 04/33] Added tests --- tests/testthat/test-toolbar.R | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/testthat/test-toolbar.R diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R new file mode 100644 index 000000000..d1b433722 --- /dev/null +++ b/tests/testthat/test-toolbar.R @@ -0,0 +1,20 @@ +test_that("toolbar() basic attributes and defaults", { + tb <- as.tags(toolbar(htmltools::span("Test"))) + + expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") + + expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") + expect_match(htmltools::tagGetAttribute(tb, "data-size"), "sm") +}) + +test_that("toolbar() assigns correct attributes", { + tb <- as.tags(toolbar(align = "left", size = "md")) + + expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") + expect_equal(htmltools::tagGetAttribute(tb, "data-size"), "md") +}) + +test_that("toolbar() validation of inputs", { + expect_error(toolbar("x", align = "center")) + expect_error(toolbar("x", size = "xl")) +}) From 63893071ad731410f75d38623ed1abf2014d6b9c Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 3 Nov 2025 16:29:12 -0500 Subject: [PATCH 05/33] Updated news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index b9d05c483..ed19fc40a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * Added a new `input_submit_textarea()` input element, which is similar to `shiny::textAreaInput()`, but includes a submit button to only submit the text changes to the server on click. This is especially useful when the input text change triggers a long-running operation and/or the user wants to type longer-form input and review it before submitting it. +* Added a new `toolbar()` component for creating Bootstrap toolbars that can contain buttons, text, and other elements. (#1247) + ## Improvements and bug fixes * `bs_theme_dependencies()` now avoids unnecessarily copying internal package files to R's temporary directory more than once when preparing precompiled theme dependencies (e.g. for a standard `bs_theme()` theme). (#1184) From c7d70e694d20c2385e07033f2377897357f535ab Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 3 Nov 2025 16:49:01 -0500 Subject: [PATCH 06/33] Removing example: --- inst/components/scss/toolbar.scss | 4 ++++ inst/examples-shiny/testapp.R | 35 ------------------------------- 2 files changed, 4 insertions(+), 35 deletions(-) delete mode 100644 inst/examples-shiny/testapp.R diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index 4336218f6..a900f6822 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -59,4 +59,8 @@ display: flex; align-items: center; } + .card-footer:has(> &) { + display: flex; + align-items: center; + } } \ No newline at end of file diff --git a/inst/examples-shiny/testapp.R b/inst/examples-shiny/testapp.R deleted file mode 100644 index b9dc0b553..000000000 --- a/inst/examples-shiny/testapp.R +++ /dev/null @@ -1,35 +0,0 @@ -library(shiny) -library(bslib) - -ui <- page_fillable( - tags$head( - tags$link(rel = "stylesheet", type = "text/css", href = "styles.css") - ), - card( - card_header( - "Card 1 header", - toolbar( - align = "right", - size = "sm", - input_switch("check", "Pick me!"), - ) - ), - p("Card 1 body"), - sliderInput("slider", "Slider", 0, 10, 5), - max_height = "500px", - card_footer() - ), - toolbar( - align = "left", - actionButton("test", NULL, icon = icon("calendar")) - ) -) - -server <- function(input, output) { - observe({ - print(input$bgc) - }) -} - - -shinyApp(ui = ui, server = server) From 3f8b63016185e9a985fc7af670badee693656744 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Tue, 4 Nov 2025 22:40:27 -0500 Subject: [PATCH 07/33] Adding snaps --- tests/testthat/_snaps/toolbar.md | 69 ++++++++++++++++++++++++++++++++ tests/testthat/test-toolbar.R | 66 ++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 tests/testthat/_snaps/toolbar.md diff --git a/tests/testthat/_snaps/toolbar.md b/tests/testthat/_snaps/toolbar.md new file mode 100644 index 000000000..a15c93bf0 --- /dev/null +++ b/tests/testthat/_snaps/toolbar.md @@ -0,0 +1,69 @@ +# toolbar() markup snapshots + + Code + show_raw_html(toolbar("Item 1", "Item 2")) + Output +
+ Item 1 + Item 2 +
+ +--- + + Code + show_raw_html(toolbar(shiny::actionButton("btn1", "Button 1"), align = "left")) + Output +
+ +
+ +--- + + Code + show_raw_html(toolbar(size = "md")) + Output +
+ +--- + + Code + show_raw_html(card(card_header("Card Title", toolbar(tags$button("Settings"), + align = "right", size = "sm")), card_body("Card content"))) + Output +
+
+ Card Title +
+ +
+
+
Card content
+ +
+ +--- + + Code + show_raw_html(toolbar(shiny::selectInput("select", NULL, choices = c("A", "B", + "C"), multiple = FALSE, selectize = FALSE), shiny::checkboxInput("check", + "Check"), align = "right")) + Output +
+
+ +
+ +
+
+
+
+ +
+
+
+ diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index d1b433722..75000e1f9 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -18,3 +18,69 @@ test_that("toolbar() validation of inputs", { expect_error(toolbar("x", align = "center")) expect_error(toolbar("x", size = "xl")) }) + +test_that("toolbar() markup snapshots", { + show_raw_html <- function(x) { + cat(format(x)) + } + + # Basic toolbar + expect_snapshot( + show_raw_html( + toolbar("Item 1", "Item 2") + ) + ) + + # Toolbar with alignment options + expect_snapshot( + show_raw_html( + toolbar( + shiny::actionButton("btn1", "Button 1"), + align = "left" + ) + ) + ) + + # Toolbar with size options + expect_snapshot( + show_raw_html( + toolbar( + size = "md" + ) + ) + ) + + # Toolbar in card header + expect_snapshot( + show_raw_html( + card( + card_header( + "Card Title", + toolbar( + tags$button("Settings"), + align = "right", + size = "sm" + ) + ), + card_body("Card content") + ) + ) + ) + + # Toolbar with Shiny inputs + expect_snapshot( + show_raw_html( + toolbar( + shiny::selectInput( + "select", + NULL, + choices = c("A", "B", "C"), + multiple = FALSE, + selectize = FALSE + ), + shiny::checkboxInput("check", "Check"), + align = "right" + ) + ) + ) +}) From 1abed04d5644f63edfeeadf8670feb39d05dd532 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Tue, 4 Nov 2025 22:57:08 -0500 Subject: [PATCH 08/33] Adding a few comments --- inst/components/scss/toolbar.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index a900f6822..1066fe08a 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -48,6 +48,7 @@ width: auto; } + /* Ensures that inputs inherit the formatting of the toolbar and align correctly */ >.form-group.shiny-input-container, .form-group.shiny-input-container>* { width: auto; margin-bottom: 0; From 5fd92549bcf8cce905dcd430cdba125b65850fbb Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Wed, 5 Nov 2025 13:31:58 -0500 Subject: [PATCH 09/33] Update to toolbar testing --- tests/testthat/_snaps/toolbar.md | 53 +++++--------------------------- tests/testthat/test-toolbar.R | 39 +++-------------------- 2 files changed, 11 insertions(+), 81 deletions(-) diff --git a/tests/testthat/_snaps/toolbar.md b/tests/testthat/_snaps/toolbar.md index a15c93bf0..e1362b59d 100644 --- a/tests/testthat/_snaps/toolbar.md +++ b/tests/testthat/_snaps/toolbar.md @@ -11,59 +11,20 @@ --- Code - show_raw_html(toolbar(shiny::actionButton("btn1", "Button 1"), align = "left")) + show_raw_html(toolbar("Item 1", "Item 2", align = "left")) Output
- -
- ---- - - Code - show_raw_html(toolbar(size = "md")) - Output -
- ---- - - Code - show_raw_html(card(card_header("Card Title", toolbar(tags$button("Settings"), - align = "right", size = "sm")), card_body("Card content"))) - Output -
-
- Card Title -
- -
-
-
Card content
- + Item 1 + Item 2
--- Code - show_raw_html(toolbar(shiny::selectInput("select", NULL, choices = c("A", "B", - "C"), multiple = FALSE, selectize = FALSE), shiny::checkboxInput("check", - "Check"), align = "right")) + show_raw_html(toolbar("Item 1", "Item 2", size = "md")) Output -
-
- -
- -
-
-
-
- -
-
+
+ Item 1 + Item 2
diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 75000e1f9..1085b1bfe 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -35,7 +35,8 @@ test_that("toolbar() markup snapshots", { expect_snapshot( show_raw_html( toolbar( - shiny::actionButton("btn1", "Button 1"), + "Item 1", + "Item 2", align = "left" ) ) @@ -45,42 +46,10 @@ test_that("toolbar() markup snapshots", { expect_snapshot( show_raw_html( toolbar( + "Item 1", + "Item 2", size = "md" ) ) ) - - # Toolbar in card header - expect_snapshot( - show_raw_html( - card( - card_header( - "Card Title", - toolbar( - tags$button("Settings"), - align = "right", - size = "sm" - ) - ), - card_body("Card content") - ) - ) - ) - - # Toolbar with Shiny inputs - expect_snapshot( - show_raw_html( - toolbar( - shiny::selectInput( - "select", - NULL, - choices = c("A", "B", "C"), - multiple = FALSE, - selectize = FALSE - ), - shiny::checkboxInput("check", "Check"), - align = "right" - ) - ) - ) }) From c2289a38fe1b97f076f39cd63a65b8114ec7f0b0 Mon Sep 17 00:00:00 2001 From: E Nelson Date: Wed, 5 Nov 2025 13:52:14 -0500 Subject: [PATCH 10/33] Fix dots in toolbar function Co-authored-by: Garrick Aden-Buie --- R/toolbar.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/R/toolbar.R b/R/toolbar.R index 340721788..531da5ebe 100644 --- a/R/toolbar.R +++ b/R/toolbar.R @@ -18,15 +18,14 @@ toolbar <- function( align = c("right", "left"), size = c("sm", "md", "lg") ) { - dots <- separate_arguments(...) align <- rlang::arg_match(align) size <- rlang::arg_match(size) - tag <- htmltools::div( + tag <- div( class = "bslib-toolbar", "data-align" = align, "data-size" = size, - rlang::list2(...), + ..., component_dependencies() ) From b23fc17683eb9ac3602ddea5bdaef1e54b9d79e0 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Wed, 5 Nov 2025 13:52:58 -0500 Subject: [PATCH 11/33] updates to dots --- R/toolbar.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/R/toolbar.R b/R/toolbar.R index 340721788..531da5ebe 100644 --- a/R/toolbar.R +++ b/R/toolbar.R @@ -18,15 +18,14 @@ toolbar <- function( align = c("right", "left"), size = c("sm", "md", "lg") ) { - dots <- separate_arguments(...) align <- rlang::arg_match(align) size <- rlang::arg_match(size) - tag <- htmltools::div( + tag <- div( class = "bslib-toolbar", "data-align" = align, "data-size" = size, - rlang::list2(...), + ..., component_dependencies() ) From 08363745653325c272bc4199af3f1030fc65696f Mon Sep 17 00:00:00 2001 From: E Nelson Date: Wed, 5 Nov 2025 17:10:27 -0500 Subject: [PATCH 12/33] Update R/toolbar.R Co-authored-by: Garrick Aden-Buie --- R/toolbar.R | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/R/toolbar.R b/R/toolbar.R index 531da5ebe..8d0e4616f 100644 --- a/R/toolbar.R +++ b/R/toolbar.R @@ -1,16 +1,16 @@ -#' Add a toolbar to a UI element +#' Toolbar component #' #' @description -#' A toolbar which can contain buttons, inputs, and other UI elements -#' in a small form suitable for inclusion in card headers, -#' footers, and other small places. +#' A toolbar which can contain buttons, inputs, and other UI elements in a small +#' form suitable for inclusion in card headers, footers, and other small places. #' #' @param ... UI elements for the toolbar. -#' @param align Determines if toolbar should be aligned to the right or left. -#' Must be one of "right" or "left". -#' @param size The size of the toolbar. Must be one of "sm", "md", or "lg". +#' @param align Determines if toolbar should be aligned to the `"right"` or +#' `"left"`. +#' @param size The size of the toolbar. Must be one of `"sm"`, `"md"`, or +#' `"lg"`. #' -#' @return Returns a toolbar. +#' @return Returns a toolbar element. #' #' @export toolbar <- function( From a55d03fdfa3a246a013dea3f9eab62ec10ec088c Mon Sep 17 00:00:00 2001 From: E Nelson Date: Wed, 5 Nov 2025 17:10:34 -0500 Subject: [PATCH 13/33] Update inst/components/scss/toolbar.scss Co-authored-by: Garrick Aden-Buie --- inst/components/scss/toolbar.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index 1066fe08a..bc07e6ea2 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -55,7 +55,7 @@ min-width: 0; } - /* Ensure card headers with toolbars use flexbox for alignment */ + // Ensure card headers with toolbars use flexbox for alignment .card-header:has(> &) { display: flex; align-items: center; From 0afabf4b0801515501af7a03998bf177bec43095 Mon Sep 17 00:00:00 2001 From: E Nelson Date: Wed, 5 Nov 2025 17:15:21 -0500 Subject: [PATCH 14/33] Update inst/components/scss/toolbar.scss Co-authored-by: Garrick Aden-Buie --- inst/components/scss/toolbar.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index bc07e6ea2..b6d00b701 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -40,7 +40,7 @@ } } - /* Adjustments to other elements */ + /* ---- Adjustments to other elements ---- */ &, &>* { From e6e9d88498b52a295a180538a35b799c2152209d Mon Sep 17 00:00:00 2001 From: E Nelson Date: Wed, 5 Nov 2025 17:15:28 -0500 Subject: [PATCH 15/33] Update inst/components/scss/toolbar.scss Co-authored-by: Garrick Aden-Buie --- inst/components/scss/toolbar.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index b6d00b701..fbe92cedc 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -4,7 +4,7 @@ align-items: center; gap: 0.5rem; - /* Toolbar options */ + /* ---- Toolbar options ---- */ &[data-align="left"] { margin-right: auto; From f8986706c673175d8e9a8b9d8859cdc6a528e5c3 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Thu, 13 Nov 2025 21:59:50 -0500 Subject: [PATCH 16/33] Updated code --- R/toolbar.R | 10 ++---- inst/components/scss/toolbar.scss | 51 ++++++------------------------- tests/testthat/_snaps/toolbar.md | 14 ++------- tests/testthat/test-toolbar.R | 16 +--------- 4 files changed, 14 insertions(+), 77 deletions(-) diff --git a/R/toolbar.R b/R/toolbar.R index 8d0e4616f..f100b5951 100644 --- a/R/toolbar.R +++ b/R/toolbar.R @@ -7,24 +7,18 @@ #' @param ... UI elements for the toolbar. #' @param align Determines if toolbar should be aligned to the `"right"` or #' `"left"`. -#' @param size The size of the toolbar. Must be one of `"sm"`, `"md"`, or -#' `"lg"`. -#' #' @return Returns a toolbar element. #' #' @export toolbar <- function( ..., - align = c("right", "left"), - size = c("sm", "md", "lg") + align = c("right", "left") ) { align <- rlang::arg_match(align) - size <- rlang::arg_match(size) tag <- div( - class = "bslib-toolbar", + class = "bslib-toolbar bslib-gap-spacing", "data-align" = align, - "data-size" = size, ..., component_dependencies() ) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index fbe92cedc..c680ba5a8 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -2,66 +2,33 @@ .bslib-toolbar { display: flex; align-items: center; - gap: 0.5rem; /* ---- Toolbar options ---- */ &[data-align="left"] { margin-right: auto; - align-items: flex-start; } &[data-align="right"] { margin-left: auto; - align-items: flex-end; - } - - &[data-size="sm"] { - font-size: 0.8rem; - - & > * { - font-size: 0.8rem; - } - } - - &[data-size="md"] { - font-size: 1rem; - - & > * { - font-size: 1rem; - } - } - - &[data-size="lg"] { - font-size: 1.25rem; - - & > * { - font-size: 1.25rem; - } } /* ---- Adjustments to other elements ---- */ + // Ensures uniformity of font sizing in elements and sub-elements (e.g., input select) &, - &>* { - margin-bottom: 0 !important; - width: auto; + & * { + font-size: 0.8rem; } - /* Ensures that inputs inherit the formatting of the toolbar and align correctly */ - >.form-group.shiny-input-container, .form-group.shiny-input-container>* { + & > * { + margin-bottom: 0 !important; width: auto; - margin-bottom: 0; - min-width: 0; + align-self: center; } - // Ensure card headers with toolbars use flexbox for alignment - .card-header:has(> &) { - display: flex; - align-items: center; - } - .card-footer:has(> &) { - display: flex; - align-items: center; + // Ensures that inputs inherit the formatting of the toolbar and align correctly (e.g. input select) + > .form-group { + width: auto; } } \ No newline at end of file diff --git a/tests/testthat/_snaps/toolbar.md b/tests/testthat/_snaps/toolbar.md index e1362b59d..2d6b9e445 100644 --- a/tests/testthat/_snaps/toolbar.md +++ b/tests/testthat/_snaps/toolbar.md @@ -3,7 +3,7 @@ Code show_raw_html(toolbar("Item 1", "Item 2")) Output -
+
Item 1 Item 2
@@ -13,17 +13,7 @@ Code show_raw_html(toolbar("Item 1", "Item 2", align = "left")) Output -
- Item 1 - Item 2 -
- ---- - - Code - show_raw_html(toolbar("Item 1", "Item 2", size = "md")) - Output -
+
Item 1 Item 2
diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 1085b1bfe..2e370ecb0 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -4,19 +4,16 @@ test_that("toolbar() basic attributes and defaults", { expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") - expect_match(htmltools::tagGetAttribute(tb, "data-size"), "sm") }) test_that("toolbar() assigns correct attributes", { - tb <- as.tags(toolbar(align = "left", size = "md")) + tb <- as.tags(toolbar(align = "left")) expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") - expect_equal(htmltools::tagGetAttribute(tb, "data-size"), "md") }) test_that("toolbar() validation of inputs", { expect_error(toolbar("x", align = "center")) - expect_error(toolbar("x", size = "xl")) }) test_that("toolbar() markup snapshots", { @@ -41,15 +38,4 @@ test_that("toolbar() markup snapshots", { ) ) ) - - # Toolbar with size options - expect_snapshot( - show_raw_html( - toolbar( - "Item 1", - "Item 2", - size = "md" - ) - ) - ) }) From 899b644597db8e40bc66861e75af81f2c8c829f3 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Fri, 14 Nov 2025 09:08:05 -0500 Subject: [PATCH 17/33] minor formatting changes --- tests/testthat/test-toolbar.R | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 2e370ecb0..d8d4eac14 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -31,11 +31,7 @@ test_that("toolbar() markup snapshots", { # Toolbar with alignment options expect_snapshot( show_raw_html( - toolbar( - "Item 1", - "Item 2", - align = "left" - ) + toolbar("Item 1", "Item 2", align = "left") ) ) }) From 6a3ccfe196b793a1c99581220625a4aaafa1f86d Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Fri, 14 Nov 2025 09:10:31 -0500 Subject: [PATCH 18/33] Adding footer back --- inst/components/scss/toolbar.scss | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index c680ba5a8..de2636f38 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -31,4 +31,11 @@ > .form-group { width: auto; } -} \ No newline at end of file +} + +// Card header is flex by default, but card footer is not and must be in order for +// toolbar alignment to work +.card-footer:has(> &) { + display: flex; + align-items: center; + } From 88f00d8179b2e9cd87ecc45efb01d7f75ce6aac7 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Fri, 14 Nov 2025 09:11:18 -0500 Subject: [PATCH 19/33] Docs changes --- man/toolbar.Rd | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/man/toolbar.Rd b/man/toolbar.Rd index ffdc940c3..6a398d85f 100644 --- a/man/toolbar.Rd +++ b/man/toolbar.Rd @@ -2,23 +2,20 @@ % Please edit documentation in R/toolbar.R \name{toolbar} \alias{toolbar} -\title{Add a toolbar to a UI element} +\title{Toolbar component} \usage{ -toolbar(..., align = c("right", "left"), size = c("sm", "md", "lg")) +toolbar(..., align = c("right", "left")) } \arguments{ \item{...}{UI elements for the toolbar.} -\item{align}{Determines if toolbar should be aligned to the right or left. -Must be one of "right" or "left".} - -\item{size}{The size of the toolbar. Must be one of "sm", "md", or "lg".} +\item{align}{Determines if toolbar should be aligned to the \code{"right"} or +\code{"left"}.} } \value{ -Returns a toolbar. +Returns a toolbar element. } \description{ -A toolbar which can contain buttons, inputs, and other UI elements -in a small form suitable for inclusion in card headers, -footers, and other small places. +A toolbar which can contain buttons, inputs, and other UI elements in a small +form suitable for inclusion in card headers, footers, and other small places. } From df309bfdf64104a6ec95e24ac2b7fdedeca8e055 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Fri, 14 Nov 2025 09:44:38 -0500 Subject: [PATCH 20/33] Updating footer, updating tests --- inst/components/scss/toolbar.scss | 8 ++++---- tests/testthat/_snaps/toolbar.md | 10 ++++++++++ tests/testthat/test-toolbar.R | 7 +++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index de2636f38..259bca3d8 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -31,11 +31,11 @@ > .form-group { width: auto; } -} -// Card header is flex by default, but card footer is not and must be in order for -// toolbar alignment to work -.card-footer:has(> &) { + // Card header is flex by default, but card footer is not and must be in order for + // toolbar alignment to work + .card-footer:has(> &) { display: flex; align-items: center; } +} \ No newline at end of file diff --git a/tests/testthat/_snaps/toolbar.md b/tests/testthat/_snaps/toolbar.md index 2d6b9e445..dbbbc3744 100644 --- a/tests/testthat/_snaps/toolbar.md +++ b/tests/testthat/_snaps/toolbar.md @@ -18,3 +18,13 @@ Item 2
+--- + + Code + show_raw_html(toolbar("Item 1", "Item 2", align = "right")) + Output +
+ Item 1 + Item 2 +
+ diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index d8d4eac14..ee7ef189a 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -34,4 +34,11 @@ test_that("toolbar() markup snapshots", { toolbar("Item 1", "Item 2", align = "left") ) ) + + # Toolbar with alignment options + expect_snapshot( + show_raw_html( + toolbar("Item 1", "Item 2", align = "right") + ) + ) }) From 68b70062cb59a35b0d1ade689872d07eed641f6a Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Fri, 14 Nov 2025 10:00:02 -0500 Subject: [PATCH 21/33] chore: air format tests/testthat/test-toolbar.R --- tests/testthat/test-toolbar.R | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index ee7ef189a..f074e4680 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -1,44 +1,44 @@ test_that("toolbar() basic attributes and defaults", { - tb <- as.tags(toolbar(htmltools::span("Test"))) + tb <- as.tags(toolbar(htmltools::span("Test"))) - expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") + expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") - expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") + expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") }) test_that("toolbar() assigns correct attributes", { - tb <- as.tags(toolbar(align = "left")) + tb <- as.tags(toolbar(align = "left")) - expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") + expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") }) test_that("toolbar() validation of inputs", { - expect_error(toolbar("x", align = "center")) + expect_error(toolbar("x", align = "center")) }) test_that("toolbar() markup snapshots", { - show_raw_html <- function(x) { - cat(format(x)) - } - - # Basic toolbar - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2") - ) + show_raw_html <- function(x) { + cat(format(x)) + } + + # Basic toolbar + expect_snapshot( + show_raw_html( + toolbar("Item 1", "Item 2") ) + ) - # Toolbar with alignment options - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2", align = "left") - ) + # Toolbar with alignment options + expect_snapshot( + show_raw_html( + toolbar("Item 1", "Item 2", align = "left") ) + ) - # Toolbar with alignment options - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2", align = "right") - ) + # Toolbar with alignment options + expect_snapshot( + show_raw_html( + toolbar("Item 1", "Item 2", align = "right") ) + ) }) From 12db8108e9f3524f50fed6b240a0f0db99c76563 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Fri, 14 Nov 2025 11:06:39 -0500 Subject: [PATCH 22/33] Spacing --- tests/testthat/test-toolbar.R | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index ee7ef189a..f074e4680 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -1,44 +1,44 @@ test_that("toolbar() basic attributes and defaults", { - tb <- as.tags(toolbar(htmltools::span("Test"))) + tb <- as.tags(toolbar(htmltools::span("Test"))) - expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") + expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") - expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") + expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") }) test_that("toolbar() assigns correct attributes", { - tb <- as.tags(toolbar(align = "left")) + tb <- as.tags(toolbar(align = "left")) - expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") + expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") }) test_that("toolbar() validation of inputs", { - expect_error(toolbar("x", align = "center")) + expect_error(toolbar("x", align = "center")) }) test_that("toolbar() markup snapshots", { - show_raw_html <- function(x) { - cat(format(x)) - } - - # Basic toolbar - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2") - ) + show_raw_html <- function(x) { + cat(format(x)) + } + + # Basic toolbar + expect_snapshot( + show_raw_html( + toolbar("Item 1", "Item 2") ) + ) - # Toolbar with alignment options - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2", align = "left") - ) + # Toolbar with alignment options + expect_snapshot( + show_raw_html( + toolbar("Item 1", "Item 2", align = "left") ) + ) - # Toolbar with alignment options - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2", align = "right") - ) + # Toolbar with alignment options + expect_snapshot( + show_raw_html( + toolbar("Item 1", "Item 2", align = "right") ) + ) }) From 87cbf1db0f8e2fad980d02852a0c7720dda8fe70 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Fri, 14 Nov 2025 11:10:46 -0500 Subject: [PATCH 23/33] Updating comments --- tests/testthat/test-toolbar.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index f074e4680..5794c196b 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -21,21 +21,20 @@ test_that("toolbar() markup snapshots", { cat(format(x)) } - # Basic toolbar + # Basic toolbar using defaults expect_snapshot( show_raw_html( toolbar("Item 1", "Item 2") ) ) - # Toolbar with alignment options + # Toolbars with alignment options expect_snapshot( show_raw_html( toolbar("Item 1", "Item 2", align = "left") ) ) - # Toolbar with alignment options expect_snapshot( show_raw_html( toolbar("Item 1", "Item 2", align = "right") From 6be96cbe108ae48e2d6409bc7c8afe3c563f5312 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 17 Nov 2025 10:02:29 -0500 Subject: [PATCH 24/33] Removed select formatting to be addressed in select input PR --- inst/components/scss/toolbar.scss | 5 ----- 1 file changed, 5 deletions(-) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index 259bca3d8..bca86fb82 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -27,11 +27,6 @@ align-self: center; } - // Ensures that inputs inherit the formatting of the toolbar and align correctly (e.g. input select) - > .form-group { - width: auto; - } - // Card header is flex by default, but card footer is not and must be in order for // toolbar alignment to work .card-footer:has(> &) { From d16f7271a50ed2a845dfb8d2038ce10cf10c6637 Mon Sep 17 00:00:00 2001 From: E Nelson Date: Mon, 17 Nov 2025 11:38:47 -0500 Subject: [PATCH 25/33] Update tests/testthat/test-toolbar.R Co-authored-by: Garrick Aden-Buie --- tests/testthat/test-toolbar.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 5794c196b..26d7a1e83 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -1,8 +1,6 @@ test_that("toolbar() basic attributes and defaults", { tb <- as.tags(toolbar(htmltools::span("Test"))) - expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") - expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") }) From 3d7d9f06a58cab3ba89ea08488bf03720342a25a Mon Sep 17 00:00:00 2001 From: E Nelson Date: Mon, 17 Nov 2025 11:39:15 -0500 Subject: [PATCH 26/33] Update tests/testthat/test-toolbar.R Co-authored-by: Garrick Aden-Buie --- tests/testthat/test-toolbar.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 26d7a1e83..61d666eef 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -6,7 +6,6 @@ test_that("toolbar() basic attributes and defaults", { test_that("toolbar() assigns correct attributes", { tb <- as.tags(toolbar(align = "left")) - expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") }) From 3cc95fe0d1c35ac6030027970bc2f3f27b9b9359 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 17 Nov 2025 15:11:06 -0500 Subject: [PATCH 27/33] Updated tests --- tests/testthat/helper-html.R | 9 +++++++++ tests/testthat/test-toolbar.R | 27 +++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) create mode 100644 tests/testthat/helper-html.R diff --git a/tests/testthat/helper-html.R b/tests/testthat/helper-html.R new file mode 100644 index 000000000..9965671bf --- /dev/null +++ b/tests/testthat/helper-html.R @@ -0,0 +1,9 @@ +show_raw_html <- function(x) { + cat(format(x)) +} + +expect_snapshot_html <- function(x, .envir = parent.frame()) { + x_str <- deparse(substitute(x)) + code <- parse(text = sprintf("expect_snapshot(show_raw_html(%s))", x_str)) + eval(code, envir = .envir) +} diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 61d666eef..9eba3837d 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -2,39 +2,26 @@ test_that("toolbar() basic attributes and defaults", { tb <- as.tags(toolbar(htmltools::span("Test"))) expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") -}) -test_that("toolbar() assigns correct attributes", { tb <- as.tags(toolbar(align = "left")) expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") -}) -test_that("toolbar() validation of inputs", { expect_error(toolbar("x", align = "center")) }) -test_that("toolbar() markup snapshots", { - show_raw_html <- function(x) { - cat(format(x)) - } +test_that("toolbar() markup snapshots", { # Basic toolbar using defaults - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2") - ) + expect_snapshot_html( + toolbar("Item 1", "Item 2") ) # Toolbars with alignment options - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2", align = "left") - ) + expect_snapshot_html( + toolbar("Item 1", "Item 2", align = "left") ) - expect_snapshot( - show_raw_html( - toolbar("Item 1", "Item 2", align = "right") - ) + expect_snapshot_html( + toolbar("Item 1", "Item 2", align = "right") ) }) From d9a5bf097f3f33f2327f79827f9590766d24413f Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 17 Nov 2025 15:47:51 -0500 Subject: [PATCH 28/33] Updating formatting --- inst/components/scss/toolbar.scss | 54 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/inst/components/scss/toolbar.scss b/inst/components/scss/toolbar.scss index bca86fb82..75f11209d 100644 --- a/inst/components/scss/toolbar.scss +++ b/inst/components/scss/toolbar.scss @@ -1,36 +1,36 @@ /* Toolbar */ .bslib-toolbar { - display: flex; - align-items: center; + display: flex; + align-items: center; - /* ---- Toolbar options ---- */ + /* ---- Toolbar options ---- */ - &[data-align="left"] { - margin-right: auto; - } + &[data-align="left"] { + margin-right: auto; + } - &[data-align="right"] { - margin-left: auto; - } + &[data-align="right"] { + margin-left: auto; + } - /* ---- Adjustments to other elements ---- */ + /* ---- Adjustments to other elements ---- */ - // Ensures uniformity of font sizing in elements and sub-elements (e.g., input select) - &, - & * { - font-size: 0.8rem; - } + // Ensures uniformity of font sizing in elements and sub-elements (e.g., input select) + &, + & * { + font-size: 0.8rem; + } - & > * { - margin-bottom: 0 !important; - width: auto; - align-self: center; - } + &>* { + margin-bottom: 0 !important; + width: auto; + align-self: center; + } - // Card header is flex by default, but card footer is not and must be in order for - // toolbar alignment to work - .card-footer:has(> &) { - display: flex; - align-items: center; - } -} \ No newline at end of file + // Card header is flex by default, but card footer is not and must be in order for + // toolbar alignment to work + .card-footer:has(> &) { + display: flex; + align-items: center; + } +} From 9357091a2f1fd0b9e4a3b4cd58dd0b96fc1e8314 Mon Sep 17 00:00:00 2001 From: E Nelson Date: Mon, 17 Nov 2025 19:49:18 -0500 Subject: [PATCH 29/33] Update tests/testthat/test-toolbar.R Co-authored-by: Garrick Aden-Buie --- tests/testthat/test-toolbar.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 9eba3837d..41f617537 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -20,8 +20,4 @@ test_that("toolbar() markup snapshots", { expect_snapshot_html( toolbar("Item 1", "Item 2", align = "left") ) - - expect_snapshot_html( - toolbar("Item 1", "Item 2", align = "right") - ) }) From e147457027967ffbbb106af34c71c1359964f6fb Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 17 Nov 2025 19:56:35 -0500 Subject: [PATCH 30/33] Updated blocking --- tests/testthat/test-toolbar.R | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/testthat/test-toolbar.R b/tests/testthat/test-toolbar.R index 9eba3837d..b58d13bd5 100644 --- a/tests/testthat/test-toolbar.R +++ b/tests/testthat/test-toolbar.R @@ -2,26 +2,19 @@ test_that("toolbar() basic attributes and defaults", { tb <- as.tags(toolbar(htmltools::span("Test"))) expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar") expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right") - - tb <- as.tags(toolbar(align = "left")) - expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") - - expect_error(toolbar("x", align = "center")) -}) - - -test_that("toolbar() markup snapshots", { - # Basic toolbar using defaults expect_snapshot_html( toolbar("Item 1", "Item 2") ) +}) - # Toolbars with alignment options +test_that("toolbar() aligns correctly", { + tb <- as.tags(toolbar(align = "left")) + expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left") expect_snapshot_html( toolbar("Item 1", "Item 2", align = "left") ) - expect_snapshot_html( toolbar("Item 1", "Item 2", align = "right") ) + expect_error(toolbar("x", align = "center")) }) From 7b81e5d819dce8b8bc5ebc7bb9e70cb9cf9e28b1 Mon Sep 17 00:00:00 2001 From: Liz Nelson Date: Mon, 17 Nov 2025 20:02:13 -0500 Subject: [PATCH 31/33] Updated tests --- tests/testthat/_snaps/bs-theme-preset-builtin.md | 2 +- tests/testthat/_snaps/bs-theme-preset.md | 6 +++--- tests/testthat/_snaps/toolbar.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/_snaps/bs-theme-preset-builtin.md b/tests/testthat/_snaps/bs-theme-preset-builtin.md index 8a00aa203..ca5c8e28a 100644 --- a/tests/testthat/_snaps/bs-theme-preset-builtin.md +++ b/tests/testthat/_snaps/bs-theme-preset-builtin.md @@ -1,4 +1,4 @@ -# builtin_bundle() / errors for unknown preset names +# builtin_bundle(): errors for unknown preset names Code builtin_bundle("not-a-preset", version = "5") diff --git a/tests/testthat/_snaps/bs-theme-preset.md b/tests/testthat/_snaps/bs-theme-preset.md index 16c1c4412..53ddb0093 100644 --- a/tests/testthat/_snaps/bs-theme-preset.md +++ b/tests/testthat/_snaps/bs-theme-preset.md @@ -1,4 +1,4 @@ -# resolve_bs_preset() / throws an error if both `name` and `bootswatch` are provided +# resolve_bs_preset(): throws an error if both `name` and `bootswatch` are provided Code resolve_bs_preset(preset = "name", bootswatch = "bootswatch") @@ -10,7 +10,7 @@ * `preset = "bootswatch"` * `bootswatch = "bootswatch"` -# resolve_bs_preset() / throws an error if `name` or `bootswatch` are not scalar strings +# resolve_bs_preset(): throws an error if `name` or `bootswatch` are not scalar strings Code resolve_bs_preset(preset = c("a", "b")) @@ -30,7 +30,7 @@ x Bad: `bootswatch = c("flatly", "darkly")` v Good: `bootswatch = "flatly"` -# resolve_bs_preset() / throws an error if `name` or `bootswatch` don't match existing presets +# resolve_bs_preset(): throws an error if `name` or `bootswatch` don't match existing presets Code resolve_bs_preset(preset = "not_a_preset", version = 4) diff --git a/tests/testthat/_snaps/toolbar.md b/tests/testthat/_snaps/toolbar.md index dbbbc3744..2b0f09a1d 100644 --- a/tests/testthat/_snaps/toolbar.md +++ b/tests/testthat/_snaps/toolbar.md @@ -1,4 +1,4 @@ -# toolbar() markup snapshots +# toolbar() basic attributes and defaults Code show_raw_html(toolbar("Item 1", "Item 2")) @@ -8,7 +8,7 @@ Item 2
---- +# toolbar() aligns correctly Code show_raw_html(toolbar("Item 1", "Item 2", align = "left")) From d03af3dc501e67d3ba32e25255449c2217da9ad5 Mon Sep 17 00:00:00 2001 From: E Nelson Date: Mon, 17 Nov 2025 20:15:37 -0500 Subject: [PATCH 32/33] Update markdown headers in bs-theme-preset.md --- tests/testthat/_snaps/bs-theme-preset.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/_snaps/bs-theme-preset.md b/tests/testthat/_snaps/bs-theme-preset.md index 53ddb0093..16c1c4412 100644 --- a/tests/testthat/_snaps/bs-theme-preset.md +++ b/tests/testthat/_snaps/bs-theme-preset.md @@ -1,4 +1,4 @@ -# resolve_bs_preset(): throws an error if both `name` and `bootswatch` are provided +# resolve_bs_preset() / throws an error if both `name` and `bootswatch` are provided Code resolve_bs_preset(preset = "name", bootswatch = "bootswatch") @@ -10,7 +10,7 @@ * `preset = "bootswatch"` * `bootswatch = "bootswatch"` -# resolve_bs_preset(): throws an error if `name` or `bootswatch` are not scalar strings +# resolve_bs_preset() / throws an error if `name` or `bootswatch` are not scalar strings Code resolve_bs_preset(preset = c("a", "b")) @@ -30,7 +30,7 @@ x Bad: `bootswatch = c("flatly", "darkly")` v Good: `bootswatch = "flatly"` -# resolve_bs_preset(): throws an error if `name` or `bootswatch` don't match existing presets +# resolve_bs_preset() / throws an error if `name` or `bootswatch` don't match existing presets Code resolve_bs_preset(preset = "not_a_preset", version = 4) From 6a79efe9608eb877e42baa19af4a5a0f9176140b Mon Sep 17 00:00:00 2001 From: E Nelson Date: Mon, 17 Nov 2025 20:15:54 -0500 Subject: [PATCH 33/33] Update header format in bs-theme-preset-builtin.md --- tests/testthat/_snaps/bs-theme-preset-builtin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/_snaps/bs-theme-preset-builtin.md b/tests/testthat/_snaps/bs-theme-preset-builtin.md index ca5c8e28a..8a00aa203 100644 --- a/tests/testthat/_snaps/bs-theme-preset-builtin.md +++ b/tests/testthat/_snaps/bs-theme-preset-builtin.md @@ -1,4 +1,4 @@ -# builtin_bundle(): errors for unknown preset names +# builtin_bundle() / errors for unknown preset names Code builtin_bundle("not-a-preset", version = "5")