Skip to content

Commit b58292e

Browse files
test brand: false overrides project
1 parent e3be2b5 commit b58292e

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: "dark brand - ggplot"
3+
brand: false
4+
execute:
5+
echo: false
6+
warning: false
7+
---
8+
9+
```{r}
10+
#| echo: false
11+
#| warning: false
12+
library(ggplot2)
13+
14+
ggplot_theme <- function(bgcolor, fgcolor) {
15+
theme_minimal(base_size = 11) %+%
16+
theme(
17+
panel.border = element_blank(),
18+
panel.grid.major.y = element_blank(),
19+
panel.grid.minor.y = element_blank(),
20+
panel.grid.major.x = element_blank(),
21+
panel.grid.minor.x = element_blank(),
22+
text = element_text(colour = fgcolor),
23+
axis.text = element_text(colour = fgcolor),
24+
rect = element_rect(colour = bgcolor, fill = bgcolor),
25+
plot.background = element_rect(fill = bgcolor, colour = NA),
26+
axis.line = element_line(colour = fgcolor),
27+
axis.ticks = element_line(colour = fgcolor)
28+
)
29+
}
30+
31+
brand_ggplot <- function(brand_yml) {
32+
brand <- yaml::yaml.load_file(brand_yml)
33+
ggplot_theme(brand$color$background, brand$color$foreground)
34+
}
35+
36+
blue_theme <- brand_ggplot("blue-background.yml")
37+
red_theme <- brand_ggplot("red-background.yml")
38+
39+
colour_scale <- scale_colour_manual(values = c("darkorange", "purple", "cyan4"))
40+
```
41+
42+
43+
```{r}
44+
#| renderings: [light, dark]
45+
ggplot(mtcars, aes(mpg, wt)) +
46+
geom_point(aes(colour = factor(cyl))) + blue_theme + colour_scale
47+
ggplot(mtcars, aes(mpg, wt)) +
48+
geom_point(aes(colour = factor(cyl))) + red_theme + colour_scale
49+
```

tests/integration/playwright/tests/html-dark-mode.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,14 @@ test('Project brand before user themes', async ({ page }) => {
4242
// theme will override brand
4343
await page.goto('./html/dark-brand/project-light-dark/brand-under-theme.html');
4444
await check_theme_overrides(page);
45+
});
46+
47+
test('Brand false remove project brand', async ({ page }) => {
48+
// theme will override brand
49+
await page.goto('./html/dark-brand/project-light-dark/brand-false.html');
50+
const locatr = await page.locator('body').first();
51+
await expect(locatr).toHaveClass('fullcontent quarto-light');
52+
await expect(locatr).toHaveCSS('background-color', 'rgb(255, 255, 255)');
53+
// no toggle
54+
expect(await page.locator('a.quarto-color-scheme-toggle').count()).toEqual(0);
4555
});

0 commit comments

Comments
 (0)