Skip to content

Commit e18c7fb

Browse files
Icon macro update (#171)
* add new tokens as css vars * theme toggle and more updates * fix docsearch background blur * more margin * replace all cdn dependencies, move toggle back to header * rework theme mechanism so toggle buttons are styled right away, add docs for lucide icons * fix build * try fixing docsearch styles * setTheme in head scripts improved * move docsearch styles to vendor folder * preserve css vars in build * Trigger Build * small docsearch styles * fix some styles for the icons macro * update doc * fix secondary nav background * increase icon class size * Update preview source for images and icons * update the docs * Small docs update * more text color styles, better icon class * don't show ext link icon on images or svg --------- Co-authored-by: Eric Schneider <[email protected]>
1 parent a959997 commit e18c7fb

13 files changed

+274
-114
lines changed

preview-src/asciidoc/images.adoc

Lines changed: 192 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Images and media
1+
= Images, icons, and media
22
:idprefix:
33
:idseparator: -
44
:figure-caption!:
@@ -8,24 +8,24 @@
88
== Block images
99

1010
.Optional title
11-
image::../img/screenshot.png[Screenshot of Astra Portal Home]
11+
image::../img/screenshot.png[alt="Screenshot of Astra Portal Home"]
1212

1313
=== Sizing and alignment
1414

15-
.400px width, align="left"
16-
image::../img/screenshot.png[Screenshot of Astra Portal Home,400,align="left"]
15+
.width=400,align=left
16+
image::../img/screenshot.png[alt="Screenshot of Astra Portal Home",width=400,align=left]
1717

18-
.400px width, align="right"
19-
image::../img/screenshot.png[Screenshot of Astra Portal Home,400,align="right"]
18+
.width=400 width,align=right
19+
image::../img/screenshot.png[alt="Screenshot of Astra Portal Home",width=400,align=right]
2020

21-
.400px width, align="center"
22-
image::../img/screenshot.png[Screenshot of Astra Portal Home,400,align="center"]
21+
.width=400 width,align=center
22+
image::../img/screenshot.png[alt="Screenshot of Astra Portal Home",width=400,align=center]
2323

2424
=== Float
2525

2626
[.float-group]
2727
--
28-
image:../img/screenshot.png[Screenshot of Astra Portal Home,300,float=right,role=float-gap]
28+
image:../img/screenshot.png[alt="Screenshot of Astra Portal Home",300,float=right,role=float-gap]
2929
In AsciiDoc, creating paragraphs is a straightforward process that does not require any special markup. A paragraph can be defined as one or more lines of consecutive text that are logically grouped together. To differentiate between paragraphs, you simply need to insert at least one blank line between them.
3030
--
3131

@@ -35,149 +35,262 @@ image::../img/multirepo-ssg.svg[Multirepo SSG,300,float=left,role=float-gap]
3535
In AsciiDoc, creating paragraphs is a straightforward process that does not require any special markup. A paragraph can be defined as one or more lines of consecutive text that are logically grouped together. To differentiate between paragraphs, you simply need to insert at least one blank line between them.
3636
--
3737

38-
== Inline images
39-
40-
Click image:../img/play_circle_FILL0_wght400_GRAD0_opsz24.svg[title=Play] to get the party started.
38+
=== Light and dark mode images
4139

42-
Click image:../img/pause_circle_FILL0_wght400_GRAD0_opsz24.svg[title=Pause] when you need a break.
40+
You can make an image appear differently in light mode vs. dark mode.
4341

44-
== Image theming (light/dark mode)
42+
==== Two separate images
4543

4644
[NOTE]
47-
======
48-
You can define an image such that it appears differently in light mode vs. dark mode.
49-
There are methods for doing this.
45+
====
46+
Define two images: one that looks good in light mode, and one that looks good in dark mode.
47+
Then, assign the corresponding `for-light` and `for-dark` roles to each image.
48+
49+
* All non-SVG images, such as screenshot PNG files, must use this method.
50+
* All SVG images that do not use <<svg-images-css,CSS variables>> must use this method.
5051
51-
Method 1: Two separate images::
52-
Define two images, one that looks good in light mode and one that looks good in dark mode.
53-
Assign the corresponding roles -- `for-light` and `for-dark` -- to each image.
54-
+
55-
All non-SVG images, such as screenshot PNG files, must use this method.
56-
All SVG images that do not use CSS variables must also use this method.
57-
+
58-
.block image
59-
[source,asciidoc]
60-
----
61-
image::light-mode-illustration.png[Alt text,400,role=for-light]
62-
image::dark-mode-illustration.png[Alt text,400,role=for-dark]
63-
----
64-
+
65-
.inline image
6652
[source,asciidoc]
6753
----
68-
Click the Astra Vector icon image:../img/astra-vector-light.svg[title="Astra Vector",role=for-light] image:../img/astra-vector-dark.svg[title="Astra Vector",role=for-dark].
54+
image::vector-ui-light.png[alt="Alt text",width=400,role=for-light]
55+
image::vector-ui-dark.png[alt="Alt text",width=400,role=for-dark]
6956
----
57+
====
7058

71-
Method 2: SVG image with CSS variables::
59+
image::../img/vector-ui-light.png[alt="Alt text",width=400,role=for-light]
60+
image::../img/vector-ui-dark.png[alt="Alt text",width=400,role=for-dark]
61+
62+
[#svg-images-css]
63+
==== SVG images with CSS variables
64+
65+
[NOTE]
66+
======
7267
Use the custom `svg` macro to define an SVG image that uses CSS variables to support light and dark mode.
73-
+
74-
.block svg
75-
[source,asciidoc]
76-
----
77-
svg::ROOT:illustration.svg[Alt text,400]
78-
----
79-
+
80-
.inline svg
68+
8169
[source,asciidoc]
8270
----
83-
Click the Astra Vector icon svg:ROOT:your-diagram.svg[title="Astra Vector"].
71+
svg::ROOT:illustration.svg[alt="Alt text",width=400]
72+
svg::ROOT:illustration.svg[Alt text,400,275]
8473
----
85-
+
74+
75+
The `svg` macro supports the following attributes: `width`, `height`, `role`, `alt`, `ariaLabel` and `title`.
76+
8677
[IMPORTANT]
8778
====
8879
CSS variables must use the tokens supported by the UI.
8980
For example:
9081

91-
[source,svg]
82+
[source,svg,subs="+quotes"]
9283
----
9384
<svg viewBox="0 0 300 200" fill="none">
94-
<path fill="var(--ds-text-primary)" d="..." />
95-
<path stroke="var(--ds-primary-outlined-border)" d="..." />
96-
<path fill="var(--ds-neutral-outlined-border)" d="..." />
85+
<path fill="**var(--ds-text-primary)**" d="..." />
86+
<path stroke="**var(--ds-primary-outlined-border)**" d="..." />
87+
<path fill="**var(--ds-neutral-outlined-border)**" d="..." />
9788
</svg>
9889
----
9990
====
10091
======
10192

102-
.themed block image
103-
image::../img/light-mode-illustration.png[Alt text,400,role=for-light]
93+
// svg::../img/quickstart-overview.svg[]
10494

105-
.themed block image
106-
image::../img/dark-mode-illustration.png[Alt text,400,role=for-dark]
95+
[#icons]
96+
== Icons
10797

108-
.themed inline image
109-
Click the Astra Vector icon image:../img/astra-vector-light.svg[title="Astra Vector",role=for-light] image:../img/astra-vector-dark.svg[title="Astra Vector",role=for-dark].
98+
You can add icons in line with text and other elements.
11099

111-
== Icons
100+
[#font-icons]
101+
=== Font icons
112102

113103
[NOTE]
114104
======
115-
You can define icons from https://fonts.google.com/icons?icon.set=Material+Icons&icon.style=Outlined[Material Icons,window=_blank] and https://lucide.dev/icons/[Lucide Icons,window=_blank]. You can also apply an svg file using the customized `icon` macro.
105+
Use the `icon` macro to invoke font icons from https://lucide.dev/icons/[Lucide Icons] and https://fonts.google.com/icons[Material Icons].
106+
The `icon` macro follows https://developers.google.com/style/ui-elements#buttons[accessibility standards] and provides built-in support for light and dark mode.
116107
117-
Method 1: Inline icon macro with an svg file::
118-
The customized inline icon macro accepts a file path as it's target source. The file must be an svg file.
119-
+
120-
This methods supports using CSS variables within the svg.
121-
+
122-
[source]
108+
Lucide is the default icon set.
109+
You can invoke a Lucide icon with either `\icon:ICON-NAME[]` or `\icon:lucide:ICON-NAME[]`:
110+
111+
.Lucide
112+
[source,asciidoc]
123113
----
124-
icon:ROOT:ui/icons/vector.svg[]
114+
Click icon:settings[name="Settings"] to configure your settings. // <.>
115+
116+
icon:moon[alt="That's no moon"] // <.>
117+
118+
icon:sun[ariaLabel="Day time"] // <.>
119+
120+
icon:atom[title="Split the atom"] // <.>
121+
122+
icon:star[role="text-failure text-2xl"] // <.>
123+
124+
icon:star[size="60"] or icon:star[60] // <.>
125125
----
126126
127-
Method 2: Inline icon macro with a material-icons target::
128-
The customized inline icon macro supports material icon names as it's target source prefixed with `material-icons:`. Ensure the name is lower case with underscores instead of spaces.
127+
<.> Use the `name` attribute to add visible text to the right of the icon.
128+
129+
<.> Use the `alt` attribute to define an `aria-label` for the icon.
130+
The text is invisible but is read by screen readers.
129131
+
130-
This macro does not yet support Lucide icons.
132+
_Do not use `alt` if `name` or `ariaLabel` is already defined._
133+
134+
<.> Identical to the `alt` attribute.
131135
+
132-
This method supports light and dark mode automatically.
136+
_Do not use `ariaLabel` if `name` or `alt` is already defined._
137+
138+
<.> The `title` attribute provides a visible tooltip on hover for pointer devices (not visible on touch devices).
133139
+
134-
[source]
140+
_The `title` attribute is not read by most screen readers, and therefore its use is discouraged._
141+
_If used, make sure to also define `alt` or `ariaLabel` to ensure accessibility._
142+
143+
<.> Use the `role` attribute to apply Tailwind CSS classes to the icon.
144+
145+
<.> Use the `size` attribute to define the size of the icon in pixels.
146+
Alternatively, you can define the size in the first https://docs.asciidoctor.org/asciidoc/latest/attributes/positional-and-named-attributes/#positional[positional attribute] (shorthand for the `size` attribute).
147+
148+
You can invoke a Material icon with `\icon:material:icon-name[]`.
149+
All of the same attributes apply:
150+
151+
.Material
152+
[source,asciidoc]
135153
----
136-
icon:material-icons:thumb_up[]
154+
Click icon:material:settings[name="Settings"] to configure your settings.
155+
156+
icon:material:air[alt="Whooosh"]
157+
158+
icon:material:volume-up[title="Turn it up"]
159+
160+
icon:material:directions-boat[role="text-warning text-2xl"]
161+
162+
icon:material:thumb-up[size=60]
137163
----
138164
139-
Method 3: material-icons role::
140-
Use the custom role `material-icons` on block or inline content. The content must be a material icon name in lower case. If there are spaces in the name, use underscores instead.
165+
.Legacy font icon methods
166+
[%collapsible]
167+
=====
168+
[WARNING]
169+
====
170+
These methods were previously used to invoke font icons and should no longer be used.
171+
====
172+
173+
Block or inline span with material-icons role::
141174
+
175+
--
176+
Use the custom role `material-icons` on block or inline content. The content must be a material icon name in lower case. If there are spaces in the name, use underscores instead.
177+
142178
This method supports light and dark mode automatically.
143-
+
179+
144180
.block style
145181
[source]
146182
----
147183
[.material-icons]
148184
thumb_up
149185
----
150-
+
186+
151187
.Inline style using a text span
152188
[source]
153189
----
154190
Inline material icons [.material-icons]#thumb_up#
155191
----
156-
+
192+
157193
[.material-icons]#thumb_up# [.material-icons]#rocket_launch#
194+
--
158195

159-
Method 4: Lucide icons with HTML passthrough::
160-
Use block or inline HTML passthrough to create an icon element `<i class="icon-{icon-name}"></i>`.
196+
HTML passthrough::
161197
+
198+
--
199+
Use block or inline HTML passthrough to create an icon element `<i class="icon-ICON-NAME"></i>`.
200+
162201
This method supports light and dark mode automatically.
163-
+
202+
164203
.Block passthrough
165204
[source]
166205
----
167206
++++
168207
<i class="icon-boom-box"></i>
169208
++++
170209
----
171-
+
210+
172211
.Inline passthrough
173212
[source]
174213
----
175214
Inline lucide icons +++<i class="icon-boom-box"></i>+++
176215
----
177-
+
216+
178217
+++<i class="icon-boom-box"></i>+++ +++<i class="icon-atom"></i>+++ +++<i class="icon-moon"></i>+++
218+
--
219+
=====
220+
======
221+
222+
// Lucide::
223+
// +
224+
// Click icon:settings[name="Settings"] to configure your settings.
225+
// +
226+
// icon:moon[alt="That's no moon"]
227+
// +
228+
// icon:atom[title="Split the atom"]
229+
// +
230+
// icon:star[role="text-failure text-2xl"]
231+
// +
232+
// icon:star[size="60"]
233+
234+
// Material::
235+
// +
236+
// Click icon:material:settings[name="Settings"] to configure your settings.
237+
// +
238+
// icon:material:air[alt="Whooosh"]
239+
// +
240+
// icon:material:volume-up[title="Turn it up"]
241+
// +
242+
// icon:material:directions-boat[role="text-warning text-2xl"]
243+
// +
244+
// icon:material:thumb-up[size=60]
245+
246+
=== SVG icons
247+
248+
[NOTE]
179249
======
250+
Use the inline `svg` macro to display a local SVG file as an icon.
180251
252+
[source,asciidoc]
253+
----
254+
svg:ROOT:ui/icons/vector.svg[role="icon"] // <.>
255+
256+
Click svg:ROOT:ui/icons/vector.svg[role="icon"] *Search* to run a similarity search based on the selected document's vector.
257+
258+
svg:ROOT:ui/icons/vector.svg[role="icon text-2xl"] // <.>
259+
260+
svg:ROOT:ui/icons/vector.svg[width="60",height="60"] // <.>
261+
----
262+
263+
<.> The `icon` role adds CSS styles that set the width and height of the image to an appropriate size relative to the font size of the parent element.
264+
Without the `icon` role, the image displays as large as possible unless a width and height is set in the SVG file itself (not recommended).
265+
266+
<.> Manually control the icon size using Tailwind `text-*` utilities, such as `text-2xl`.
267+
268+
<.> Manually control the icon size using the `width` and `height` attributes.
269+
270+
[IMPORTANT]
271+
====
272+
Unlike <<font-icons,font icons>>, the `svg` macro doesn't automatically support light and dark mode.
273+
You'll need to add supported <<svg-images-css,CSS variables>> to the SVG file for the icon to display properly in light and dark mode.
274+
275+
If the svg is a simple, single-color icon, you can use `currentColor` for all fill and stroke colors.
276+
This will automatically inherit the text color of the parent element or the body text color which is black or white depending on the theme.
277+
====
278+
======
279+
280+
// Click svg:ROOT:ui/icons/vector.svg[role="icon"] *Search* to run a similarity search based on the selected document's vector.
281+
282+
[#inline-images]
283+
== Inline images
284+
285+
[IMPORTANT]
286+
====
287+
Avoid using inline images.
288+
Use <<icons>> instead.
289+
====
290+
291+
Click image:../img/play_circle_FILL0_wght400_GRAD0_opsz24.svg[title=Play] to get the party started.
292+
293+
Click image:../img/pause_circle_FILL0_wght400_GRAD0_opsz24.svg[title=Pause] when you need a break.
181294

182295
== Video
183296

-451 KB
Binary file not shown.
-456 KB
Binary file not shown.

0 commit comments

Comments
 (0)