Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(theme): Branded theming via brand.yml #1148

Open
wants to merge 63 commits into
base: main
Choose a base branch
from

Conversation

gadenbuie
Copy link
Member

@gadenbuie gadenbuie commented Dec 9, 2024

Adds support for branded theming via bs_theme(brand = TRUE).

There are few choices:

# Automatically find `_brand.yml` in app dir or its parents
bs_theme()

# Find `_brand.yml` in app dir or its parents, or fail otherwise
bs_theme(brand = TRUE)

# Direct path to a brand.yml file
bs_theme(brand = "path/to/brand.yml")

# Ignore an existing `_brand.yml` file, apply no branding
bs_theme(brand = FALSE)

# Provide a brand definition inline
bs_theme(brand = list(color = list(primary = "#466683")))

Or in YAML where bs_theme() is called:

theme:
  brand: true

theme:
  brand: false

theme:
  brand: "path/to/brand.yml"

theme:
  brand:
    color:
      primary: "#466683"

TODO

  • Tests
  • Documentation - Update function docs in bs_theme()
  • Documentation - Article on pkgdown site?
  • Build ignore Monda.ttf and download it as needed on app load

gadenbuie and others added 30 commits December 5, 2024 16:05
```
theme:
  preset: brand
```

```
theme:
  preset: { brand: "path/to/brand.yml" }
```
R/bs-theme-preset.R Outdated Show resolved Hide resolved
Comment on lines +43 to +49
"brand_base" = switch_version(
version,
five = sass_layer_file(
system_file("brand", "bs5", "_brand-yml.scss", package = "bslib")
),
default = list()
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be throwing an error if version is less than 5?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure... we don't have a fully adapted branded theme for BS <= 4 but there are still a number of features of brand that are useful. It's also possible that a user could fill in their own implementation for BS <= 4 using only the tools already present in brand.yml. So erroring here feels too aggressive. I'll add a warning instead.

@cpsievert
Copy link
Collaborator

Looks great overall! Consider this approved when all suggestions are considered/addressed and if there's no new major code changes. I will be mostly away until the 10th, but if you have questions that can be addressed asynchronously, I'll be checking Slack/GitHub periodically.

@gadenbuie gadenbuie marked this pull request as ready for review December 30, 2024 15:56
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.

3 participants