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

docs: dark brand #1614

Open
wants to merge 12 commits into
base: prerelease
Choose a base branch
from
Open

docs: dark brand #1614

wants to merge 12 commits into from

Conversation

gordonwoodhull
Copy link
Contributor

Hi @cwickham, here is the first of my doc PRs for Quarto 1.7, covering Dark Brand.

I'll follow up with more commits covering the changes for Typst, and a separate PR for renderings.

(I will also need to check that my schema changes have made it into the reference documentation, hmm.)

Please let me know what you think - glad to edit, move content, etc.

Thanks!

@gordonwoodhull gordonwoodhull requested a review from cwickham April 3, 2025 20:56
Copy link
Contributor

github-actions bot commented Apr 3, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 3, 2025 21:02 Inactive
Copy link
Collaborator

@cwickham cwickham left a comment

Choose a reason for hiding this comment

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

This all looks great. A few places that could use a bit more clarification.

I'll open a PR for the updates to the reference so you can take a look.

@@ -101,10 +101,12 @@ Setting the above themes in your `_quarto.yml` results in both a dark and light

When providing both a dark and light mode for your html output, Quarto will automatically create a toggle to allow your reader to select the desired dark or light appearance. The toggle will automatically appear in the top right corner of your html output. When possible, the toggle will use browser local storage to maintain the user's preference across sessions.

The first appearance (light or dark) elements in the theme to determine the default appearance for your html output. For example, since the `light` option appears first in the above example, a reader will see the light appearance by default.
To honor the user's operating system or browser preference for light or dark mode, specify `respect-user-color-scheme: true`. Otherwise, the order of light and dark elements in the theme or brand will determine the default appearance for your html output. For example, since the `light` option appears first in the above example, a reader will see the light appearance by default, if `respect-user-color-scheme` is not enabled.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Specify where? Is this a YAML option under theme? I'd probably put an example right after the first sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. It's a new HTML document option. Will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding the example meant invalidating the reference to "above example" in the next sentence, so I changed it to "first example". Is this clear?

Copy link
Contributor

github-actions bot commented Apr 4, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 4, 2025 13:53 Inactive
Copy link
Contributor

github-actions bot commented Apr 6, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 6, 2025 01:28 Inactive
@gordonwoodhull gordonwoodhull marked this pull request as ready for review April 6, 2025 01:57
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Apr 6, 2025

I've added documentation for Typst brand-mode and resolved the other issues.

I also added minimal documentation for renderings. Note we can't demonstrate this feature until we enable dark mode for quarto.org.

@cwickham, please give this another read for clarity.

Copy link
Contributor

github-actions bot commented Apr 6, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 6, 2025 02:00 Inactive
Copy link
Contributor

github-actions bot commented Apr 6, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 6, 2025 02:23 Inactive
Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 7, 2025 13:45 Inactive
Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 7, 2025 14:54 Inactive
Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 7, 2025 15:06 Inactive
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Apr 7, 2025

I've also moved the document logo customization documentation out of the advanced Typst brand yml docs and into the main Brand page. This fixes quarto-dev/quarto-cli#12181.

I don't know if this belongs here, but it should be somewhere on the main site.

The remaining helpful info on the Advanced page has to do with typography, so I've added a link there.

I realized I had put the brand-mode section inside of the color documentation, so I made a Typst subsection under Dark Brand instead.

I think this completes my documentation tasks for 1.7 (aside from needing to return to renderings when we're able to demo that).

Glad to edit or expand any of this.

Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 7, 2025 15:12 Inactive
Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 7, 2025 15:39 Inactive
Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 7, 2025 15:47 Inactive
Copy link
Collaborator

@cwickham cwickham left a comment

Choose a reason for hiding this comment

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

Looks good! A few minor suggestions.

In terms of renderings:

  • We definitely need some examples. Can we do screenshots for now? Not sure how big a job it is to implement dark mode on quarto.org.
  • Where were you thinking of putting the examples? Maybe docs/computations/execution-options.html#figure-options?
  • I think you might have mentioned you can construct light/dark variations of (e.g.) screenshots by constructing divs with the right classes. Is this something we want to document?

It's starting to feel like the dark mode details are spread all over the place and we might want a single page that describes implenting dark mode on a website: setting themes, brand and renderings.

Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@github-actions github-actions bot temporarily deployed to pull request April 7, 2025 20:46 Inactive
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Apr 7, 2025

Light/dark renderings example

A problem with adding an example today is that we don't have the helper libraries... I'm trying to put the release and docs to bed so that I can get back to the user side.

(This might include syntactic sugar to avoid duplicate code, like the custom print function you came up with.)

So a minimal ggplot example is about 56 lines, but 34 lines of this (the first code cell) is the stuff that is supposed to in the helper library:

---
title: "knitr dark mode - ggplot"
brand:
  light: united-brand.yml
  dark: slate-brand.yml
execute:
  echo: false
  warning: false
---

```{r}
#| echo: false
#| warning: false
library(ggplot2)

ggplot_theme <- function(bgcolor, fgcolor) {
  theme_minimal(base_size = 11) %+%
    theme(
      panel.border = element_blank(),
      panel.grid.major.y = element_blank(),
      panel.grid.minor.y = element_blank(),
      panel.grid.major.x = element_blank(),
      panel.grid.minor.x = element_blank(),
      text = element_text(colour = fgcolor),
      axis.text = element_text(colour = fgcolor),
      rect = element_rect(colour = bgcolor, fill = bgcolor),
      plot.background = element_rect(fill = bgcolor, colour = NA),
      axis.line = element_line(colour = fgcolor),
      axis.ticks = element_line(colour = fgcolor)
    )
}

brand_ggplot <- function(brand_yml) {
  brand <- yaml::yaml.load_file(brand_yml)
  ggplot_theme(brand$color$background, brand$color$foreground)
}

united_theme <- brand_ggplot("united-brand.yml")
slate_theme <- brand_ggplot("slate-brand.yml")

colour_scale <- scale_colour_manual(values = c("darkorange", "purple", "cyan4"))
```

### no crossref, no caption

```{r}
#| renderings: [light, dark]
ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(colour = factor(cyl))) +
  united_theme +
  colour_scale
ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(colour = factor(cyl))) +
  slate_theme +
  colour_scale
```

I think it would be okay at 12 lines, and I agree it fits in docs/computations/execution-options.html#figure-options.

Non-computational light and dark

We can add this but I'm not sure where it goes. It's not really brand or theme but just the way our CSS works.

A minimal example without any resources would be

---
title: "light and dark with divs"
brand:
  light: united-brand.yml
  dark: slate-brand.yml
---

::: {.light-content}
This text will be shown in light mode.
:::

::: {.dark-content}
This text will be shown in dark mode.
:::

This example is self-explanatory but kind of useless. Would it be better with images?

EDIT: that example only works for HTML; the cross-format way to do this is currently to imitate cell output. Too ugly to document?

---
title: "light and dark with divs"
brand:
  light: united-brand.yml
  dark: slate-brand.yml
renderings: [light, dark]
---

::: {.cell}
::: {.cell-output-display}
This text will be shown in light mode.
:::

::: {.cell-output-display}
This text will be shown in dark mode.
:::
:::

we no longer need to document Typst 0.11 behavior, since we ship with 0.13 now
Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed on https://deploy-preview-1614.quarto.org

@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Apr 8, 2025

I think we should merge this and then continue with examples for renderings in a later PR.

Unless you want to reorganize to a single dark mode page?

I have an example at 22 lines, using your darkmode_theme() function ... it might be made shorter.

But we need to contribute the 40 lines of helpers.R to quarto-r (instead of using source() below). I should be able to do that this week.

---
title: "knitr dark mode - ggplot"
brand:
  light: united-brand.yml
  dark: slate-brand.yml
---

```{r}
#| echo: false
source("helpers.R")
united_theme <- brand_ggplot("united-brand.yml")
slate_theme <- brand_ggplot("slate-brand.yml")
darkmode_theme(united_theme, slate_theme)
colour_scale <- scale_colour_manual(values = c("darkorange", "purple", "cyan4"))
```

```{r}
#| renderings: [light, dark]
ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(colour = factor(cyl))) +
  colour_scale
```

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.

2 participants