Skip to content

Commit 2e09895

Browse files
authored
FIX: Don't filter images that support the dark theme (#942)
1 parent 3d7e4e5 commit 2e09895

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

docs/user_guide/light-dark.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,14 @@ Change the theme and a new image should be displayed.
103103
Images and content that work in both themes
104104
-------------------------------------------
105105

106-
For images without the :code:`only-dark` class, when the **dark theme** is activated, a white background will automatically be added to ensure the image contents are visible.
107-
If your image is suitable for both light and dark theme, add the CSS class :code:`dark-light` to make your image theme-agnostic.
106+
When the **dark theme** is activated, images that do not support dark mode will
107+
automatically have a white background added to ensure the image contents are
108+
visible, and their brightness will be reduced by a filter.
109+
110+
If your image is suitable for the dark theme, add the CSS class
111+
:code:`only-dark` as noted above. If your image is suitable for both light and
112+
dark theme, add the CSS class :code:`dark-light` to make your image
113+
theme-agnostic.
108114

109115
For example, here's an image without adding this helper class.
110116
Change to the dark theme and a grey background will be present.

src/pydata_sphinx_theme/assets/styles/variables/_color.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ $pst-semantic-colors: (
103103
.only-light {
104104
display: none !important;
105105
}
106-
// adjust images in dark mode
107-
img {
106+
/* Adjust images in dark mode (unless they have class .only-dark or
107+
* .dark-light, in which case assume they're already optimized for dark
108+
* mode).
109+
*/
110+
img:not(.only-dark):not(.dark-light) {
108111
filter: brightness(0.8) contrast(1.2);
109112
}
110113
/* Give images a light background in dark mode in case they have

0 commit comments

Comments
 (0)