diff --git a/DESCRIPTION b/DESCRIPTION index 5473ca1eb..81f41c8ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -111,7 +111,7 @@ Config/testthat/parallel: true Config/testthat/start-first: zzzz-bs-sass, fonts, zzz-precompile, theme-*, rmd-* Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Collate: 'accordion.R' 'breakpoints.R' diff --git a/R/sysdata.rda b/R/sysdata.rda index 4f1e95705..6d77d9f68 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/_pkgdown.yml b/_pkgdown.yml index 7bf7cabff..bb145c9c5 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -22,20 +22,16 @@ template: docsearch: api_key: 53fd87c79a13e431b4298611470d023a index_name: bslib - includes: - in_header: > - + light-switch: true navbar: bg: info type: light structure: left: [get-started, examples, theming, components, layouts] - right: [reference, news, github, dark-mode] + right: [reference, news, github, lightswitch] components: home: ~ - dark-mode: - href: "#dark-mode" get-started: text: Get Started @@ -86,6 +82,7 @@ navbar: github: icon: bi-github + aria-label: GitHub href: https://github.com/rstudio/bslib news: diff --git a/man/value_box.Rd b/man/value_box.Rd index 298fd509e..2e7e108c0 100644 --- a/man/value_box.Rd +++ b/man/value_box.Rd @@ -303,9 +303,7 @@ Like with the \verb{bg-} theme names, if only \code{bg} is provided, \code{value Note that \code{value_box_theme()} optionally takes a \code{theme} name, which can be helpful if you want to use a named theme and modify the default \code{bg} or \code{fg} colors of that theme. \if{html}{\out{
}}\preformatted{value_box_theme(name = "orange", bg = "#FFFFFF") -}\if{html}{\out{
}} - -\if{html}{\out{
}}\preformatted{value_box_theme(name = "text-danger", fg = "#FFB6C1") +value_box_theme(name = "text-danger", fg = "#FFB6C1") }\if{html}{\out{
}} Also note that \code{bg}/\code{fg} \emph{must} be CSS colors, not Bootstrap theme or color names. diff --git a/pkgdown/extra.js b/pkgdown/extra.js deleted file mode 100644 index cf924db86..000000000 --- a/pkgdown/extra.js +++ /dev/null @@ -1,133 +0,0 @@ -/*! - * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/) - * Copyright 2011-2023 The Bootstrap Authors - * Licensed under the Creative Commons Attribution 3.0 Unported License. - * Updates for {pkgdown} by the {bslib} authors, also licensed under CC-BY-3.0. - */ - -const getStoredTheme = () => localStorage.getItem('theme') -const setStoredTheme = theme => localStorage.setItem('theme', theme) - -const getPreferredTheme = () => { - const storedTheme = getStoredTheme() - if (storedTheme) { - return storedTheme - } - - return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' -} - -const setTheme = theme => { - if (theme === 'auto') { - document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) - } else { - document.documentElement.setAttribute('data-bs-theme', theme) - } -} - -setTheme(getPreferredTheme()) - -function bsSetupThemeToggle () { - 'use strict' - - const showActiveTheme = (theme, focus = false) => { - const themeSwitcher = document.querySelector('#bd-theme') - - if (!themeSwitcher) { - return - } - - const themeSwitcherText = document.querySelector('#bd-theme-text') - const activeThemeIcon = document.querySelector('.theme-icon-active') - const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`) - const svgOfActiveBtn = btnToActive.querySelector('.theme-icon').innerHTML - - document.querySelectorAll('[data-bs-theme-value]').forEach(element => { - element.classList.remove('active') - element.setAttribute('aria-pressed', 'false') - }) - - btnToActive.classList.add('active') - btnToActive.setAttribute('aria-pressed', 'true') - activeThemeIcon.innerHTML = svgOfActiveBtn - const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})` - themeSwitcher.setAttribute('aria-label', themeSwitcherLabel) - - if (focus) { - themeSwitcher.focus() - } - } - - window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { - const storedTheme = getStoredTheme() - if (storedTheme !== 'light' && storedTheme !== 'dark') { - setTheme(getPreferredTheme()) - } - }) - - window.addEventListener('DOMContentLoaded', () => { - showActiveTheme(getPreferredTheme()) - - document.querySelectorAll('[data-bs-theme-value]') - .forEach(toggle => { - toggle.addEventListener('click', () => { - const theme = toggle.getAttribute('data-bs-theme-value') - setStoredTheme(theme) - setTheme(theme) - showActiveTheme(theme, true) - }) - }) - }) -} - -function colorPickerMarkup () { - const svgs = { - "sun-fill": ``, - "moon-stars-fill": ``, - "circle-half": `` - } - - const icons = { - "sun-fill": ``, - "moon-stars-fill": ``, - "circle-half": `` - } - - return ` - ` -} - -document.addEventListener('DOMContentLoaded', () => { - const switcher = document.querySelector('.navbar [href$="#dark-mode"]') - if (!switcher) return - - switcher.parentElement.classList.add('dropdown') - switcher.parentElement.innerHTML = colorPickerMarkup() - bsSetupThemeToggle() -}) diff --git a/vignettes/any-project/index.Rmd b/vignettes/any-project/index.Rmd index 2748d7995..6f020fadf 100644 --- a/vignettes/any-project/index.Rmd +++ b/vignettes/any-project/index.Rmd @@ -139,6 +139,7 @@ output: ::: col-md-6 ```{r, echo = FALSE} +#| fig.alt: RStudio "New Template" dialog showing three theming-related templates from bslib. knitr::include_graphics("rstudio-templates.png") ``` ::: diff --git a/vignettes/cards/index.Rmd b/vignettes/cards/index.Rmd index df6f64d2d..0bb3911ca 100644 --- a/vignettes/cards/index.Rmd +++ b/vignettes/cards/index.Rmd @@ -375,6 +375,7 @@ card( full_screen = TRUE, card_image( file = "shiny-hex.svg", + alt = "Shiny's hex sticker", href = "https://github.com/rstudio/shiny" ), card_body( diff --git a/vignettes/custom-components/index.Rmd b/vignettes/custom-components/index.Rmd index 04e57baa0..3258426f2 100644 --- a/vignettes/custom-components/index.Rmd +++ b/vignettes/custom-components/index.Rmd @@ -64,6 +64,7 @@ shinyApp(ui, function(input, output) {}) ``` ```{r, echo = FALSE, out.width="67%"} +#| fig.alt: Two custom person components, one each for Andrew Carnegie and John D. Rockefeller. knitr::include_graphics("person.png") ``` diff --git a/vignettes/theming/index.Rmd b/vignettes/theming/index.Rmd index eb531d3cf..6dcf25388 100644 --- a/vignettes/theming/index.Rmd +++ b/vignettes/theming/index.Rmd @@ -82,6 +82,7 @@ knitr::include_graphics("themer.gif") When running the theming widget locally, you'll see output like this in your R console (in R Markdown, you'll see YAML output instead of R code) to reproduce the theming changes: ```{r, echo = FALSE, out.width="80%"} +#| fig.alt: Console output showing the R code to reproduce the theming changes. knitr::include_graphics("themer-code.png") ``` @@ -108,6 +109,7 @@ output: ```{r, echo = FALSE} +#| fig.alt: A screenshot of the minty Bootswatch theme. knitr::include_graphics("bootswatch.png") ``` @@ -153,6 +155,7 @@ output: ::: ```{r, echo = FALSE} +#| fig.alt: A screenshot showing a dark mode theme with custom fonts. knitr::include_graphics("custom-dark-mode.png") ``` @@ -199,6 +202,7 @@ output: ```{r, echo = FALSE, out.width="67%"} +#| fig.alt: A progress bar indicator colored orange. knitr::include_graphics("progress-orange.png") ``` @@ -275,6 +279,7 @@ bs_theme( ``` ```{r, echo = FALSE} +#| fig.alt: A screenshot showing a Shiny app with a video game style thanks to NES.css. knitr::include_graphics("nes.png") ``` @@ -342,6 +347,7 @@ shinyApp(ui, server) ``` ```{r, echo = FALSE, out.width="50%"} +#| fig.alt: An animation showing a dark mode switch in a Shiny app toggling on and off. knitr::include_graphics("dark-mode.gif") ``` diff --git a/vignettes/utility-classes/index.Rmd b/vignettes/utility-classes/index.Rmd index ead697d6a..cf6e689e2 100644 --- a/vignettes/utility-classes/index.Rmd +++ b/vignettes/utility-classes/index.Rmd @@ -30,6 +30,7 @@ tabsetPanel( ``` ```{r, echo = FALSE, out.width="67%"} +#| fig.alt: A tabset panel without padding or borders, showing plain text placed directly against the tab's bottom border. knitr::include_graphics("tab-before.png") ``` @@ -46,6 +47,7 @@ tabsetPanel( ``` ```{r, echo = FALSE, out.width="67%"} +#| fig.alt: A tabset panel with padding and borders, showing a border around the tab content and padding between the tab content and the tab's border. knitr::include_graphics("tab-after.png") ``` @@ -63,16 +65,19 @@ tabsetPanel( ``` ```{r, echo = FALSE, out.width="67%"} +#| fig.alt: Tabs using a pills style where the tab controls look like buttons. knitr::include_graphics("pills.png") ``` It's also worth noting that you can also add these classes to [rmarkdown tabsets](https://bookdown.org/yihui/rmarkdown-cookbook/html-tabs.html), like so: ```{r, echo = FALSE, out.width="50%"} +#| fig.alt: Source code for an rmarkdown tabset, see the previous link for the code. knitr::include_graphics("rmarkdown-tabs-source.png") ``` ```{r, echo = FALSE} +#| fig.alt: Screenshot of a rendered rmarkdown tabset. knitr::include_graphics("rmarkdown-tabs.png") ``` @@ -91,6 +96,7 @@ fluidPage( ``` ```{r, echo = FALSE, out.width="67%"} +#| fig.alt: Tabs using a pills style where the tab controls look like buttons and are horizontally centered. knitr::include_graphics("pills.png") ``` @@ -122,6 +128,7 @@ shinyApp( ``` ```{r, echo = FALSE, out.width="67%"} +#| fig.alt: A card component with an orage header and a table of the mtcars dataset in the card body. knitr::include_graphics("DT-card.png") ``` @@ -134,5 +141,6 @@ bs_theme("theme-colors" = "('flair': orange)") ``` ```{r, echo = FALSE, out.width="67%"} +#| fig.alt: A card component with an orange header and a table of the mtcars dataset in the card body. knitr::include_graphics("DT-card-custom.png") ```