diff --git a/DESCRIPTION b/DESCRIPTION index abe3433bc..8d8fb261a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -142,6 +142,7 @@ Collate: 'layout.R' 'nav-items.R' 'nav-update.R' + 'navbar_options.R' 'navs-legacy.R' 'navs.R' 'onLoad.R' diff --git a/R/navbar_options.R b/R/navbar_options.R new file mode 100644 index 000000000..6ab9253d9 --- /dev/null +++ b/R/navbar_options.R @@ -0,0 +1,213 @@ +#' Create a set of navbar options +#' +#' A `navbar_options()` object captures options specific to the appearance and +#' behavior of the navbar, independent from the content displayed on the page. +#' This helper should be used to create the list of options expected by +#' `navbar_options` in [page_navbar()] and [navset_bar()]. +#' +#' ## Changelog +#' +#' This function was introduced in \pkg{bslib} v0.9.0, replacing the `position`, +#' `bg`, `inverse`, `collapsible` and `underline` arguments of [page_navbar()] +#' and [navset_bar()]. Those arguments are deprecated with a warning and will be +#' removed in a future version of \pkg{bslib}. Note that the deprecated +#' `inverse` argument of [page_navbar()] and [navset_bar()] was replaced with +#' the `theme` argument of `navbar_options()`. +#' +#' @examples +#' navbar_options(position = "static-top", bg = "#2e9f7d", underline = FALSE) +#' +#' @inheritParams shiny::navbarPage +#' @param bg a CSS color to use for the navbar's background color. +#' @param theme Either `"dark"` for a light text color (on a **dark** +#' background) or `"light"` for a dark text color (on a **light** background). +#' If `"auto"` (the default) and `bg` is provided, the best contrast to `bg` +#' is chosen. +#' @param underline Whether or not to add underline styling to page or navbar +#' links when active or focused. +#' @param ... Additional attributes that will be passed directly to the navbar +#' container element. +#' +#' @returns Returns a list of navbar options. +#' +#' @export +navbar_options <- function( + ..., + position = c("static-top", "fixed-top", "fixed-bottom"), + bg = NULL, + theme = c("auto", "light", "dark"), + collapsible = TRUE, + underline = TRUE +) { + # Track user-provided arguments for print method and deprecation warnings + is_default <- list( + position = missing(position), + bg = missing(bg), + theme = missing(theme), + collapsible = missing(collapsible), + underline = missing(underline) + ) + + opts <- list( + position = rlang::arg_match(position), + bg = bg, + theme = rlang::arg_match(theme), + collapsible = collapsible, + underline = underline + ) + + dots <- separate_arguments(...) + if (length(dots$children) > 0) { + abort( + "All arguments in `...` must be named attributes to be applied to the navbar container." + ) + } + + if ("inverse" %in% names(dots$attribs)) { + # Catch muscle-memory for using `inverse`. We didn't officially release + # `navbar_options()` with an `inverse` argument, but it's reasonable people + # might try to use it and it did exist briefly in dev versions. + lifecycle::deprecate_soft( + when = "0.9.0", + what = "navbar_options(inverse=)", + with = "navbar_options(theme=)" + ) + } + if (length(dots$attribs)) { + opts$attribs <- dots$attribs + } + + structure( + opts, + class = c("bslib_navbar_options", "list"), + is_default = is_default, + waldo_opts = list(ignore_attr = TRUE) + ) +} + +navbar_options_resolve_deprecated <- function( + options_user = list(), + position = deprecated(), + bg = deprecated(), + inverse = deprecated(), + collapsible = deprecated(), + underline = deprecated(), + .fn_caller = "navset_bar", + .warn_deprecated = TRUE +) { + options_old <- list( + position = if (lifecycle::is_present(position)) position, + bg = if (lifecycle::is_present(bg)) bg, + inverse = if (lifecycle::is_present(inverse)) inverse, + collapsible = if (lifecycle::is_present(collapsible)) collapsible, + underline = if (lifecycle::is_present(underline)) underline + ) + options_old <- dropNulls(options_old) + + args_deprecated <- names(options_old) + + if (.warn_deprecated && length(args_deprecated)) { + # TODO-deprecated: (2024-12) Elevate deprecation to an error + lifecycle::deprecate_warn( + "0.9.0", + I( + sprintf( + "The arguments of `%s()` for navbar options (including %s) have been consolidated into a single `navbar_options` argument and ", + .fn_caller, + paste(sprintf("`%s`", args_deprecated), collapse = ", ") + ) + ), + details = c( + "i" = "See `navbar_options()` for more details.", + "!" = if ("inverse" %in% args_deprecated) + "Use `theme` instead of `inverse` in `navbar_options()`." + ) + ) + } + + # Upgrade `inverse` to the new `theme` argument of `navbar_options()` + if ("inverse" %in% names(options_old)) { + inverse <- options_old[["inverse"]] + options_old[["inverse"]] <- NULL + + options_old[["theme"]] <- + if (is.character(inverse)) { + inverse + } else if (isTRUE(as.logical(inverse))) { + options_old[["theme"]] <- "dark" + } else if (isFALSE(as.logical(inverse))) { + options_old[["theme"]] <- "light" + } else { + abort(paste("Invalid `inverse` value: ", inverse)) + } + } + + # Consolidate `navbar_options` (options_user) with the deprecated direct + # options. We take the direct option if the user option is a default value, + # warning if otherwise ignored. + # TODO-deprecated: Remove this and warning when direct options are hard-deprecated + is_default <- attr(options_user, "is_default") %||% list() + keep_user_values <- vapply( + names(options_user), + function(x) !isTRUE(is_default[[x]]), + logical(1) + ) + options_user <- options_user[keep_user_values] + + ignored <- c() + for (opt in names(options_old)) { + if (!opt %in% names(options_user)) { + options_user[[opt]] <- options_old[[opt]] + } else if (!identical(options_old[[opt]], options_user[[opt]])) { + ignored <- c(ignored, if (opt == "theme") "inverse" else opt) + } + } + + if (length(ignored) > 0) { + rlang::warn( + c( + sprintf( + "`%s` %s provided twice: once directly and once in `navbar_options`.", + paste(ignored, collapse = "`, `"), + if (length(ignored) == 1) "was" else "were" + ), + "The deprecated direct option(s) will be ignored and the values from `navbar_options` will be used." + ), + call = rlang::caller_call() + ) + } + + attribs <- options_user[["attribs"]] %||% list() + options_user$attribs <- NULL + + rlang::exec(navbar_options, !!!options_user, !!!attribs) +} + +#' @export +print.bslib_navbar_options <- function(x, ...) { + cat("\n") + + if (length(x) == 0) { + return(invisible(x)) + } + + fields <- names(x) + opt_w <- max(nchar(fields)) + is_default <- attr(x, "is_default") %||% list() + for (opt in fields) { + value <- x[[opt]] %||% "NULL" + if (inherits(value, "list")) { + value <- paste(names(value), collapse = ", ") + } + if (isTRUE(is_default[[opt]])) { + if (identical(value, "NULL")) { + # Skip printing default NULL values + next + } + value <- sprintf("(%s)", value) + } + cat(sprintf("%*s", opt_w, opt), ": ", value, "\n", sep = "") + } + + invisible(x) +} diff --git a/R/navs-legacy.R b/R/navs-legacy.R index 3227ca121..8b00d97f5 100644 --- a/R/navs-legacy.R +++ b/R/navs-legacy.R @@ -166,216 +166,6 @@ navset_bar <- function( ) } -#' Create a set of navbar options -#' -#' A `navbar_options()` object captures options specific to the appearance and -#' behavior of the navbar, independent from the content displayed on the page. -#' This helper should be used to create the list of options expected by -#' `navbar_options` in [page_navbar()] and [navset_bar()]. -#' -#' ## Changelog -#' -#' This function was introduced in \pkg{bslib} v0.9.0, replacing the `position`, -#' `bg`, `inverse`, `collapsible` and `underline` arguments of [page_navbar()] -#' and [navset_bar()]. Those arguments are deprecated with a warning and will be -#' removed in a future version of \pkg{bslib}. Note that the deprecated -#' `inverse` argument of [page_navbar()] and [navset_bar()] was replaced with -#' the `theme` argument of `navbar_options()`. -#' -#' @examples -#' navbar_options(position = "static-top", bg = "#2e9f7d", underline = FALSE) -#' -#' @inheritParams shiny::navbarPage -#' @param bg a CSS color to use for the navbar's background color. -#' @param theme Either `"dark"` for a light text color (on a **dark** -#' background) or `"light"` for a dark text color (on a **light** background). -#' If `"auto"` (the default) and `bg` is provided, the best contrast to `bg` -#' is chosen. -#' @param underline Whether or not to add underline styling to page or navbar -#' links when active or focused. -#' @param ... Additional attributes that will be passed directly to the navbar -#' container element. -#' -#' @returns Returns a list of navbar options. -#' -#' @export -navbar_options <- function( - ..., - position = c("static-top", "fixed-top", "fixed-bottom"), - bg = NULL, - theme = c("auto", "light", "dark"), - collapsible = TRUE, - underline = TRUE -) { - # Track user-provided arguments for print method and deprecation warnings - is_default <- list( - position = missing(position), - bg = missing(bg), - theme = missing(theme), - collapsible = missing(collapsible), - underline = missing(underline) - ) - - opts <- list( - position = rlang::arg_match(position), - bg = bg, - theme = rlang::arg_match(theme), - collapsible = collapsible, - underline = underline - ) - - dots <- separate_arguments(...) - if (length(dots$children) > 0) { - abort("All arguments in `...` must be named attributes to be applied to the navbar container.") - } - - if ("inverse" %in% names(dots$attribs)) { - # Catch muscle-memory for using `inverse`. We didn't officially release - # `navbar_options()` with an `inverse` argument, but it's reasonable people - # might try to use it and it did exist briefly in dev versions. - lifecycle::deprecate_soft( - when = "0.9.0", - what = "navbar_options(inverse=)", - with = "navbar_options(theme=)" - ) - } - if (length(dots$attribs)) { - opts$attribs <- dots$attribs - } - - structure( - opts, - class = c("bslib_navbar_options", "list"), - is_default = is_default, - waldo_opts = list(ignore_attr = TRUE) - ) -} - -navbar_options_resolve_deprecated <- function( - options_user = list(), - position = deprecated(), - bg = deprecated(), - inverse = deprecated(), - collapsible = deprecated(), - underline = deprecated(), - .fn_caller = "navset_bar", - .warn_deprecated = TRUE -) { - options_old <- list( - position = if (lifecycle::is_present(position)) position, - bg = if (lifecycle::is_present(bg)) bg, - inverse = if (lifecycle::is_present(inverse)) inverse, - collapsible = if (lifecycle::is_present(collapsible)) collapsible, - underline = if (lifecycle::is_present(underline)) underline - ) - options_old <- dropNulls(options_old) - - args_deprecated <- names(options_old) - - if (.warn_deprecated && length(args_deprecated)) { - # TODO-deprecated: (2024-12) Elevate deprecation to an error - lifecycle::deprecate_warn( - "0.9.0", - I(sprintf( - "The arguments of `%s()` for navbar options (including %s) have been consolidated into a single `navbar_options` argument and ", - .fn_caller, - paste(sprintf("`%s`", args_deprecated), collapse = ", ") - )), - details = c( - "i" = "See `navbar_options()` for more details.", - "!" = if ("inverse" %in% args_deprecated) - "Use `theme` instead of `inverse` in `navbar_options()`." - ) - ) - } - - # Upgrade `inverse` to the new `theme` argument of `navbar_options()` - if ("inverse" %in% names(options_old)) { - inverse <- options_old[["inverse"]] - options_old[["inverse"]] <- NULL - - options_old[["theme"]] <- - if (is.character(inverse)) { - inverse - } else if (isTRUE(as.logical(inverse))) { - options_old[["theme"]] <- "dark" - } else if (isFALSE(as.logical(inverse))) { - options_old[["theme"]] <- "light" - } else { - abort(paste("Invalid `inverse` value: ", inverse)) - } - } - - # Consolidate `navbar_options` (options_user) with the deprecated direct - # options. We take the direct option if the user option is a default value, - # warning if otherwise ignored. - # TODO-deprecated: Remove this and warning when direct options are hard-deprecated - is_default <- attr(options_user, "is_default") %||% list() - keep_user_values <- vapply( - names(options_user), - function(x) !isTRUE(is_default[[x]]), - logical(1) - ) - options_user <- options_user[keep_user_values] - - ignored <- c() - for (opt in names(options_old)) { - if (!opt %in% names(options_user)) { - options_user[[opt]] <- options_old[[opt]] - } else if (!identical(options_old[[opt]], options_user[[opt]])) { - ignored <- c(ignored, if (opt == "theme") "inverse" else opt) - } - } - - if (length(ignored) > 0) { - rlang::warn( - c( - sprintf( - "`%s` %s provided twice: once directly and once in `navbar_options`.", - paste(ignored, collapse = "`, `"), - if (length(ignored) == 1) "was" else "were" - ), - "The deprecated direct option(s) will be ignored and the values from `navbar_options` will be used." - ), - call = rlang::caller_call() - ) - } - - attribs <- options_user[["attribs"]] %||% list() - options_user$attribs <- NULL - - rlang::exec(navbar_options, !!!options_user, !!!attribs) -} - -#' @export -print.bslib_navbar_options <- function(x, ...) { - cat("\n") - - if (length(x) == 0) { - return(invisible(x)) - } - - fields <- names(x) - opt_w <- max(nchar(fields)) - is_default <- attr(x, "is_default") %||% list() - for (opt in fields) { - value <- x[[opt]] %||% "NULL" - if (inherits(value, "list")) { - value <- paste(names(value), collapse = ", ") - } - if (isTRUE(is_default[[opt]])) { - if (identical(value, "NULL")) { - # Skip printing default NULL values - next - } - value <- sprintf("(%s)", value) - } - cat(sprintf("%*s", opt_w, opt), ": ", value, "\n", sep = "") - } - - invisible(x) -} - # This internal version of navs_bar() exists so both it and page_navbar() # (and thus shiny::navbarPage()) can use it. And in the page_navbar() case, diff --git a/man/navbar_options.Rd b/man/navbar_options.Rd index 1d3c85ae2..c9a60c55d 100644 --- a/man/navbar_options.Rd +++ b/man/navbar_options.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/navs-legacy.R +% Please edit documentation in R/navbar_options.R \name{navbar_options} \alias{navbar_options} \title{Create a set of navbar options} diff --git a/tests/testthat/_snaps/navbar_options.md b/tests/testthat/_snaps/navbar_options.md new file mode 100644 index 000000000..3384c43e1 --- /dev/null +++ b/tests/testthat/_snaps/navbar_options.md @@ -0,0 +1,34 @@ +# navbar_options() print method + + Code + navbar_options() + Output + + position: (static-top) + theme: (auto) + collapsible: (TRUE) + underline: (TRUE) + +--- + + Code + navbar_options(theme = "dark", bg = "red") + Output + + position: (static-top) + bg: red + theme: dark + collapsible: (TRUE) + underline: (TRUE) + +--- + + Code + navbar_options(position = "static-top", theme = "auto", collapsible = TRUE) + Output + + position: static-top + theme: auto + collapsible: TRUE + underline: (TRUE) + diff --git a/tests/testthat/_snaps/navs-legacy.md b/tests/testthat/_snaps/navs-legacy.md index 24bb12d19..06097861f 100644 --- a/tests/testthat/_snaps/navs-legacy.md +++ b/tests/testthat/_snaps/navs-legacy.md @@ -1,37 +1,3 @@ -# navbar_options() print method - - Code - navbar_options() - Output - - position: (static-top) - theme: (auto) - collapsible: (TRUE) - underline: (TRUE) - ---- - - Code - navbar_options(theme = "dark", bg = "red") - Output - - position: (static-top) - bg: red - theme: dark - collapsible: (TRUE) - underline: (TRUE) - ---- - - Code - navbar_options(position = "static-top", theme = "auto", collapsible = TRUE) - Output - - position: static-top - theme: auto - collapsible: TRUE - underline: (TRUE) - # navbar markup snapshots Code diff --git a/tests/testthat/test-navbar_options.R b/tests/testthat/test-navbar_options.R new file mode 100644 index 000000000..b9f05d699 --- /dev/null +++ b/tests/testthat/test-navbar_options.R @@ -0,0 +1,175 @@ +test_that("navbar_options() validates position", { + expect_equal( + navbar_options(position = "fixed-bottom")$position, + "fixed-bottom" + ) + + expect_error(navbar_options(position = "bad")) +}) + +test_that("navbar_options() print method", { + expect_snapshot(navbar_options()) + expect_snapshot(navbar_options(theme = "dark", bg = "red")) + expect_snapshot( + navbar_options(position = "static-top", theme = "auto", collapsible = TRUE) + ) + + expect_output( + print(navbar_options()), + "" + ) +}) + +test_that("navbar_options() adds named args from ... to `attribs`", { + expect_equal(navbar_options(foo = "bar")$attribs, list(foo = "bar")) +}) + +test_that("navbar_options() throws for unnamed args in ...", { + expect_error(navbar_options("foo", "bar")) +}) + +test_that("navbar_options() warns `inverse` is used instead of `type`", { + lifecycle::expect_deprecated( + navbar_options(inverse = TRUE) + ) +}) + +test_that("navbar_options_resolve_deprecated() consolidates correctly", { + # TODO-deprecated: Remove when direction options are deprecated with an error + + # deprecation messages are handled through other tests + rlang::local_options(lifecycle_verbosity = "quiet") + + expect_equal( + navbar_options_resolve_deprecated(navbar_options(), bg = "red")$bg, + "red" + ) + + expect_equal( + navbar_options_resolve_deprecated(list(), bg = "red")$bg, + "red" + ) + + expect_warning( + expect_equal( + navbar_options_resolve_deprecated( + navbar_options(bg = "blue"), + bg = "red" + )$bg, + "blue" + ) + ) + + expect_warning( + expect_equal( + navbar_options_resolve_deprecated(list(bg = "blue"), bg = "red")$bg, + "blue" + ) + ) + + expect_warning( + expect_null( + navbar_options_resolve_deprecated( + navbar_options(bg = NULL), + bg = "red" + )$bg + ) + ) + + expect_warning( + expect_null( + navbar_options_resolve_deprecated(list(bg = NULL), bg = "red")$bg + ) + ) + + expect_equal( + attr(navbar_options(underline = FALSE), "is_default"), + attr(navbar_options_resolve_deprecated(underline = FALSE), "is_default") + ) +}) + +test_that("navbar_options_resolve_deprecated() upgrades `inverse` to `type`", { + # TODO-deprecated: Remove when direction options are deprecated with an error + + # deprecation messages are handled through other tests + rlang::local_options(lifecycle_verbosity = "quiet") + + expect_equal( + navbar_options_resolve_deprecated(navbar_options(), inverse = TRUE)$theme, + "dark" + ) + + expect_equal( + navbar_options_resolve_deprecated(navbar_options(), inverse = FALSE)$theme, + "light" + ) + + expect_equal( + navbar_options_resolve_deprecated(navbar_options(), inverse = "auto")$theme, + "auto" + ) + + expect_warning( + expect_equal( + navbar_options_resolve_deprecated( + navbar_options(theme = "light"), + inverse = TRUE + )$theme, + "light" + ) + ) + + expect_warning( + expect_equal( + navbar_options_resolve_deprecated( + navbar_options(theme = "dark"), + inverse = FALSE + )$theme, + "dark" + ) + ) +}) + +test_that("navbar_options_resolve_deprecated() prefers user options over deprecated direct options", { + rlang::local_options(lifecycle_verbosity = "quiet") + + expect_warning( + expect_equal( + navbar_options_resolve_deprecated( + position = "fixed-top", + options_user = navbar_options(position = "static-top") + )$position, + "static-top" + ) + ) + + expect_warning( + expect_equal( + navbar_options_resolve_deprecated( + bg = "red", + options_user = navbar_options(bg = "blue") + )$bg, + "blue" + ) + ) + + expect_warning( + expect_equal( + navbar_options_resolve_deprecated( + inverse = TRUE, + options_user = navbar_options(theme = "light") + )$theme, + "light" + ) + ) + + expect_warning( + expect_equal( + navbar_options_resolve_deprecated( + collapsible = FALSE, + options_user = navbar_options(collapsible = TRUE) + )$collapsible, + TRUE + ) + ) +}) diff --git a/tests/testthat/test-navs-legacy.R b/tests/testthat/test-navs-legacy.R index bdc0a3658..3f5ffedc9 100644 --- a/tests/testthat/test-navs-legacy.R +++ b/tests/testthat/test-navs-legacy.R @@ -1,123 +1,3 @@ -test_that("navbar_options() validates position", { - expect_equal( - navbar_options(position = "fixed-bottom")$position, - "fixed-bottom" - ) - - expect_error(navbar_options(position = "bad")) -}) - -test_that("navbar_options() print method", { - expect_snapshot(navbar_options()) - expect_snapshot(navbar_options(theme = "dark", bg = "red")) - expect_snapshot( - navbar_options(position = "static-top", theme = "auto", collapsible = TRUE) - ) - - expect_output( - print(navbar_options()), - "" - ) -}) - -test_that("navbar_options() adds named args from ... to `attribs`", { - expect_equal(navbar_options(foo = "bar")$attribs, list(foo = "bar")) -}) - -test_that("navbar_options() throws for unnamed args in ...", { - expect_error(navbar_options("foo", "bar")) -}) - -test_that("navbar_options() warns `inverse` is used instead of `type`", { - lifecycle::expect_deprecated( - navbar_options(inverse = TRUE) - ) -}) - -test_that("navbar_options_resolve_deprecated() consolidates correctly", { - # TODO-deprecated: Remove when direction options are deprecated with an error - - # deprecation messages are handled through other tests - rlang::local_options(lifecycle_verbosity = "quiet") - - expect_equal( - navbar_options_resolve_deprecated(navbar_options(), bg = "red")$bg, - "red" - ) - - expect_equal( - navbar_options_resolve_deprecated(list(), bg = "red")$bg, - "red" - ) - - expect_warning( - expect_equal( - navbar_options_resolve_deprecated(navbar_options(bg = "blue"), bg = "red")$bg, - "blue" - ) - ) - - expect_warning( - expect_equal( - navbar_options_resolve_deprecated(list(bg = "blue"), bg = "red")$bg, - "blue" - ) - ) - - expect_warning( - expect_null( - navbar_options_resolve_deprecated(navbar_options(bg = NULL), bg = "red")$bg - ) - ) - - expect_warning( - expect_null( - navbar_options_resolve_deprecated(list(bg = NULL), bg = "red")$bg - ) - ) - - expect_equal( - attr(navbar_options(underline = FALSE), "is_default"), - attr(navbar_options_resolve_deprecated(underline = FALSE), "is_default") - ) -}) - -test_that("navbar_options_resolve_deprecated() upgrades `inverse` to `type`", { - # TODO-deprecated: Remove when direction options are deprecated with an error - - # deprecation messages are handled through other tests - rlang::local_options(lifecycle_verbosity = "quiet") - - expect_equal( - navbar_options_resolve_deprecated(navbar_options(), inverse = TRUE)$theme, - "dark" - ) - - expect_equal( - navbar_options_resolve_deprecated(navbar_options(), inverse = FALSE)$theme, - "light" - ) - - expect_equal( - navbar_options_resolve_deprecated(navbar_options(), inverse = "auto")$theme, - "auto" - ) - - expect_warning( - expect_equal( - navbar_options_resolve_deprecated(navbar_options(theme = "light"), inverse = TRUE)$theme, - "light" - ) - ) - - expect_warning( - expect_equal( - navbar_options_resolve_deprecated(navbar_options(theme = "dark"), inverse = FALSE)$theme, - "dark" - ) - ) -}) - test_that("navset_bar() warns if using deprecated args", { lifecycle::expect_deprecated( navset_bar(position = "fixed-top") @@ -165,50 +45,6 @@ test_that("navset_bar() warns if `navbar_options()` collide with direct deprecat ) }) -test_that("navbar_options_resolve_deprecated() prefers user options over deprecated direct options", { - rlang::local_options(lifecycle_verbosity = "quiet") - - expect_warning( - expect_equal( - navbar_options_resolve_deprecated( - position = "fixed-top", - options_user = navbar_options(position = "static-top") - )$position, - "static-top" - ) - ) - - expect_warning( - expect_equal( - navbar_options_resolve_deprecated( - bg = "red", - options_user = navbar_options(bg = "blue") - )$bg, - "blue" - ) - ) - - expect_warning( - expect_equal( - navbar_options_resolve_deprecated( - inverse = TRUE, - options_user = navbar_options(theme = "light") - )$theme, - "light" - ) - ) - - expect_warning( - expect_equal( - navbar_options_resolve_deprecated( - collapsible = FALSE, - options_user = navbar_options(collapsible = TRUE) - )$collapsible, - TRUE - ) - ) -}) - test_that("shiny:navbarPage() is unaffected", { rlang::local_options(lifecycle_verbosity = "warning") @@ -248,49 +84,76 @@ test_that("navbar markup snapshots", { expect_snapshot( show_navbar_markup( - navs_bar_(theme = bs_theme(version = 4), navbar_options = navbar_options(theme = "dark")) + navs_bar_( + theme = bs_theme(version = 4), + navbar_options = navbar_options(theme = "dark") + ) ) ) expect_snapshot( show_navbar_markup( - navs_bar_(theme = bs_theme(version = 4), navbar_options = navbar_options(theme = "light")) + navs_bar_( + theme = bs_theme(version = 4), + navbar_options = navbar_options(theme = "light") + ) ) ) expect_snapshot( show_navbar_markup( - navs_bar_(theme = bs_theme(version = 4), navbar_options = navbar_options(bg = "#000")) + navs_bar_( + theme = bs_theme(version = 4), + navbar_options = navbar_options(bg = "#000") + ) ) ) expect_snapshot( show_navbar_markup( - navs_bar_(theme = bs_theme(version = 5), navbar_options = navbar_options(theme = "dark")) + navs_bar_( + theme = bs_theme(version = 5), + navbar_options = navbar_options(theme = "dark") + ) ) ) expect_snapshot( show_navbar_markup( - navs_bar_(theme = bs_theme(version = 5), navbar_options = navbar_options(theme = "light")) + navs_bar_( + theme = bs_theme(version = 5), + navbar_options = navbar_options(theme = "light") + ) ) ) expect_snapshot( show_navbar_markup( - navs_bar_(theme = bs_theme(version = 5), navbar_options = navbar_options(bg = "#000")) + navs_bar_( + theme = bs_theme(version = 5), + navbar_options = navbar_options(bg = "#000") + ) ) ) expect_snapshot( show_navbar_markup( - navs_bar_(theme = bs_theme(version = 5), navbar_options = navbar_options(theme = "light", `data-bs-theme` = "dark")) + navs_bar_( + theme = bs_theme(version = 5), + navbar_options = navbar_options( + theme = "light", + `data-bs-theme` = "dark" + ) + ) ) ) expect_snapshot( show_navbar_markup( - navs_bar_(theme = bs_theme(version = 5), navbar_options = navbar_options(class = "bg-primary", theme = "dark")) + navs_bar_( + theme = bs_theme(version = 5), + navbar_options = navbar_options(class = "bg-primary", theme = "dark") + ) ) ) })