Skip to content

Commit bc8b204

Browse files
committed
document 'defaults'
1 parent 9d04547 commit bc8b204

File tree

2 files changed

+30
-91
lines changed

2 files changed

+30
-91
lines changed

docs/authoring/brand.qmd

Lines changed: 30 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,7 @@ logo:
166166
medium: logo.png
167167
```
168168

169-
You can specify a local file path, relative to the location of `_brand.yml`, or a URL that starts with `http://` or `https://`.
170-
171-
::: {.callout-warning}
172-
173-
## Limitation
174-
175-
Logos specified as URLs are not currently supported in `format: typst`.
176-
177-
:::
169+
You can specify a local file path, relative to the location of `_brand.yml`, or a URL.
178170

179171
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:
180172

@@ -338,46 +330,40 @@ The supported fields are generally described as follows:
338330

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

341-
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 supports `defaults: quarto` and `defaults: bootstrap`.
342-
343-
#### Quarto
333+
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`.
344334

345-
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`:
335+
#### Bootstrap
346336

347-
``` {.yaml filename="_brand.yml"}
348-
defaults:
349-
quarto:
350-
format:
351-
html:
352-
highlight-style: github
353-
```
337+
The `bootstrap` section follows [**brand.yml**](https://posit-dev.github.io/brand-yml/brand/defaults.html).
338+
**brand.yml** specifies the behavior of a `defaults` key inside `bootstrap`, with key-value pairs
339+
corresponding to SCSS variable name-value pairs.
340+
In addition to the `defaults` key, Quarto supports `uses`, `functions`, `mixins` and `rules`.
341+
These keys all take a string value that will be used for the appropriate [layer](/docs/output-formats/html-themes-more.qmd).
354342

355-
Or, you might change the `logo` options for `typst`:
343+
Consider the following, building on our working example:
356344

357345
``` {.yaml filename="_brand.yml"}
346+
## Add this entry to the `_brand.yml` example above
358347
defaults:
359-
quarto:
360-
format:
361-
typst:
362-
logo:
363-
location: left-bottom
348+
bootstrap:
349+
defaults: # defaults also supports a string as its value
350+
link-decoration: underline
351+
navbar-fg: "#fff"
352+
# uses: <string>
353+
# functions: <string>
354+
# mixins: <string>
355+
# rules: <string>
364356
```
365357

366-
::: callout-note
367-
## Set all formats in document metadata
368-
369-
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:
370-
371-
``` {.yaml filename="document.qmd"}
372-
format:
373-
html: default
374-
revealjs: default
375-
```
358+
::::::: {.column-body-outset-right layout-ncol="2"}
359+
::: {}
360+
![Without `defaults: bootstrap` setting](/docs/authoring/images/brand-html.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."}
376361
:::
377362

378-
#### Bootstrap
379-
380-
*How relevant is `defaults: bootstrap`? Example? WHere do you find out what you can put under `bootstrap`?*
363+
::: {}
364+
![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."}
365+
:::
366+
:::::::
381367

382368
### Meta
383369

@@ -442,62 +428,19 @@ You can't currently access `typography`, `meta`, or `defaults` values using the
442428

443429
### In SCSS
444430

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

448433
```{.yaml filename="_brand.yml"}
449434
color:
450435
palette:
451436
blue: "#ddeaf1"
452437
```
453438

454-
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).
455-
You can add a custom SCSS file, `styles.scss`, in the usual way:
456-
```{.yaml filename="_quarto.yml"}
457-
format:
458-
html:
459-
theme: [styles.scss]
460-
```
439+
This should work:
461440

462-
Then `styles.scss` can use these brand variables to make style tweaks.
463-
For example, you might want all `h1` elements to be `blue`:
464-
465-
```{.scss filename="styles.scss"}
466-
/*-- scss:rules --*/
467-
468-
h1 {
469-
color: $brand-blue;
470-
}
471-
```
472-
473-
When you specify SCSS files without an explicit `brand` element, it is equivalant to listing them after `brand`.
474-
For instance, the above `theme` is equivalant to:
475-
476-
```{.yaml filename="_quarto.yml"}
477-
format:
478-
html:
479-
theme: [brand, styles.scss]
480-
```
481-
482-
This order doesn't matter when you are setting items in the `/*-- scss:rules --*/` layer, because `rules` are layered on after `defaults`.
483-
484-
However, if you want to set a [Quarto SASS variable](https://quarto.org/docs/output-formats/html-themes.html#sass-variables) you'll use the `/*-- scss:defaults --*/` layer and the order of items in `theme` will matter.
485-
486-
As an example, consider setting the navigation bar background to the `blue` brand color:
487-
488-
```{.scss filename="nav.scss"}
441+
```{.scss filename="custom.scss"}
489442
/*-- scss:defaults --*/
490-
491-
$navbar-bg: $brand-blue;
492-
```
493-
494-
Because of the way Quarto layers SCSS, the order for the `defaults` layer is the reverse of what is specified in `theme`.
495-
For `nav.scss` to find the `brand-blue` variable, `brand` must come after `nav.scss` in `theme`:
496-
497-
```{.yaml filename="_quarto.yml"}
498-
format:
499-
html:
500-
theme: [nav.scss, brand]
443+
$navbar-bg: $brand-blue;
501444
```
502445

503446
### Typst
@@ -520,8 +463,4 @@ Filters and shortcodes can access brand values using the `brand` Lua module.
520463
``` lua
521464
local brand = require('modules/brand/brand')
522465
local primary = brand.get_color('primary')
523-
```
524-
525-
## Comprehensive Example
526-
527-
TBD
466+
```
319 KB
Loading

0 commit comments

Comments
 (0)