Skip to content

Commit

Permalink
Conditionally set navbar bg
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed May 22, 2024
1 parent 393e164 commit cb18b29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 12 additions & 7 deletions R/navbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ data_navbar <- function(pkg = ".", depth = 0L) {
pkg <- as_pkgdown(pkg)

navbar <- config_pluck(pkg, "navbar")

style <- navbar_style(
navbar = navbar,
theme = get_bslib_theme(pkg),
bs_version = pkg$bs_version
)


uses_lightswitch <- !is.null(config_pluck_string(pkg, "template.theme-dark"))
if (uses_lightswitch) {
style <- NULL
} else {
style <- navbar_style(
navbar = navbar,
theme = get_bslib_theme(pkg),
bs_version = pkg$bs_version
)
}

links <- navbar_links(pkg, depth = depth)

c(style, links)
Expand Down
6 changes: 6 additions & 0 deletions inst/BS5/assets/pkgdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

/* navbar =================================================================== */

.navbar {
background: mix(mix($body-bg, $body-color, 95%), $primary, 98%);
}
[data-bs-theme="dark"] .navbar {
background: mix(mix($body-bg-dark, $body-color-dark, 95%), $primary, 98%);
}
// make both the active nav and the hovered nav more clear by mixing the
// background colour with the body and primary colours respectively
.nav-item .nav-link {
Expand Down

0 comments on commit cb18b29

Please sign in to comment.