Skip to content

Commit

Permalink
feat(theme): Branded theming via brand.yml (#1148)
Browse files Browse the repository at this point in the history
* feat(resolve_bs_preset): Support brand

```
theme:
  preset: brand
```

```
theme:
  preset: { brand: "path/to/brand.yml" }
```

* feat: read_brand_yml (not exported)

* feat: Brand theme includes base theme from brand.yml

* feat: Add brand example app

* feat: Add brand base and colors as first brand layer

* feat: Add brand defaults

* feat: Add brand.color defaults

* feat: Add brand typography

* chore: consistent return values

* feat: Add brand fonts

* chore: tweak and improve example app

* fix: ensure return type consistency

* feat: include `brand` as an attribute of the bslib theme object

* feat: Example app updates

* Resave data (GitHub Action)

* Update website deps (GitHub Action)

* chore: download font files on first run

* feat: File fonts can be URLs

* tests: Update tests

* chore: Add {lobstr} to Suggests

* fix: Remove `|>` syntax, add clarifying comment

* feat: Normalize `brand.color` on read and detect cycles

* Resave data (GitHub Action)

* tests: maybe_convert_font_size_to_rem

* tests(b_get_color): Add test for null case

* chore: remove unused function

* feat(brand_resolve_preset): Use S3 class for many ways to create a brand preset

* feat: "brand" is now a builtin theme

* chore: don't use str because it comes from {utils}

* tests: normalize `brand$path`

* chore: style

* chore: Add {tools} and {utils} to Suggests

* feat: inline brand definitions are allowed

* tests: update snapshot

* tests: fix path test for Windows

* fix: actually fix path comparison

* feat: Update _brand-yml.scss after `$default` fix

* chore: rename brand example app file

* feat(bs_theme): Separate `preset` and `brand` arguments

Tests are not updated yet

* tests: Update brand theming tests

* `devtools::document()` (GitHub Actions)

* Update website deps (GitHub Action)

* fix: remove unused call

* feat: brand_resolve(NULL) finds brand if available, silent if not

* tests: clean up unused tests

brand and preset are no longer entangled

* `devtools::document()` (GitHub Actions)

* test: `brand_resolve(FALSE)` returns `NULL`

* chore: remove print method and lobstr dependency

Saving a real print method for the `brand.yml` package

* tests(brand_resolve_preset)

* Add white space to trigger CI

* chore: undo changes to `resolve_bs_preset()`

* chore: use `sass::sass_file()`

* feat: warn if brand is used with Bootstrap <= 4

* fix: Add missing font family to error message

* refactor: Use `abort()` across the board

* chore: trim whitespace of css value

* refactor: early return on its own

* fix: oops

* refactor: simplify `path_is_file()`

* chore: add comment that we're borrowing from tools::file_ext()

* chore: suggested imports

* docs: make note of brand example

* `yarn build` (GitHub Actions)

* docs: callouts for h3-h5

* docs: Add brand.yml article

* docs(article): Edits and moving around

* chore: remove unused brand.yml logo

* chore: fix typo in brand.yml

* feature(app): live edit brand.yml in the app

* feat: Add light-weight prism-code-editor

* chore: Use env for error message storage

* feat: Toggle editor from navbar

* feat: Use ExtendedTask for long-running plot

* chore: clean up logo section of example _brand.yml

* chore: format

* Resave data (GitHub Action)

* chore: strip ansi chars from error message

* chore: increase theme update delay

* docs: Add news item

* Update website deps (GitHub Action)

* chore: remove dev code from example app

* rename: `b_get()` -> `brand_pluck()`, etc.

* fix: Set default google font style

* fix: `.brand-font-{family}` class name

* chore: add a comment that fonts aren't dynamically updated

* chore: format

* Update website deps (GitHub Action)

* chore: simplify ansi color code removal

* chore: remove pkgload local dev code (again)

* chore: tweak error message

* docs(bs_theme): `brand=NULL` is the default

* chore: finalize example _brand.yml

* refactor: Rename example `brand.yml`

* feat: Only allow saving the `_brand.yml` file if used as template

* `devtools::document()` (GitHub Actions)

* feat: put editor in a card in a black-background sidebar

* fix(brand_color_pluck): Return `NULL` values, otherwise assert string values

* refactor: simplify null/string check
  • Loading branch information
gadenbuie authored Jan 7, 2025
1 parent 4ab41c2 commit 0977ad7
Show file tree
Hide file tree
Showing 20 changed files with 2,726 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ inst/lib/bsw3/.npmignore
^\.gitattributes$
^CODE_OF_CONDUCT\.md$
^cran-comments\.md$
^inst/examples-shiny/brand.yml/Monda\.ttf$
^inst/examples-shiny/brand.yml/Monda-OFL\.txt$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ vignettes/*/index.html
# rendered examples that appear in iframes
vignettes/**/examples
!vignettes/examples
inst/examples-shiny/brand.yml/Monda-OFL.txt
inst/examples-shiny/brand.yml/Monda.ttf
6 changes: 5 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ Suggests:
shiny (> 1.8.1),
testthat,
thematic,
withr
tools,
utils,
withr,
yaml
Config/Needs/deploy:
BH,
chiflights22,
Expand Down Expand Up @@ -119,6 +122,7 @@ Collate:
'bs-remove.R'
'bs-theme-layers.R'
'bs-theme-preset-bootswatch.R'
'bs-theme-preset-brand.R'
'bs-theme-preset-builtin.R'
'bs-theme-preset.R'
'utils.R'
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
S3method(as.tags,bslib_sidebar)
S3method(bind_task_button,ExtendedTask)
S3method(bind_task_button,default)
S3method(brand_resolve,"NULL")
S3method(brand_resolve,brand_yml)
S3method(brand_resolve,character)
S3method(brand_resolve,list)
S3method(brand_resolve,logical)
S3method(is_fill_item,default)
S3method(is_fill_item,htmlwidget)
S3method(is_fillable_container,default)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

Related to the above change, `navset_bar()` now defaults to using `underline = TRUE` so that both `page_navbar()` and `navset_bar()` use the same set of default `navbar_options()`.

## New features

* bslib now supports unified theming with [brand.yml](https://posit-dev.github.io/brand-yml). brand.yml lets you theme your Shiny apps, Quarto documents and more with a single, portable YAML file. Learn more in the new [Unified theming with brand.yml](https://rstudio.github.io/bslib/dev/articles/brand-yml/) article. (#1148)

## Improvements and bug fixes

* `navset_card_pills()`, `navset_card_underline()`, `navset_card_tabs()` fixed to now respect header/footer arguments (@tanho63, #1024)
Expand Down
Loading

0 comments on commit 0977ad7

Please sign in to comment.