Skip to content

Commit c642f5f

Browse files
authored
Merge pull request #2187 from notriddle/notriddle/warning-block
Add `.warning` class for doc author use
2 parents d5b1676 + ceb8b50 commit c642f5f

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

guide/src/format/mdbook.md

+48
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,51 @@ contents (sidebar) by including a `\{{#title ...}}` near the top of the page.
314314
```hbs
315315
\{{#title My Title}}
316316
```
317+
318+
## HTML classes provided by mdBook
319+
320+
<img class="right" src="images/rust-logo-blk.svg" alt="The Rust logo">
321+
322+
### `class="left"` and `"right"`
323+
324+
These classes are provided by default, for inline HTML to float images.
325+
326+
```html
327+
<img class="right" src="images/rust-logo-blk.svg" alt="The Rust logo">
328+
```
329+
330+
### `class="hidden"`
331+
332+
HTML tags with class `hidden` will not be shown.
333+
334+
```html
335+
<div class="hidden">This will not be seen.</div>
336+
```
337+
338+
<div class="hidden">This will not be seen.</div>
339+
340+
### `class="warning"`
341+
342+
To make a warning or similar note stand out, wrap it in a warning div.
343+
344+
```html
345+
<div class="warning">
346+
347+
This is a bad thing that you should pay attention to.
348+
349+
Warning blocks should be used sparingly in documentation, to avoid "warning
350+
fatique," where people are trained to ignore them because they usually don't
351+
matter for what they're doing.
352+
353+
</div>
354+
```
355+
356+
<div class="warning">
357+
358+
This is a bad thing that you should pay attention to.
359+
360+
Warning blocks should be used sparingly in documentation, to avoid "warning
361+
fatique," where people are trained to ignore them because they usually don't
362+
matter for what they're doing.
363+
364+
</div>

src/theme/css/general.css

+23
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,29 @@ blockquote {
156156
border-block-end: .1em solid var(--quote-border);
157157
}
158158

159+
.warning {
160+
margin: 20px;
161+
padding: 0 20px;
162+
border-inline-start: 2px solid var(--warning-border);
163+
}
164+
165+
.warning:before {
166+
position: absolute;
167+
width: 3rem;
168+
height: 3rem;
169+
margin-inline-start: calc(-1.5rem - 21px);
170+
content: "ⓘ";
171+
text-align: center;
172+
background-color: var(--bg);
173+
color: var(--warning-border);
174+
font-weight: bold;
175+
font-size: 2rem;
176+
}
177+
178+
blockquote .warning:before {
179+
background-color: var(--quote-bg);
180+
}
181+
159182
kbd {
160183
background-color: var(--table-border-color);
161184
border-radius: 4px;

src/theme/css/variables.css

+12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
--quote-bg: hsl(226, 15%, 17%);
3939
--quote-border: hsl(226, 15%, 22%);
4040

41+
--warning-border: #ff8e00;
42+
4143
--table-border-color: hsl(210, 25%, 13%);
4244
--table-header-bg: hsl(210, 25%, 28%);
4345
--table-alternate-bg: hsl(210, 25%, 11%);
@@ -80,6 +82,8 @@
8082
--quote-bg: hsl(234, 21%, 18%);
8183
--quote-border: hsl(234, 21%, 23%);
8284

85+
--warning-border: #ff8e00;
86+
8387
--table-border-color: hsl(200, 7%, 13%);
8488
--table-header-bg: hsl(200, 7%, 28%);
8589
--table-alternate-bg: hsl(200, 7%, 11%);
@@ -122,6 +126,8 @@
122126
--quote-bg: hsl(197, 37%, 96%);
123127
--quote-border: hsl(197, 37%, 91%);
124128

129+
--warning-border: #ff8e00;
130+
125131
--table-border-color: hsl(0, 0%, 95%);
126132
--table-header-bg: hsl(0, 0%, 80%);
127133
--table-alternate-bg: hsl(0, 0%, 97%);
@@ -164,6 +170,8 @@
164170
--quote-bg: hsl(226, 15%, 17%);
165171
--quote-border: hsl(226, 15%, 22%);
166172

173+
--warning-border: #ff8e00;
174+
167175
--table-border-color: hsl(226, 23%, 16%);
168176
--table-header-bg: hsl(226, 23%, 31%);
169177
--table-alternate-bg: hsl(226, 23%, 14%);
@@ -206,6 +214,8 @@
206214
--quote-bg: hsl(60, 5%, 75%);
207215
--quote-border: hsl(60, 5%, 70%);
208216

217+
--warning-border: #ff8e00;
218+
209219
--table-border-color: hsl(60, 9%, 82%);
210220
--table-header-bg: #b3a497;
211221
--table-alternate-bg: hsl(60, 9%, 84%);
@@ -249,6 +259,8 @@
249259
--quote-bg: hsl(234, 21%, 18%);
250260
--quote-border: hsl(234, 21%, 23%);
251261

262+
--warning-border: #ff8e00;
263+
252264
--table-border-color: hsl(200, 7%, 13%);
253265
--table-header-bg: hsl(200, 7%, 28%);
254266
--table-alternate-bg: hsl(200, 7%, 11%);

0 commit comments

Comments
 (0)