Skip to content

Commit 1cbbc68

Browse files
authored
Merge pull request #1461 from quarto-dev/brand
Brand edits
2 parents 93c4702 + ed6dfef commit 1cbbc68

File tree

5 files changed

+130
-50
lines changed

5 files changed

+130
-50
lines changed

docs/authoring/brand.qmd

Lines changed: 81 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
title: Multiformat branding with `_brand.yml`
33
---
44

5-
::: callout-caution
6-
## Work In Progress
7-
8-
These docs are a work-in-progress and may be incorrect or incomplete. Feedback welcome.
9-
:::
10-
115
## Overview
126

137
Quarto supports [**brand.yml**](https://posit-dev.github.io/brand-yml/)---a single YAML file that can be used to customize the appearance of your documents across multiple formats. This is particularly useful for organizations that need a unified look across various formats.
@@ -102,7 +96,7 @@ color:
10296
background: blue
10397
```
10498

105-
The most commonly used colors include `foreground`, `background` and `primary`:
99+
The most commonly used semantic colors include `foreground`, `background` and `primary`:
106100

107101
``` {.yaml filename="_brand.yml"}
108102
color:
@@ -166,7 +160,15 @@ logo:
166160
medium: logo.png
167161
```
168162

169-
You can specify a local file path, relative to the location of `_brand.yml`, or a URL (*is this true?*).
163+
You can specify a local file path, relative to the location of `_brand.yml`, or a URL.
164+
165+
::: {.callout-warning}
166+
167+
## Limitation
168+
169+
Logos specified as URLs are not currently supported in `format: typst`.
170+
171+
:::
170172

171173
A single logo may not work well in all locations so **brand.yml** allows you to set three different logos: `small`, `medium` and `large`. For example:
172174

@@ -223,7 +225,7 @@ typography:
223225
source: google
224226
```
225227

226-
The properties you can set for a font under `fonts` depends on the `source`. You can see the other properties available in our [Reference for Brand](docs/reference/metadata/brand.qmd#font-resource-definitions).
228+
The properties you can set for a font under `fonts` depends on the `source`. You can see the other properties available in our [Reference for Brand](/docs/reference/metadata/brand.qmd#font-resource-definitions).
227229

228230
You can then refer to fonts by `family` in the remaining typography options:
229231

@@ -330,50 +332,51 @@ The supported fields are generally described as follows:
330332

331333
[Defaults in the **brand.yml** docs](https://posit-dev.github.io/brand-yml/brand/defaults.html){.external}
332334

333-
The `defaults` section of **brand.yml** allows users to set option for specific tools that don't otherwise fit into the **brand.yml** schema. In particular, Quarto currently supports `defaults: bootstrap`.
335+
The `defaults` section of **brand.yml** allows users to set options for specific tools that don't otherwise fit into the **brand.yml** schema. Quarto's implementation currently supports `defaults: bootstrap`.
334336

335-
::: {.content-hidden}
337+
#### Bootstrap
336338

337-
#### Quarto
339+
The `bootstrap` section of `defaults` follows [**brand.yml**](https://posit-dev.github.io/brand-yml/brand/defaults.html) and applies to the `html` and `dashboard` formats.
340+
Quarto merges the options set under `defaults: bootstrap` in the appropriate layer of [Quarto's SCSS layering system](/docs/output-formats/html-themes-more.qmd).
338341

339-
Quarto merges options you set in `defaults: quarto` with document metadata. For example, you can use this to set format specific options like syntax highlighting for `html`:
342+
The `defaults` option inside `bootstrap`, can take a string, or key-value pairs
343+
corresponding to SCSS variable name-value pairs.
344+
Building on our initial example, you could use `bootstrap: defaults` to set the SCSS variables `link-decoration` and `navbar-fg`:
340345

341346
``` {.yaml filename="_brand.yml"}
342347
defaults:
343-
quarto:
344-
format:
345-
html:
346-
highlight-style: github
348+
bootstrap:
349+
defaults: # defaults also supports a string as its value
350+
link-decoration: underline
351+
navbar-fg: "#fff"
347352
```
348353

349-
Or, you might change the `logo` options for `typst`:
354+
The resulting HTML pages will have links that are underlined and use white for text in the navigation bar.
350355

351-
``` {.yaml filename="_brand.yml"}
352-
defaults:
353-
quarto:
354-
format:
355-
typst:
356-
logo:
357-
location: left-bottom
358-
```
359-
360-
::: callout-note
361-
## Set all formats in document metadata
362-
363-
Because of the merging behavior of `format`, if you set format specific options in `defaults: quarto`, you'll need to set all the required formats in document metadata:
364-
365-
``` {.yaml filename="document.qmd"}
366-
format:
367-
html: default
368-
revealjs: default
369-
```
356+
::::::: {.column-body-outset-right layout-ncol="2"}
357+
::: {}
358+
![Without `defaults: bootstrap` setting](/docs/authoring/images/brand-html-no-defaults.png){.lightbox group="brand-bootstrap-defaults" fig-alt="Screenshot of a webpage. The text is dark grey on a light blue background, using a rounded sans-serif typeface, a logo appears in the navbar."}
370359
:::
371360

372-
:::
361+
::: {}
362+
![With `defaults: bootstrap` setting: note the link decoration and the white color for the navbar text](/docs/authoring/images/brand-html-defaults.png){.lightbox group="brand-bootstrap-defaults" fig-alt="Screenshot of a webpage. It looks identical to the previous image, except for underlined links and white text on the navbar."}
363+
:::
364+
:::::::
373365

374-
#### Bootstrap
366+
In addition to the `defaults` option, Quarto supports `uses`, `functions`, `mixins` and `rules`, which all take a string value.
367+
For example, you could use `rules` to provide a CSS rule to remove the border below second-level headings:
375368

376-
*How relevant is `defaults: bootstrap`? Example? WHere do you find out what you can put under `bootstrap`?*
369+
```{.yaml filename="_brand.yml"}
370+
defaults:
371+
bootstrap:
372+
# uses: <string>
373+
# functions: <string>
374+
# mixins: <string>
375+
rules: |
376+
h2 {
377+
border: none;
378+
}
379+
```
377380

378381
### Meta
379382

@@ -438,21 +441,54 @@ You can't currently access `typography`, `meta`, or `defaults` values using the
438441

439442
### In SCSS
440443

441-
If `_brand.yml` defines `color: blue`:
444+
The colors defined in `palette` are set as SCSS variables of the form `brand-COLOR_NAME`.
445+
For example, if `_brand.yml` defines `blue`:
442446

443447
```{.yaml filename="_brand.yml"}
444448
color:
445449
palette:
446450
blue: "#ddeaf1"
447451
```
448452

449-
This should work:
453+
Then the variable `$brand-blue` is will be set to `#ddeaf1` in the `defaults` layer of [Quarto's SCSS layering system](/docs/output-formats/html-themes-more.html#bootstrap-bootswatch-layering).
454+
You can add a custom SCSS file, `styles.scss`, in the usual way:
455+
```{.yaml filename="_quarto.yml"}
456+
format:
457+
html:
458+
theme: [styles.scss]
459+
```
460+
461+
Then `styles.scss` can use these brand variables to make style tweaks.
462+
For example, you might want all `h1` elements to be `blue`:
463+
464+
```{.scss filename="styles.scss"}
465+
/*-- scss:rules --*/
466+
467+
h1 {
468+
color: $brand-blue;
469+
}
470+
```
471+
472+
When you specify SCSS files without an explicit `brand` element, it is equivalent to listing them after `brand`.
473+
For instance, the above `theme` is equivalent to:
450474

451-
```{.scss filename="custom.scss"}
452-
/*-- scss:defaults --*/
453-
$navbar-bg: $brand-blue;
475+
```{.yaml filename="_quarto.yml"}
476+
format:
477+
html:
478+
theme: [brand, styles.scss]
479+
```
480+
481+
The order of elements in `theme` controls their priority.
482+
For example, you could layer brand and your custom SCSS on top of a built-in theme:
483+
484+
```{.yaml filename="_quarto.yml"}
485+
format:
486+
html:
487+
theme: [cosmo, brand, styles.scss]
454488
```
455489

490+
You can learn more about layering themes in [More About Quarto Themes](/docs/output-formats/html-themes-more.qmd).
491+
456492
### Typst
457493

458494
In Typst documents, brand colors are set in a [dictionary](https://typst.app/docs/reference/foundations/dictionary/) called `brand-color`.
@@ -474,7 +510,3 @@ Filters and shortcodes can access brand values using the `brand` Lua module.
474510
local brand = require('modules/brand/brand')
475511
local primary = brand.get_color('primary')
476512
```
477-
478-
## Comprehensive Example
479-
480-
TBD
69.7 KB
Loading
69.1 KB
Loading

docs/output-formats/html-themes-more.qmd

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ From time to time, as the Bootswatch themes are updated, we will update these me
4444

4545
## Bootstrap / Bootswatch Layering
4646

47-
When using the Quarto HTML format, we allow the user to specify theme information in the document front matter (or project YAML). The theme information consists of a list of one or more of
47+
When using the Quarto `html` and `dashboard` formats, we allow the user to specify theme information in the document front matter (or project YAML). The theme information consists of a list of one or more of
4848

4949
- A valid built in Bootswatch theme name
5050

@@ -106,3 +106,50 @@ We order the themes according to the order that they are specified in the YAML,
106106
Bootstrap
107107
cosmo /*-- scss:rules --*/
108108
custom.scss /*-- scss:rules --*/
109+
110+
## `revealjs` Layering
111+
112+
The same system applies for `revealjs` and its themes.
113+
`revealjs` themes shipped with Quarto do not have a uniform variable naming convention, and so different SCSS files are likely to be needed to make effective changes to different themes.
114+
115+
Nevertheless, the following examples illustrate what's possible:
116+
117+
``` yaml
118+
# In this configuration, `custom.scss` takes precedence
119+
format:
120+
revealjs:
121+
theme:
122+
- blood
123+
- custom.scss
124+
# In this configuration, the `blood` theme takes precedence
125+
format:
126+
revealjs:
127+
theme:
128+
- custom.scss
129+
- blood
130+
```
131+
132+
## `_brand.yml` Layering
133+
134+
Quarto supports [**brand.yml**](https://posit-dev.github.io/brand-yml/brand/defaults.html), see the [Brand guide](/docs/authoring/brand.qmd) for more details.
135+
By default, styling information in `_brand.yml` takes the lowest precedence.
136+
To change this, use the `"brand"` string in your theme configuration in YAML:
137+
138+
``` yaml
139+
# In this configuration, the `blood` theme takes precedence
140+
# over `custom.scss` *and* the information in `_brand.yml`
141+
format:
142+
revealjs:
143+
theme:
144+
- custom.scss
145+
- blood
146+
# In this configuration, the information in `_brand.yml` takes
147+
# precedence over the `blood` theme and `custom.scss`, in that
148+
# order
149+
format:
150+
revealjs:
151+
theme:
152+
- blood
153+
- custom.scss
154+
- brand
155+
```

docs/presentations/revealjs/themes.qmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,4 @@ See these articles to learn more about using Reveal:
215215
- [Reveal Basics](index.qmd) covers the basic mechanics of creating presentations.
216216
- [Presenting Slides](presenting.qmd) describes slide navigation, printing to PDF, drawing on slides using a chalkboard, and creating multiplex presentations.
217217
- [Advanced Reveal](advanced.qmd) delves into transitions, animations, advanced layout and positioning, and other options available for customizing presentations.
218+
- [More About Quarto Themes](/docs/output-formats/html-themes-more.qmd) describes the layering system in more detail, including interactions with other SCSS files and [`_brand.yml`](/docs/authoring/brand.qmd).

0 commit comments

Comments
 (0)