Skip to content

Commit 7709b04

Browse files
authored
Merge pull request #12960 from quarto-dev/revealjs/brand-layer
reveajs - correctly identify brand layer
2 parents b543849 + 13c30aa commit 7709b04

File tree

15 files changed

+120
-2
lines changed

15 files changed

+120
-2
lines changed

news/changelog-1.8.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ All changes included in 1.8:
2525
### `revealjs`
2626

2727
- ([#12598](https://github.com/quarto-dev/quarto-cli/pull/12598)): Ensure `.fragment` on an image with caption applies to whole figure.
28+
- ([#12716](https://github.com/quarto-dev/quarto-cli/issues/12716)): Correctly resolve `"brand"` set in `theme` configuration for document in subdirectory from project root.
2829

2930
### `docx`
3031

@@ -93,4 +94,4 @@ All changes included in 1.8:
9394

9495
- ([#11321](https://github.com/quarto-dev/quarto-cli/issues/11321)): Follow [recommendation from LaTeX project](https://latex-project.org/news/latex2e-news/ltnews40.pdf) and use `lualatex` instead of `xelatex` as the default PDF engine.
9596
- ([#12782](https://github.com/quarto-dev/quarto-cli/pull/12782)): fix bug on `safeRemoveDirSync`'s detection of safe directory boundaries.
96-
- ([#12853](https://github.com/quarto-dev/quarto-cli/issues/12853)): fix replaceAll() escaping issue with embedded notebooks containing `$` in their Markdown.
97+
- ([#12853](https://github.com/quarto-dev/quarto-cli/issues/12853)): fix replaceAll() escaping issue with embedded notebooks containing `$` in their Markdown.

src/format/reveal/format-reveal-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export async function revealTheme(
124124
.map(
125125
(theme) => {
126126
const themePath = join(relative(Deno.cwd(), dirname(input)), theme);
127-
if (themePath === "brand") {
127+
if (theme === "brand") {
128128
usedBrandLayers = true;
129129
return brandLayers;
130130
} else if (existsSync(themePath)) {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*-- scss:defaults --*/
2+
$body-bg: $brand-dark-teal;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.quarto/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
color:
2+
palette:
3+
dark-teal: "#005E5E"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project:
2+
type: default
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*-- scss:defaults --*/
2+
$body-bg: $brand-dark-teal;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: test
3+
format:
4+
revealjs:
5+
theme: [custom.scss, brand]
6+
---
7+
8+
# content
9+
10+
content
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*-- scss:defaults --*/
2+
$body-bg: $brand-dark-teal;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: test
3+
format:
4+
revealjs:
5+
theme: [custom.scss, brand]
6+
---
7+
8+
# content
9+
10+
content
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: test
3+
format:
4+
revealjs:
5+
theme: [custom.scss, brand]
6+
brand:
7+
color:
8+
palette:
9+
dark-teal: "#005E5E"
10+
---
11+
12+
# content
13+
14+
content
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*-- scss:defaults --*/
2+
$body-bg: $brand-dark-teal;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: test
3+
format:
4+
revealjs:
5+
theme: [custom.scss, brand]
6+
brand:
7+
color:
8+
palette:
9+
dark-teal: "#005E5E"
10+
---
11+
12+
# content
13+
14+
content

tests/integration/playwright/src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ export async function checkBorderProperties(element: Locator, side: string, colo
233233
await expect(element).toHaveCSS(`border-${side}-width`, width);
234234
}
235235

236+
export async function checkBackgroundColorProperty(element: Locator, color: RGBColor) {
237+
await checkColor(element, `background-color`, color);
238+
}
239+
236240
export function useDarkLightMode(mode: 'dark' | 'light'): Partial<PlaywrightTestOptions> {
237241
return {
238242
colorScheme: mode
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { test, expect, Locator } from '@playwright/test';
2+
import { asRGB, checkBackgroundColorProperty, checkColor, checkColorIdentical, checkFontSizeSimilar, getCSSProperty, hexToRgb, RGBColor } from '../src/utils';
3+
4+
async function getRevealBrandColorVar(page: any, suffix: string): Promise<string> {
5+
return await getCSSProperty(page.locator('body'), `--quarto-scss-export-brand-${suffix}`, false) as string;
6+
}
7+
8+
// specific function to check the branded background color for revealjs/brand/ tests
9+
// They use `color.palette.dark-teal` as brand color
10+
async function checkBrandedBackgroundColor(page: any) {
11+
const brandColor = await getRevealBrandColorVar(page, 'dark-teal');
12+
await checkBackgroundColorProperty(page.locator('body'), hexToRgb(brandColor));
13+
}
14+
15+
// Define test cases with their URLs to reduce duplication
16+
const brandTestCases = [
17+
{
18+
name: 'project file using _brand.yml configuration',
19+
url: './revealjs/brand/project/index.html',
20+
description: 'Tests a file within a project that uses _brand.yml for branding'
21+
},
22+
{
23+
name: 'nested file within project inheriting project branding',
24+
url: './revealjs/brand/project/subdir/index.html',
25+
description: 'Tests a file in a subdirectory that inherits project branding from _brand.yml'
26+
},
27+
{
28+
name: 'standalone file with inline brand configuration',
29+
url: './revealjs/brand/single.html',
30+
description: 'Tests a standalone file with inline brand configuration in YAML frontmatter'
31+
},
32+
{
33+
name: 'file in subdirectory with inline brand configuration',
34+
url: './revealjs/brand/subdir/index.html',
35+
description: 'Tests a file in subdirectory with its own inline brand configuration'
36+
}
37+
];
38+
39+
// Run all test cases with the same pattern
40+
for (const testCase of brandTestCases) {
41+
test(testCase.name, async ({ page }, testInfo) => {
42+
// Add the description as an annotation to the test report
43+
testInfo.annotations.push({
44+
type: 'description',
45+
description: testCase.description
46+
});
47+
48+
await page.goto(testCase.url);
49+
await checkBrandedBackgroundColor(page);
50+
});
51+
}

0 commit comments

Comments
 (0)