Skip to content

Commit d96d9da

Browse files
authored
fix(theme): light-content / dark-content SCSS rules not included in Reveal.js format (#13771)
1 parent 8036215 commit d96d9da

File tree

8 files changed

+125
-20
lines changed

8 files changed

+125
-20
lines changed

news/changelog-1.9.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ All changes included in 1.9:
4949
- ([#13667](https://github.com/quarto-dev/quarto-cli/issues/13667)): Fix LaTeX compilation error with Python error output containing caret characters.
5050
- ([#13730](https://github.com/quarto-dev/quarto-cli/issues/13730)): Fix TinyTeX detection when `~/.TinyTeX/` directory exists without binaries. Quarto now verifies that the bin directory and tlmgr binary exist before reporting TinyTeX as available, allowing proper fallback to system PATH installations.
5151

52+
### `revealjs`
53+
54+
- ([#13722](https://github.com/quarto-dev/quarto-cli/issues/13722)): Fix `light-content` / `dark-content` SCSS rules not included in Reveal.js format. (author: @mcanouil)
55+
5256
## Projects
5357

5458
### `website`

src/resources/formats/html/_quarto-rules.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,3 +762,13 @@ $mermaid-node-fg-color: $primary !default;
762762
color: #666;
763763
}
764764
}
765+
766+
// light and dark content
767+
768+
body.quarto-light .dark-content {
769+
display: none !important;
770+
}
771+
772+
body.quarto-dark .light-content {
773+
display: none !important;
774+
}

src/resources/formats/html/bootstrap/dist/scss/_light-dark.scss

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/resources/formats/html/bootstrap/dist/scss/bootstrap.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
@import "type";
1414
@import "images";
1515
@import "containers";
16-
@import "light-dark";
1716
@import "grid";
1817
@import "tables";
1918
@import "forms";

src/resources/formats/revealjs/reveal/css/reveal.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,18 +1535,6 @@ $controlsArrowAngleActive: 36deg;
15351535
transition-duration: 1200ms;
15361536
}
15371537

1538-
/*********************************************
1539-
* LIGHT AND DARK CONTENT
1540-
*********************************************/
1541-
1542-
body.quarto-light .dark-content {
1543-
display: none !important;
1544-
}
1545-
1546-
body.quarto-dark .light-content {
1547-
display: none !important;
1548-
}
1549-
15501538
/*********************************************
15511539
* OVERLAY FOR LINK PREVIEWS AND HELP
15521540
*********************************************/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
format: html
3+
title: Light and dark content
4+
---
5+
6+
## Inline content
7+
8+
This is normal content.
9+
10+
[This text is visible only in light mode]{.light-content}
11+
12+
[This text is visible only in dark mode]{.dark-content}
13+
14+
## Block content
15+
16+
:::: {.light-content}
17+
This is a block that is visible only in light mode.
18+
:::
19+
20+
:::: {.dark-content}
21+
This is a block that is visible only in dark mode.
22+
:::
23+
24+
## Mixed content
25+
26+
- Normal list item.
27+
- [Light mode list item]{.light-content}
28+
- [Dark mode list item]{.dark-content}
29+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
format: revealjs
3+
title: Light and dark content
4+
---
5+
6+
## Slide with light and dark content
7+
8+
[This is light content]{.light-content}
9+
10+
:::: {.light-content}
11+
This block is visible only in light mode.
12+
:::
13+
14+
[This is dark content]{.dark-content}
15+
16+
:::: {.dark-content}
17+
This block is visible only in dark mode.
18+
:::
19+
20+
## Another slide
21+
22+
Both light and dark content should display correctly depending on the theme.
23+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
async function check_light_content_visibility(page) {
4+
// In light mode, light-content should be visible, dark-content should be hidden
5+
const light_spans = page.locator('span.light-content');
6+
const dark_spans = page.locator('span.dark-content');
7+
8+
// Check that light content spans exist and are visible
9+
await expect(light_spans.first()).toBeVisible();
10+
11+
// Check that dark content spans are hidden
12+
await expect(dark_spans.first()).toBeHidden();
13+
14+
const light_divs = page.locator('div.light-content');
15+
const dark_divs = page.locator('div.dark-content');
16+
17+
await expect(light_divs.first()).toBeVisible();
18+
await expect(dark_divs.first()).toBeHidden();
19+
}
20+
21+
test.describe('Light and dark content in light mode', () => {
22+
test.use({
23+
colorScheme: 'light'
24+
});
25+
26+
test('HTML: light and dark content visibility in light mode', async ({ page }) => {
27+
await page.goto('./html/unified-brand/light-dark-content.html');
28+
await check_light_content_visibility(page);
29+
});
30+
});
31+
32+
33+
test.describe('Light and dark content in RevealJS', () => {
34+
test('RevealJS: light and dark content visibility', async ({ page }) => {
35+
await page.goto('./revealjs/light-dark-content.html');
36+
37+
// Check that light-content and dark-content elements exist
38+
const light_spans = page.locator('span.light-content');
39+
const dark_spans = page.locator('span.dark-content');
40+
const light_divs = page.locator('div.light-content');
41+
const dark_divs = page.locator('div.dark-content');
42+
43+
await expect(light_spans).not.toHaveCount(0);
44+
await expect(dark_spans).not.toHaveCount(0);
45+
await expect(light_divs).not.toHaveCount(0);
46+
await expect(dark_divs).not.toHaveCount(0);
47+
48+
// Check that body has the correct theme class
49+
const body = page.locator('body');
50+
await expect(body).toHaveClass(/quarto-light/);
51+
52+
// Verify visibility based on theme
53+
await expect(light_spans.first()).toBeVisible();
54+
await expect(dark_spans.first()).toBeHidden();
55+
56+
await expect(light_divs.first()).toBeVisible();
57+
await expect(dark_divs.first()).toBeHidden();
58+
});
59+
});

0 commit comments

Comments
 (0)