diff --git a/R/navbar.R b/R/navbar.R index d30ee9ae4..9b4300ec0 100644 --- a/R/navbar.R +++ b/R/navbar.R @@ -21,10 +21,10 @@ navbar_style <- function(navbar = list(), theme = "_default", bs_version = 3) { list(type = navbar$type %||% "default") } else { # bg is usually light, dark, or primary, but can use any .bg-* - bg <- navbar$bg %||% purrr::pluck(bootswatch_bg, theme, .default = "light") + bg <- navbar$bg %||% bootswatch_bg[[theme]] %||% "light" type <- navbar$type %||% if (bg == "light") "light" else "dark" - list(bg = bg, type = type) + list(bg = bg, is_dark = type == "dark") } } @@ -229,7 +229,7 @@ pkg_navbar_vignettes <- function(name = character(), # Scraped from bootswatch preivews, see code in # -bootswatch_bg <- c( +bootswatch_bg <- list( "_default" = "light", cerulean = "primary", cosmo = "primary", diff --git a/inst/BS5/assets/pkgdown.scss b/inst/BS5/assets/pkgdown.scss index a86b46d21..683091306 100644 --- a/inst/BS5/assets/pkgdown.scss +++ b/inst/BS5/assets/pkgdown.scss @@ -20,11 +20,16 @@ /* navbar =================================================================== */ -// boostrap doesn't style active/hovered nav making it hard to see where -// you are and where you're going, so we add our own styling -.navbar-nav .nav-item > .nav-link { +// make both the active nav and the hovered nav more clear by mixing the +// background colour with the body and primary colours respectively +.navbar-nav .nav-item > a { @include border-radius($border-radius); - padding: 0.5rem; +} +.nav-item.active > a { background: mix($body-bg, $body-color, 90%); } +.nav-item > a:hover { background: mix($body-bg, $primary, 90%); } +[data-bs-theme="dark"] { + .nav-item.active > a { background: mix($body-bg-dark, $body-color-dark, 90%); } + .nav-item > a:hover { background: mix($body-bg-dark, $primary, 90%); } } // Align baselines of package name, version, and nav items @@ -33,30 +38,8 @@ -webkit-align-items: baseline; } -.navbar-light .navbar-nav .active > .nav-link { - background: $gray-200; - color: $body-color; -} -.navbar-dark .navbar-nav .active > .nav-link { - background: $gray-800; - color: $body-bg; -} - -.navbar-dark .navbar-nav .nav-item > .nav-link:hover, -.navbar-light .navbar-nav .nav-item > .nav-link:hover { - background: change-color($primary, $alpha: 0.1); -} - -.navbar-dark { - input[type="search"] { - border-color: $gray-600; - background-color: $gray-900; - color: $gray-200; - } -} - +// Make search a little narrower than the default input[type="search"] { - border-color: $border-color; width: 12rem; } diff --git a/inst/BS5/templates/navbar.html b/inst/BS5/templates/navbar.html index c13e8b08a..82da65810 100644 --- a/inst/BS5/templates/navbar.html +++ b/inst/BS5/templates/navbar.html @@ -1,5 +1,5 @@ {{#navbar}} -