Skip to content

Commit 26e0622

Browse files
Themed images (#24)
* adding class styles and preview src * add callout to adoc * Update preview-src/index.adoc Co-authored-by: Eric Schneider <[email protected]> * Update preview-src/index.adoc Co-authored-by: Eric Schneider <[email protected]> --------- Co-authored-by: Eric Schneider <[email protected]>
1 parent 5948f5d commit 26e0622

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed
451 KB
Loading

preview-src/index.adoc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,53 @@ public static JavaArchive createDeployment() {
927927

928928
== Images
929929

930+
=== Images for Light and Dark modes
931+
932+
[source,adoc]
933+
----
934+
[.for-light]
935+
image::your-light-image.png[Description]
936+
[.for-dark]
937+
image::your-dark-image.png[Description]
938+
939+
// You can also define the role within the macro itself
940+
941+
image::light-mode-illustration.png[Description,role=for-light]
942+
image::dark-mode-illustration.png[Description,role=for-dark]
943+
----
944+
945+
[.for-light]
946+
image::light-mode-illustration.png[Description,400]
947+
[.for-dark]
948+
image::dark-mode-illustration.png[Description,400]
949+
950+
=== SVG with CSS variables for Light and Dark modes
951+
952+
.Currently unsupported
953+
[WARNING]
954+
====
955+
The method described below for embedding an SVG directly into the HTML won't work until Antora adds support for the `opts=inline` option (see https://gitlab.com/antora/antora/-/issues/1001).
956+
Therefore, unless a suitable workaround is discovered, we can't support SVGs with CSS variables until Antora fixes this issue.
957+
====
958+
959+
[source,svg]
960+
----
961+
<svg viewBox="0 0 300 200" fill="none">
962+
<path fill="var(--ds-text-primary)" d="..." />
963+
<path stroke="var(--ds-primary-outlined-border)" d="..." />
964+
<path fill="var(--ds-neutral-outlined-border)" d="..." />
965+
</svg>
966+
----
967+
968+
[source,adoc]
969+
----
970+
image::your-diagram.svg[Description,300,opts=inline] <1>
971+
----
972+
973+
<1> The `opts=inline` attribute is required to embed the SVG directly into the HTML.
974+
975+
image::preview-src/simple-diagram.svg[Simple Diagram,192,opts=inline]
976+
930977
=== Inline images
931978

932979
Click image:play_circle_FILL0_wght400_GRAD0_opsz24.svg[title=Play] to get the party started.
456 KB
Loading

preview-src/simple-diagram.svg

Lines changed: 9 additions & 0 deletions
Loading

src/css/ds-dark.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,16 @@ html[data-theme="dark"] {
143143
@include dark-theme;
144144
}
145145

146+
html[data-theme="dark"] .for-light {
147+
display: none;
148+
}
149+
146150
@media (prefers-color-scheme: dark) {
147151
:root:not([data-theme="light"]):not([data-theme="dark"]) {
148152
@include dark-theme;
149153
}
154+
155+
:root:not([data-theme="light"]):not([data-theme="dark"]) .for-light {
156+
display: none;
157+
}
150158
}

src/css/ds-light.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,16 @@ html[data-theme="light"] {
143143
@include light-theme;
144144
}
145145

146+
html[data-theme="light"] .for-dark {
147+
display: none;
148+
}
149+
146150
@media (prefers-color-scheme: light) {
147151
:root:not([data-theme="light"]):not([data-theme="dark"]) {
148152
@include light-theme;
149153
}
154+
155+
:root:not([data-theme="light"]):not([data-theme="dark"]) .for-dark {
156+
display: none;
157+
}
150158
}

0 commit comments

Comments
 (0)