Skip to content

Commit 1f2f740

Browse files
Add CSS filter for auto-dark figures (#2919)
Thanks to @gadenbuie Fixes #2729. Closes #2854
1 parent aa23abd commit 1f2f740

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# pkgdown (development version)
22

3+
* Plots in dark mode are now transformed with a CSS filter to improve their
4+
visibility (thanks to @gadenbuie).
35
* Updated the translations vignette with instructions for building non-English sites through Github Actions.
46
* `build_site()` gained a `quiet` argument, which is propagated to other functions
57
(e.g., `build_articles()`) and is useful for debugging build errors on GH actions.

R/test.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ NULL
8080
#' plot(1:10)
8181
#' lines(1:10)
8282
#' text(2, 5, "Hello", srt = 30, cex = 2)
83+
#'
84+
#' plot(1:3, col = c("red", "green", "blue"), pch = 16, cex = 10)
8385
NULL
8486

8587
#' Test case: tables

inst/BS5/assets/pkgdown.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,3 +930,21 @@ figure>figcaption.quarto-float-caption-top {
930930
--mermaid-node-bg-color: RGBA(var(--bs-primary-rgb), 0.1);
931931
--mermaid-node-fg-color: var(--bs-primary);
932932
}
933+
934+
// aut-dark mode for images ---------------------------------------
935+
936+
@mixin invert-filter {
937+
938+
img:not(.logo),
939+
.html-widget {
940+
filter: invert(100%) hue-rotate(180deg);
941+
}
942+
}
943+
944+
[data-bs-theme="dark"] {
945+
@include invert-filter;
946+
947+
.no-invert-dark-mode {
948+
@include invert-filter;
949+
}
950+
}

man/test-figures.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
*_files
55

66
/.quarto/
7+
8+
**/*.quarto_ipynb

0 commit comments

Comments
 (0)