Skip to content

Commit fc6cd8d

Browse files
authored
Merge pull request #11828 from quarto-dev/fix/border-color
2 parents 1fb031d + 4b31c88 commit fc6cd8d

File tree

5 files changed

+94
-9
lines changed

5 files changed

+94
-9
lines changed

news/changelog-1.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All changes included in 1.7:
77
- ([#11549](https://github.com/quarto-dev/quarto-cli/issues/11549)): Fix regression in rendering `dashboard` tabsets into cards without titles.
88
- ([#11580](https://github.com/quarto-dev/quarto-cli/issues/11580)): Fix regression with documents containing `categories` fields that are not strings.
99
- ([#11752](https://github.com/quarto-dev/quarto-cli/issues/11752)): Fix regression with non-alphanumeric characters in `categories` preventing correct filtering of listing.
10+
- ([#11561](https://github.com/quarto-dev/quarto-cli/issues/11561)): Fix a regression with `$border-color` that impacted, callouts borders, tabset borders, and table borders of the defaults themes. `$border-color` is now correctly a mixed of `$body-color` and `$body-bg` even for the default theme.
1011

1112
## YAML validation
1213

src/resources/formats/html/bootstrap/_bootstrap-variables.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,12 @@ $link-weight: $font-weight-base !default;
272272
$link-decoration: null !default;
273273

274274
// border colors
275+
/// if a theme does not provide body-color or body-bg
276+
/// defaults to boostrap own default value for theses variables (in _variables.scss)
275277
$border-color: mix(
276-
if(variable-exists(body-color), $body-color, #fff),
277-
$body-contrast-bg,
278-
30%
278+
if(variable-exists(body-color), $body-color, $gray-900),
279+
if(variable-exists(body-bg), $body-bg, $white),
280+
15%
279281
) !default;
282+
/// Make sure table border are the same as the border color (in case change in bootstrap default)
280283
$table-border-color: $border-color !default;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "Checking that border color for default does not change"
3+
format:
4+
html:
5+
theme: litera
6+
---
7+
8+
::: callout-note
9+
10+
Content
11+
12+
:::
13+
14+
::: {.panel-tabset}
15+
16+
## Tab 1
17+
18+
This is a playground for Quarto.
19+
20+
## Tab 2
21+
22+
Another Tab
23+
24+
## Tab 3
25+
26+
![An image]({{< placeholder 600 400 >}}){#fig-placeholder}
27+
28+
:::
29+
30+
| | mpg| cyl|
31+
|:-------------|---:|---:|
32+
|Mazda RX4 | 21| 6|
33+
|Mazda RX4 Wag | 21| 6|

tests/integration/playwright/src/utils.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,18 @@ export type RGBColor = {
125125
red: number;
126126
green: number;
127127
blue: number;
128+
alpha?: number;
128129
};
129130

130131
export async function checkColor(element, cssProperty, rgbColors: RGBColor) {
131-
await expect(element).toHaveCSS(cssProperty, `rgb(${rgbColors.red}, ${rgbColors.green}, ${rgbColors.blue})`);
132+
const colorString = rgbColors.alpha !== undefined
133+
? `rgba(${rgbColors.red}, ${rgbColors.green}, ${rgbColors.blue}, ${rgbColors.alpha})`
134+
: `rgb(${rgbColors.red}, ${rgbColors.green}, ${rgbColors.blue})`;
135+
await expect(element).toHaveCSS(cssProperty, colorString);
132136
}
133137

134-
export function asRGB(red: number, green: number, blue: number): RGBColor {
135-
return { red, green, blue };
138+
export function asRGB(red: number, green: number, blue: number, alpha?: number): RGBColor {
139+
return { red, green, blue, alpha };
136140
}
137141

138142
export async function getCSSProperty(loc: Locator, variable: string, asNumber = false): Promise<string | number> {
@@ -147,7 +151,6 @@ export async function getCSSProperty(loc: Locator, variable: string, asNumber =
147151
}
148152
}
149153

150-
151154
export async function checkFontSizeIdentical(loc1: Locator, loc2: Locator) {
152155
const loc1FontSize = await getCSSProperty(loc1, 'font-size', false) as string;
153156
await expect(loc2).toHaveCSS('font-size', loc1FontSize);
@@ -157,4 +160,9 @@ export async function checkFontSizeSimilar(loc1: Locator, loc2: Locator, factor:
157160
const loc1FontSize = await getCSSProperty(loc1, 'font-size', true) as number;
158161
const loc2FontSize = await getCSSProperty(loc2, 'font-size', true) as number;
159162
await expect(loc1FontSize).toBeCloseTo(loc2FontSize * factor);
163+
}
164+
165+
export async function checkBorderProperties(element: Locator, side: string, color: RGBColor, width: string) {
166+
await checkColor(element, `border-${side}-color`, color);
167+
await expect(element).toHaveCSS(`border-${side}-width`, width);
160168
}

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

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from '@playwright/test';
2-
import { getCSSProperty } from '../src/utils';
2+
import { asRGB, checkBorderProperties, checkColor, getCSSProperty } from '../src/utils';
33

44
test('Dark and light theme respect user themes', async ({ page }) => {
55
// This document use a custom theme file that change the background color of the title banner
@@ -37,4 +37,44 @@ test('Mainfont can be set to multiple mainfont families', async ({ page }) => {
3737
expect(await getCSSProperty(page.locator('body'), '--bs-body-font-family', false)).toEqual('Creepster, "Cascadia Code", Inter');
3838
await page.goto('./html/mainfont/mainfont-3.html');
3939
expect(await getCSSProperty(page.locator('body'), '--bs-body-font-family', false)).toEqual('Creepster, "Cascadia Code", Inter');
40-
})
40+
})
41+
42+
test('border color from default theme does not change (like disappearing)', async ({ page }) => {
43+
await page.goto('./html/default-border-color.html');
44+
45+
// callout border
46+
const calloutNote = page.locator('div.callout-note');
47+
const calloutBorderColor = asRGB(0, 0, 0, 0.1);
48+
await checkBorderProperties(calloutNote, 'bottom', calloutBorderColor, '1px');
49+
await checkBorderProperties(calloutNote, 'right', calloutBorderColor, '1px');
50+
await checkBorderProperties(calloutNote, 'top', calloutBorderColor, '1px');
51+
52+
// tabset border
53+
const tabContent = page.locator('div.tab-content');
54+
const tabBorderColor = asRGB(225, 225, 226);
55+
await checkBorderProperties(tabContent, 'bottom', tabBorderColor, '1px');
56+
await checkBorderProperties(tabContent, 'right', tabBorderColor, '1px');
57+
await checkBorderProperties(tabContent, 'left', tabBorderColor, '1px');
58+
59+
const activeNavLink = page.locator('li.nav-item > a.nav-link.active');
60+
await checkBorderProperties(activeNavLink, 'top', tabBorderColor, '1px');
61+
await checkBorderProperties(activeNavLink, 'right', tabBorderColor, '1px');
62+
await checkBorderProperties(activeNavLink, 'left', tabBorderColor, '1px');
63+
await checkBorderProperties(activeNavLink, 'bottom', asRGB(255, 255, 255), '1px');
64+
65+
// table borders
66+
const table = page.locator('table');
67+
const headerColor = asRGB(154, 157, 160);
68+
const borderColor = asRGB(214, 216, 217);
69+
// table defines top and bottom borders
70+
await checkBorderProperties(table, 'top', borderColor, '1px');
71+
await checkBorderProperties(table, 'bottom', borderColor, '1px');
72+
73+
// table header row have a specific bottom row, other are colorized but hidden (width 0)
74+
const thead = table.locator('> thead');
75+
await checkBorderProperties(thead, 'bottom', headerColor, '1px');
76+
await checkBorderProperties(thead, 'top', borderColor, '0px');
77+
await checkBorderProperties(thead, 'left', asRGB(0, 0, 0, 0.1), '0px');
78+
await checkBorderProperties(thead, 'right', asRGB(0, 0, 0, 0.1), '0px');
79+
80+
});

0 commit comments

Comments
 (0)