Skip to content

Commit cec465c

Browse files
authored
add icons to admonitions (#306)
1 parent 67cbe6a commit cec465c

File tree

10 files changed

+185
-27
lines changed

10 files changed

+185
-27
lines changed

preview-src/admonitions.adoc

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,57 @@ $ npm i -g @antora/cli @antora/site-generator-default
179179
====
180180

181181
Nominavi luptatum eos, an vim hinc philosophia intellegebat.
182-
Eu mea inani iriure.
182+
Eu mea inani iriure.
183+
184+
== Admonition in a table
185+
186+
[options="header",width="100%",cols="2,3a"]
187+
|===
188+
| Parameter
189+
| Explanation
190+
191+
192+
| Parameter name
193+
| Parameter explanation
194+
Lorem ipsum
195+
196+
Dolor sit est.
197+
198+
[NOTE]
199+
====
200+
Note text goes here.
201+
Note should be nicely aligned and have no borders
202+
====
203+
204+
|===
205+
206+
207+
== Admonition first element in an example block
208+
209+
210+
[.tabbed-example]
211+
=====
212+
[.include-with-admonition-first]
213+
======
214+
215+
216+
[WARNING]
217+
====
218+
Admonition should be given enough margin if it is the first element in an example block.
219+
====
220+
221+
======
222+
223+
[.include-with-admonition-not-first]
224+
======
225+
226+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
227+
228+
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
229+
230+
[TIP]
231+
====
232+
Admonition should be given normal margin if it is not the first element in an example block.
233+
====
234+
235+
=====

src/css/doc.css

Lines changed: 107 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ body {
200200

201201
.doc i.fa {
202202
font-style: normal;
203+
font-size: var(--admonition-title-font-size);
204+
}
205+
206+
.doc i.fa::before {
207+
width: 24px;
208+
height: inherit;
209+
background-size: 20px;
210+
background-position-y: center;
211+
filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(7500%) hue-rotate(199deg) brightness(103%) contrast(103%); /* filter to white */
203212
}
204213

205214
.doc p code,
@@ -286,7 +295,7 @@ body {
286295
padding: 0.5rem;
287296
}
288297

289-
.doc table.tableblock td,
298+
.doc table.tableblock > tbody > tr > td,
290299
.doc table.tableblock > :not(thead) th {
291300
border-top: 1px solid var(--table-border-color);
292301
border-bottom: 1px solid var(--table-border-color);
@@ -318,8 +327,8 @@ body {
318327
}
319328

320329
.doc .admonitionblock {
321-
margin: 0 0 1.5rem;
322-
border-left: 4px solid var(--doc-font-color);
330+
margin: 1.5rem 0 1.5rem;
331+
/* border-left: 4px solid var(--doc-font-color); */
323332
border-radius: 0.25rem;
324333
}
325334

@@ -345,7 +354,7 @@ body {
345354
}
346355

347356
.doc .admonitionblock .content {
348-
padding: 1rem 1rem 0.75rem;
357+
padding: 1.5rem 1rem 0.75rem;
349358
/* background: var(--admonition-background); */
350359
width: 100%;
351360
}
@@ -354,19 +363,94 @@ body {
354363
padding: 0;
355364
}
356365

357-
.doc .admonitionblock .icon {
358-
display: none;
359-
/* position: absolute;
360-
top: 0;
366+
.doc .admonitionblock td.icon {
361367
left: 0;
362-
font-size: calc(15 / var(--rem-base) * 1rem);
363-
padding: 0 0.5rem;
364-
height: 1.25rem;
365368
line-height: 1;
369+
padding: 0;
370+
position: absolute;
371+
top: 0;
372+
transform: translate(-1rem, -50%);
373+
}
374+
375+
.doc .tableblock .admonitionblock td.icon {
376+
transform: translate(0, -50%);
377+
border: none;
378+
}
379+
380+
.doc .admonitionblock td.icon i {
381+
color: rgba(var(--colors-neutral-15));
382+
align-items: center;
383+
border-radius: 9999px;
384+
display: inline-flex;
385+
filter: none;
386+
height: 1.5rem;
387+
padding: 0 0.5rem;
388+
width: fit-content;
389+
}
390+
391+
.doc .admonitionblock td.icon i.fa::after {
392+
content: attr(title);
393+
font-family: var(--body-font-family);
394+
font-style: normal;
395+
font-weight: 600;
366396
font-weight: var(--admonition-label-font-weight);
397+
/* padding-left: 0.5rem; */
367398
text-transform: uppercase;
368-
border-radius: 0.45rem;
369-
transform: translate(-0.5rem, -50%); */
399+
}
400+
401+
/* admonition icon and text backgrounds */
402+
403+
.doc .admonitionblock td.icon i.icon-note {
404+
background-color: var(--note-color);
405+
}
406+
407+
.doc .admonitionblock td.icon i.icon-tip {
408+
background-color: var(--tip-border-color);
409+
}
410+
411+
.doc .admonitionblock td.icon i.icon-important {
412+
background-color: var(--important-border-color);
413+
}
414+
415+
.doc .admonitionblock td.icon i.icon-caution {
416+
background-color: var(--caution-border-color);
417+
}
418+
419+
.doc .admonitionblock td.icon i.icon-warning {
420+
background-color: var(--warning-border-color);
421+
}
422+
423+
/* admonition icon contents */
424+
425+
.fa.icon-note::before {
426+
background: url(../img/ndl-icons/information-circle.svg) no-repeat;
427+
content: "";
428+
}
429+
430+
.fa.icon-tip::before {
431+
background: url(../img/ndl-icons/light-bulb.svg) no-repeat;
432+
content: "";
433+
}
434+
435+
.fa.icon-important::before {
436+
background: url(../img/ndl-icons/exclamation-circle.svg) no-repeat;
437+
content: "";
438+
}
439+
440+
.fa.icon-caution::before {
441+
background: url(../img/ndl-icons/fire.svg) no-repeat;
442+
content: "";
443+
}
444+
445+
.fa.icon-warning::before {
446+
background: url(../img/ndl-icons/exclamation-triangle.svg) no-repeat;
447+
content: "";
448+
}
449+
450+
.doc .admonitionblock td .content {
451+
word-wrap: anywhere;
452+
padding: 1rem 1rem 0.75rem;
453+
width: 100%;
370454
}
371455

372456
.doc .admonitionblock a.btn {
@@ -384,7 +468,7 @@ body {
384468
.doc .admonitionblock.warning {
385469
background-color: var(--warning-background-color);
386470
color: var(--warning-color);
387-
border-left-color: var(--warning-border-color);
471+
/* border-left-color: var(--warning-border-color); */
388472
}
389473

390474
.doc .admonitionblock.warning a.btn {
@@ -398,7 +482,7 @@ body {
398482
.doc .admonitionblock.caution {
399483
background-color: var(--caution-background-color);
400484
color: var(--caution-color);
401-
border-left-color: var(--caution-border-color);
485+
/* border-left-color: var(--caution-border-color); */
402486
}
403487

404488
.doc .admonitionblock.caution a {
@@ -416,7 +500,7 @@ body {
416500
.doc .admonitionblock.tip {
417501
background-color: var(--tip-background-color);
418502
color: var(--tip-color);
419-
border-left-color: var(--tip-color);
503+
/* border-left-color: var(--tip-color); */
420504
}
421505

422506
.doc .admonitionblock.tip a {
@@ -434,7 +518,7 @@ body {
434518
.doc .admonitionblock.note {
435519
background-color: var(--note-background-color);
436520
color: var(--note-color);
437-
border-left-color: var(--note-border-color);
521+
/* border-left-color: var(--note-border-color); */
438522
}
439523

440524
.doc .admonitionblock.note a {
@@ -452,7 +536,7 @@ body {
452536
.doc .admonitionblock.important {
453537
background-color: var(--important-background-color);
454538
color: var(--important-color);
455-
border-left-color: var(--important-border-color);
539+
/* border-left-color: var(--important-border-color); */
456540
}
457541

458542
.doc .admonitionblock.important a {
@@ -724,7 +808,7 @@ body {
724808
padding: 0.75rem;
725809
} */
726810

727-
.doc .exampleblock > .content > :first-child {
811+
.doc .exampleblock > .content > :first-child:not(.admonitionblock) {
728812
margin-top: 0;
729813
}
730814

@@ -1077,13 +1161,13 @@ body {
10771161
/* table-layout: fixed; */
10781162
}
10791163

1080-
.doc table.tableblock.frame-all tr:last-child td,
1081-
.doc table.tableblock.frame-ends tr:last-child td {
1164+
.doc table.tableblock.frame-all > tbody > tr:last-child > td,
1165+
.doc table.tableblock.frame-ends > tbody > tr:last-child > td {
10821166
border-bottom: 2.5px solid var(--table-border-color);
10831167
}
10841168

1085-
.doc table.tableblock.frame-all tr:first-child td,
1086-
.doc table.tableblock.frame-ends tr:first-child td {
1169+
.doc table.tableblock.frame-all > tbody > tr:first-child > td,
1170+
.doc table.tableblock.frame-ends > tbody > tr:first-child > td {
10871171
border-top: 2.5px solid var(--table-border-color);
10881172
}
10891173

src/css/labels.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ h2 > .flex-label {
9393
background: rgba(var(--colors-baltic-50));
9494
color: rgba(var(--colors-baltic-10));
9595
font-weight: 600;
96-
font-size: 0.7rem;
96+
font-size: var(--label-title-font-size);
9797
font-style: normal;
9898
}
9999

src/css/themes.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ body.docs #preamble .abstract blockquote {
102102
color: rgba(var(--colors-baltic-60));
103103
}
104104

105-
body.docs .tableblock .icon i {
105+
body.docs .tableblock .icon i:not(.fa) {
106106
color: var(--color-docs);
107107
}
108108

@@ -337,7 +337,7 @@ body.developer #preamble .abstract blockquote {
337337
border-left-color: var(--color-green-600);
338338
}
339339

340-
body.developer .tableblock .icon i {
340+
body.developer .tableblock .icon i:not(.fa) {
341341
color: var(--color-green-600);
342342
}
343343

src/css/vars.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@
380380
--alpha-beta-color: var(--color-black);
381381
--alpha-beta-background-color: rgba(var(--colors-marigold-40));
382382

383+
/* labels and admonitions */
384+
385+
--label-title-font-size: calc(0.8 * var(--font-size-label)); /* set label font size from ndl */
386+
--admonition-title-font-size: var(--font-size-label); /* set admonitino font size from ndl */
387+
383388
/* footer */
384389
--footer-font-size: var(--font-size-body-medium);
385390
--footer-line-height: var(--doc-line-height);
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

src/img/ndl-icons/fire.svg

Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

src/img/ndl-icons/light-bulb.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)