Clarify theming of dropdown in dark mode

Open
#2,967 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
bootstrap, r, scss
Domain
documentation

Research direction

Start by building the example site with and without extra.scss, using the _pkgdown.yml configuration. Compare the generated navbar dropdown behavior with the dropdown-dark-* variables and inspect the linked bslib _variables.scss reference; done means the dark-mode dropdown respects those variables without custom SCSS, or the intended limitation is documented.

Written by the indexing model from the issue text.

Description

For some $dropdown- variables, {bslib} has light and dark mode variants.

https://github.com/rstudio/bslib/blob/bc56d8e7671b6c1c41c041b6992e24cf1a4bc05f/inst/lib/bs5/scss/_variables.scss#L1296

When building a pkgdown site with light-switch: true, I expect the navbar dropdowns to respect the dropdown-dark-* variables defined in _pkgdown.yml. Instead, these variables appear to be ignored—dropdowns remain in light mode (no [data-bs-theme="dark"] applied) unless I add custom SCSS rules.

So far, I haven't understood why these variables are being ignored. I would appreciate understanding this and whether this is intended behavior or if we can change it.

The _pkgdown.yml and extra.scss files below can be used to illustrate the issue (colors may be sufficient for the actual purpose but not for real life). Build the site with and without extra.scss.

_pkgdown.yml:

url: ~
template:
  light-switch: true
  bslib:
    version: 5
    preset: default
    # Make it obvious which mode we are in
    body-bg: "#F0ECDA"
    body-bg-dark: "#192D3C"
    body-color: "#152740"
    body-color-dark: "#F0F0F0"
    navbar-light-bg: "#487F86"
    navbar-dark-bg: "#96AAAA"

    # What we care about in this issue
    dropdown-link-hover-bg: "#797292"
    dropdown-dark-link-hover-bg: "#23857A"
    dropdown-link-active-bg: "rgba($dropdown-link-hover-bg, .4)"
    dropdown-dark-link-active-bg: "rgba($dropdown-dark-link-hover-bg, .4)"
    dropdown-link-active-color: "$body-color"
    dropdown-dark-link-active-color: "$body-color-dark"

extra.scss

/*-- scss:rules --*/

[data-bs-theme="dark"] .dropdown-item {
  color: $body-color-dark;

  &.active, &:active {
    background-color: rgba(#C88200,.4);
  }

  &:hover, &:focus {
    background-color: #C88200;
  }
}
Dominant language
R
Stars
775
Forks
355
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/pkgdown

All issues in r-lib/pkgdown

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.