Skip to content

feat: Support light and dark brand colors - #1344

Draft
gadenbuie wants to merge 7 commits into
mainfrom
feat/brand-color-light-dark
Draft

feat: Support light and dark brand colors#1344
gadenbuie wants to merge 7 commits into
mainfrom
feat/brand-color-light-dark

Conversation

@gadenbuie

Copy link
Copy Markdown
Member

Companion to posit-dev/brand-yml#120.

Summary

Adds light/dark brand.yml color and typography support to bs_theme(brand = ...), using Bootstrap's existing data-bs-theme runtime contract.

  • Keeps the current Sass compilation as the default/light theme and appends a dark-mode compilation only when the brand defines mode-dependent values.
  • Recompiles Bootstrap component and utility rules under [data-bs-theme="dark"] so Sass-derived styles such as buttons update together with CSS custom properties.
  • Preserves scalar brand behavior and leaves Bootstrap defaults intact when a light or dark branch is undefined.
  • Preserves brand metadata and HTML dependencies through public theme mutators and the appended dark CSS cache artifact.
  • Handles expanded and compressed Sass output with charset or BOM prefixes.
  • Requires the development brand.yml version that provides the paired light/dark Sass contract.

Verification

brand <- brand.yml::as_brand_yml(
  "
  color:
    primary: { light: '#0d6efd', dark: '#6ea8fe' }
    background: { light: '#ffffff', dark: '#212529' }
    foreground: { light: '#212529', dark: '#f8f9fa' }
  "
)
theme <- bslib::bs_theme(brand = brand)

bslib::bs_theme_dependencies(theme)
# Generated CSS responds to:
#   document.documentElement.dataset.bsTheme = "light"
#   document.documentElement.dataset.bsTheme = "dark"
  • Focused brand theme tests pass with 182 expectations.
  • Full devtools::test() suite passes with 1,305 expectations.
  • Browser coverage verifies computed button, body, and link styles while switching modes at runtime.
  • Air formatting and git diff --check pass.
  • R CMD check --no-manual passes with 0 errors, warnings, or notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant