Skip to content

Commit 1807e28

Browse files
committed
fix some styles for the icons macro
1 parent 6d9a5c1 commit 1807e28

File tree

6 files changed

+66
-34
lines changed

6 files changed

+66
-34
lines changed

preview-src/asciidoc/images.adoc

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,31 +112,57 @@ Click the Astra Vector icon image:../img/astra-vector-light.svg[title="Astra Vec
112112

113113
[NOTE]
114114
======
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.
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] with the icon macro. You can also create custom icons with SVG files using the svg macro.
116116
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.
117+
Method 1: icon macro::
118+
The inline icon macro accepts a Lucide or Material icon name as the target source.
119119
+
120-
This methods supports using CSS variables within the svg.
120+
This method supports light and dark mode automatically.
121121
+
122-
[source]
123-
----
124-
icon:ROOT:ui/icons/vector.svg[]
122+
[source,title="Lucide"]
125123
----
124+
// the icon macro uses lucide by default
125+
icon:boom-box[]
126+
// or specifiy lucide
127+
icon:lucide:boom-box[]
126128
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.
129+
// alt or title attribute create an aria-label
130+
icon:atom[title="Split the atom"]
131+
icon:moon[alt="That's no moon"]
132+
133+
// customize with tailwind classes as the role
134+
With tailwind roles icon:star[role="text-amber-600 text-2xl"]
135+
136+
// customize the size in px
137+
icon:star[size="60"]
138+
----
129139
+
130-
This macro does not yet support Lucide icons.
140+
[source,title="Material"]
141+
----
142+
// specifiy material
143+
icon:material:chevron-down[]
144+
145+
// alt or title attribute create an aria-label
146+
icon:material:air[alt="Whooosh"]
147+
148+
// customize with tailwind classes as the role
149+
icon:material:directions-boat[role="text-amber-600 text-2xl"]
150+
151+
// customize the size in px
152+
icon:material:thumb-up[size=60]
153+
----
154+
155+
Method 2: svg macro with icon role::
156+
Display a local SVG file with the icon role.
131157
+
132-
This method supports light and dark mode automatically.
158+
This methods supports using CSS variables within the svg.
133159
+
134160
[source]
135161
----
136-
icon:material-icons:thumb_up[]
162+
svg:ROOT:ui/icons/vector.svg[role="icon"]
137163
----
138164
139-
Method 3: material-icons role::
165+
Method 3: block or inline span with material-icons role::
140166
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.
141167
+
142168
This method supports light and dark mode automatically.
@@ -156,7 +182,7 @@ Inline material icons [.material-icons]#thumb_up#
156182
+
157183
[.material-icons]#thumb_up# [.material-icons]#rocket_launch#
158184
159-
Method 4: Lucide icons with HTML passthrough::
185+
Method 4: HTML passthrough::
160186
Use block or inline HTML passthrough to create an icon element `<i class="icon-{icon-name}"></i>`.
161187
+
162188
This method supports light and dark mode automatically.

src/css/asciidoc/admonition-block.css

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
flex-wrap: wrap;
1717
}
1818

19-
.doc .admonitionblock .icon {
19+
.doc .admonitionblock td.icon {
2020
display: flex;
2121
gap: var(--ds-space-1);
2222
align-items: center;
@@ -45,31 +45,31 @@
4545
background: none;
4646
}
4747

48-
.doc .admonitionblock .icon::before {
48+
.doc .admonitionblock td.icon::before {
4949
font-family: "Material Icons Outlined", sans-serif;
5050
font-size: calc(20 / var(--rem-base) * 1rem);
5151
font-weight: normal;
5252
}
5353

5454
/* TIP, NOTE */
55-
.doc .admonitionblock.tip .icon,
56-
.doc .admonitionblock.note .icon {
55+
.doc .admonitionblock.tip td.icon,
56+
.doc .admonitionblock.note td.icon {
5757
background: var(--ds-success-soft-bg);
5858
color: var(--ds-text-primary);
5959
}
6060

61-
.doc .admonitionblock.note .icon::before {
61+
.doc .admonitionblock.note td.icon::before {
6262
color: var(--ds-success-soft-color);
6363
content: "\e88e";
6464
}
6565

66-
.doc .admonitionblock.tip .icon::before {
66+
.doc .admonitionblock.tip td.icon::before {
6767
color: var(--ds-success-soft-color);
6868
content: "\e0f0";
6969
}
7070

7171
/* CAUTION */
72-
.doc .admonitionblock.caution .icon {
72+
.doc .admonitionblock.caution td.icon {
7373
background: var(--ds-warning-soft-bg);
7474
color: var(--ds-text-primary);
7575
}
@@ -78,14 +78,14 @@
7878
border: 1px solid var(--ds-warning-outlined-border);
7979
}
8080

81-
.doc .admonitionblock.caution .icon::before {
81+
.doc .admonitionblock.caution td.icon::before {
8282
color: var(--ds-warning-soft-color);
8383
content: "\e88e";
8484
}
8585

8686
/* WARNING, IMPORTANT */
87-
.doc .admonitionblock.warning .icon,
88-
.doc .admonitionblock.important .icon {
87+
.doc .admonitionblock.warning td.icon,
88+
.doc .admonitionblock.important td.icon {
8989
background: var(--ds-failure-soft-bg);
9090
color: var(--ds-text-primary);
9191
}
@@ -95,12 +95,12 @@
9595
border: 1px solid var(--ds-failure-outlined-border);
9696
}
9797

98-
.doc .admonitionblock.warning .icon::before {
98+
.doc .admonitionblock.warning td.icon::before {
9999
color: var(--ds-failure-soft-color);
100100
content: "\f083";
101101
}
102102

103-
.doc .admonitionblock.important .icon::before {
103+
.doc .admonitionblock.important td.icon::before {
104104
color: var(--ds-failure-soft-color);
105105
content: "\e160";
106106
}

src/css/asciidoc/doc.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@
417417
word-wrap: anywhere;
418418
}
419419

420-
.doc .admonitionblock .icon {
420+
.doc .admonitionblock td.icon {
421421
position: absolute;
422422
top: 0;
423423
left: 0;
@@ -431,13 +431,13 @@
431431
transform: translate(-0.25rem, -50%);
432432
}
433433

434-
.doc .admonitionblock .icon i {
434+
.doc .admonitionblock td.icon i {
435435
display: inline-flex;
436436
align-items: center;
437437
height: 100%;
438438
}
439439

440-
.doc .admonitionblock .icon i::after {
440+
.doc .admonitionblock td.icon i::after {
441441
font-size: 1rem;
442442
font-weight: 600;
443443
font-family: "Roboto Flex", sans-serif;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
@import "lucide-static/font/lucide.css";
2+
3+
[class*=" icon-"], [class^=icon-] {
4+
font-size: 1.25em;
5+
line-height: 1;
6+
vertical-align: sub;
7+
}

src/css/typeface/typeface-material-icons-outlined.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
font-family: 'Material Icons Outlined', sans-serif;
1313
font-weight: normal;
1414
font-style: normal;
15-
font-size: 1.25rem;
15+
font-size: 1.25em;
1616
display: inline-block;
1717
line-height: 1;
1818
text-transform: none;
@@ -28,5 +28,5 @@
2828
-moz-osx-font-smoothing: grayscale;
2929
/* Support for IE. */
3030
font-feature-settings: 'liga';
31-
vertical-align: middle;
31+
vertical-align: sub;
3232
}

src/partials/theme-toggle.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
tabindex="0"
77
value="light"
88
aria-label="Light">
9-
<i class="icon-sun"></i>
9+
<i class="icon-sun text-base"></i>
1010
</button>
1111
<button
1212
class="toggle-button dark w-6 h-6 flex items-center justify-center rounded-full hover:bg-[var(--ds-neutral-plain-hover-bg)] z-0 transition-all"
1313
aria-pressed="false"
1414
tabindex="0"
1515
value="dark"
1616
aria-label="Dark">
17-
<i class="icon-moon"></i>
17+
<i class="icon-moon text-base"></i>
1818
</button>
1919
<button
2020
class="toggle-button system w-6 h-6 flex items-center justify-center rounded-full hover:bg-[var(--ds-neutral-plain-hover-bg)] z-0 transition-all"
2121
aria-pressed="false"
2222
tabindex="0"
2323
value="system"
2424
aria-label="System">
25-
<i class="icon-monitor"></i>
25+
<i class="icon-monitor text-base"></i>
2626
</button>
2727
</div>

0 commit comments

Comments
 (0)