Skip to content

Commit aaa4639

Browse files
committed
Add test to check SCSS color customization for callouts
1 parent 3072cb2 commit aaa4639

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: callout colors
3+
format:
4+
revealjs:
5+
theme: custom.scss
6+
---
7+
8+
## Note
9+
10+
::: {.callout-note}
11+
12+
Content with inline code `1 + 1` and block
13+
14+
```{.python}
15+
1 + 1
16+
```
17+
:::
18+
19+
## Warning
20+
21+
::: {.callout-warning}
22+
23+
Content with inline code `1 + 1` and block
24+
25+
```{.python}
26+
1 + 1
27+
```
28+
:::
29+
30+
## Important
31+
32+
::: {.callout-important}
33+
34+
Content with inline code `1 + 1` and block
35+
36+
```{.python}
37+
1 + 1
38+
```
39+
:::
40+
41+
## Tip
42+
43+
::: {.callout-tip}
44+
45+
Content with inline code `1 + 1` and block
46+
47+
```{.python}
48+
1 + 1
49+
```
50+
:::
51+
52+
## caution
53+
54+
::: {.callout-caution}
55+
56+
Content with inline code `1 + 1` and block
57+
58+
```{.python}
59+
1 + 1
60+
```
61+
:::
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*-- scss:defaults --*/
2+
3+
$callout-color-note: rgb(128, 0, 128);
4+
$callout-color-tip: rgb(255, 255, 0);
5+
$callout-color-important: rgb(128, 128, 128);
6+
$callout-color-caution: rgb(0, 128, 0);
7+
$callout-color-warning: rgb(173, 216, 230);

tests/integration/playwright/tests/revealjs-themes.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ async function getRevealCodeInlineFontSize(page: any): Promise<number> {
2929
return await getCSSProperty(page.locator('body'), "--r-inline-code-font-size", true) as number;
3030
}
3131

32+
async function checkColor(element, cssProperty, rgbColors) {
33+
await expect(element).toHaveCSS(cssProperty, `rgb(${rgbColors.red}, ${rgbColors.green}, ${rgbColors.blue})`);
34+
}
35+
36+
function asRGB(red, green, blue) {
37+
return { red, green, blue };
38+
}
39+
40+
41+
3242
test('Code font size in callouts and smaller slide is scaled down', async ({ page }) => {
3343
await page.goto('./revealjs/code-font-size.html');
3444
await page.locator('body').press('ArrowRight');
@@ -116,4 +126,13 @@ test('Code font size is correctly set', async ({ page }) => {
116126
expect(
117127
await getCSSProperty(page.locator("#non-highligted pre code"), 'font-size', true)
118128
).toBeCloseTo(codeBlockFontSize);
129+
});
130+
131+
test('Callouts colors can be customized', async ({ page }) => {
132+
await page.goto('./revealjs/callouts/custom-colors.html');
133+
await checkColor(page.locator('div.callout-note'), 'border-left-color', asRGB(128, 0, 128));
134+
await checkColor(page.locator('div.callout-tip'), 'border-left-color', asRGB(255, 255, 0));
135+
await checkColor(page.locator('div.callout-warning'), 'border-left-color', asRGB(173, 216, 230));
136+
await checkColor(page.locator('div.callout-important'), 'border-left-color', asRGB(128, 128, 128));
137+
await checkColor(page.locator('div.callout-caution'), 'border-left-color', asRGB(0, 128, 0));
119138
});

0 commit comments

Comments
 (0)