Skip to content

Commit 49e99ee

Browse files
committed
Add support for rendering alert icon in README
1 parent a0b84b3 commit 49e99ee

File tree

8 files changed

+71
-0
lines changed

8 files changed

+71
-0
lines changed

app/styles/crate/version.module.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,24 @@
177177
line-height: 1;
178178
}
179179

180+
& > :global(.markdown-alert-title)::before {
181+
content: '';
182+
margin-right: .5rem;
183+
background-color: var(--gray-border);
184+
width: 1em;
185+
height: 1em;
186+
}
187+
180188
&:global(.markdown-alert-note) {
181189
border-left-color: var(--fg-color-note);
182190

183191
& > :global(.markdown-alert-title) {
184192
color: var(--fg-color-note);
193+
194+
&:before {
195+
mask: url("/assets/alert-note.svg");
196+
background-color: var(--fg-color-note);
197+
}
185198
}
186199
}
187200

@@ -190,6 +203,11 @@
190203

191204
& > :global(.markdown-alert-title) {
192205
color: var(--fg-color-tip);
206+
207+
&:before {
208+
mask: url("/assets/alert-tip.svg");
209+
background-color: var(--fg-color-tip);
210+
}
193211
}
194212
}
195213

@@ -198,6 +216,11 @@
198216

199217
& > :global(.markdown-alert-title) {
200218
color: var(--fg-color-important);
219+
220+
&:before {
221+
mask: url("/assets/alert-important.svg");
222+
background-color: var(--fg-color-important);
223+
}
201224
}
202225
}
203226

@@ -206,6 +229,11 @@
206229

207230
& > :global(.markdown-alert-title) {
208231
color: var(--fg-color-warning);
232+
233+
&:before {
234+
mask: url("/assets/alert-warning.svg");
235+
background-color: var(--fg-color-warning);
236+
}
209237
}
210238
}
211239

@@ -214,6 +242,11 @@
214242

215243
& > :global(.markdown-alert-title) {
216244
color: var(--fg-color-caution);
245+
246+
&:before {
247+
mask: url("/assets/alert-caution.svg");
248+
background-color: var(--fg-color-caution);
249+
}
217250
}
218251
}
219252
}

e2e/acceptance/readme-rendering.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ const README_HTML = `
2323
<p>Advises about risks or negative outcomes of certain actions.</p>
2424
</div>
2525
26+
<div class="markdown-alert markdown-alert-note">
27+
<p class="markdown-alert-title">Note</p>
28+
<div class="markdown-alert markdown-alert-important">
29+
<p class="markdown-alert-title">Important</p>
30+
<div class="markdown-alert markdown-alert-caution">
31+
<p class="markdown-alert-title">Caution</p>
32+
<p>Rick roll</p>
33+
<p>Never gonna give you up</p>
34+
</div>
35+
</div>
36+
</div>
2637
2738
<p><strong>Serde is a framework for <em>ser</em>ializing and <em>de</em>serializing Rust data structures efficiently and generically.</strong></p>
2839
<hr>

public/assets/alert-caution.svg

Lines changed: 3 additions & 0 deletions
Loading

public/assets/alert-important.svg

Lines changed: 3 additions & 0 deletions
Loading

public/assets/alert-note.svg

Lines changed: 3 additions & 0 deletions
Loading

public/assets/alert-tip.svg

Lines changed: 3 additions & 0 deletions
Loading

public/assets/alert-warning.svg

Lines changed: 3 additions & 0 deletions
Loading

tests/acceptance/readme-rendering-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ const README_HTML = `
3030
<p>Advises about risks or negative outcomes of certain actions.</p>
3131
</div>
3232
33+
<div class="markdown-alert markdown-alert-note">
34+
<p class="markdown-alert-title">Note</p>
35+
<div class="markdown-alert markdown-alert-important">
36+
<p class="markdown-alert-title">Important</p>
37+
<div class="markdown-alert markdown-alert-caution">
38+
<p class="markdown-alert-title">Caution</p>
39+
<p>Rick roll</p>
40+
<p>Never gonna give you up</p>
41+
</div>
42+
</div>
43+
</div>
44+
3345
<p><strong>Serde is a framework for <em>ser</em>ializing and <em>de</em>serializing Rust data structures efficiently and generically.</strong></p>
3446
<hr>
3547
<p>You may be looking for:</p>

0 commit comments

Comments
 (0)