Skip to content

Commit fa74261

Browse files
SabyaXSachicderv
andauthored
Fix notebook preview title contrast across themes (#15315)
The notebook preview header draws its title on the theme's primary background. Custom theme heading colors were applied to the title, which made it difficult to read on some themes. The title now inherits the header's contrasting text color. - Use `text-bg-primary` on the header for contrasting text - Set the title to `color: inherit` so heading colors no longer apply - Add Playwright tests for four themes, including custom heading colors --------- Co-authored-by: Christophe Dervieux <christophe.dervieux@gmail.com>
1 parent ccc1cf6 commit fa74261

13 files changed

Lines changed: 219 additions & 1 deletion

File tree

‎news/changelog-1.12.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All changes included in 1.12:
1111
## Accessibility
1212

1313
- ([#15269](https://github.com/quarto-dev/quarto-cli/pull/15269)): Announce every link that opens a new tab to screen readers, not only links opened by `link-external-newwindow`. (author: @mcanouil)
14+
- ([#15306](https://github.com/quarto-dev/quarto-cli/issues/15306)): Fix the notebook preview title taking the theme's heading color on the primary-colored header bar, which left it low-contrast or unreadable with themes such as `lux` or a custom `$headings-color`. The title now uses the same color as the header buttons. (author: @SabyaXSachi)
1415

1516
## Formats
1617

‎src/resources/formats/html/embed/template.html‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@
2828
border-bottom: solid 1px;
2929
}
3030

31+
/* The title sits on the theme's primary background, so it inherits the
32+
header's contrasting text color instead of the theme heading color */
3133
#quarto-embed-header h6 {
3234
font-size: 1.1em;
3335
padding-top: 0.6em;
3436
margin-left: 1em;
3537
margin-right: 1em;
3638
font-weight: 400;
39+
color: inherit;
3740
}
3841

3942
#quarto-embed-header a.quarto-back-link,
@@ -123,7 +126,7 @@
123126
</head>
124127

125128
<body>
126-
<nav id="quarto-embed-header" class="headroom fixed-top bg-primary" aria-labelledby="quarto-embed-title">
129+
<nav id="quarto-embed-header" class="headroom fixed-top text-bg-primary" aria-labelledby="quarto-embed-title">
127130

128131
<a href="$if(nbMeta.backHref)$$nbMeta.backHref$$endif$" onclick="window.quartoBackToArticle(); return false;" class="btn btn-primary quarto-back-link"><i class="bi bi-caret-left"></i> $nbMeta.backLabel$</a>
129132
<h6 id="quarto-embed-title"><i class="bi bi-journal-code"></i> $nbMeta.title$</h6>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/notebook.out.ipynb
2+
**/*.quarto_ipynb
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "Home"
3+
theme: cerulean
4+
---
5+
6+
{{< embed notebook.ipynb#answer >}}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "answer",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"data": {
11+
"text/plain": [
12+
"2"
13+
]
14+
},
15+
"execution_count": 1,
16+
"metadata": {},
17+
"output_type": "execute_result"
18+
}
19+
],
20+
"source": [
21+
"#| label: answer\n",
22+
"1 + 1"
23+
]
24+
}
25+
],
26+
"metadata": {
27+
"kernelspec": {
28+
"display_name": "Python 3",
29+
"language": "python",
30+
"name": "python3"
31+
},
32+
"language_info": {
33+
"name": "python"
34+
}
35+
},
36+
"nbformat": 4,
37+
"nbformat_minor": 5
38+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/notebook.out.ipynb
2+
**/*.quarto_ipynb
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "Home"
3+
theme: lux
4+
---
5+
6+
{{< embed notebook.ipynb#answer >}}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "answer",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"data": {
11+
"text/plain": [
12+
"2"
13+
]
14+
},
15+
"execution_count": 1,
16+
"metadata": {},
17+
"output_type": "execute_result"
18+
}
19+
],
20+
"source": [
21+
"#| label: answer\n",
22+
"1 + 1"
23+
]
24+
}
25+
],
26+
"metadata": {
27+
"kernelspec": {
28+
"display_name": "Python 3",
29+
"language": "python",
30+
"name": "python3"
31+
},
32+
"language_info": {
33+
"name": "python"
34+
}
35+
},
36+
"nbformat": 4,
37+
"nbformat_minor": 5
38+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/notebook.out.ipynb
2+
**/*.quarto_ipynb
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "Home"
3+
theme: [default, theme-light-heading.scss]
4+
---
5+
6+
{{< embed notebook.ipynb#answer >}}

0 commit comments

Comments
 (0)