Skip to content

Commit afac04b

Browse files
talumjonrohansimurai
authored
Add footnote styles (#1616)
* Add footnote styles Port the styles from dotcom to Primer. * Create gold-games-tickle.md * disable lints * Nest footnotes within markdown-body Co-authored-by: Jon Rohan <[email protected]> * Style footnotes * Add footnotes to docs * Lint * Bump right border Bumps the right border out a bit for symmetry in the :target border style. * Darken text when targeted Co-authored-by: Jon Rohan <[email protected]> Co-authored-by: simurai <[email protected]>
1 parent b8fe364 commit afac04b

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

.changeset/gold-games-tickle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/css": minor
3+
---
4+
5+
Adding footnote styles to markdown-body.

docs/content/components/markdown.md

+31
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,25 @@ bundle: markdown
276276

277277
<p><img src="http://placekitten.com/g/1200/800/"></p>
278278

279+
<p>
280+
Here's a simple footnote,<sup><a href="#user-content-fn-1-12345" id="user-content-fnref-1-12345" data-footnote-ref="" aria-describedby="footnote-label">1</a></sup> and here's a longer one.<sup><a href="#user-content-fn-bignote-12345" id="user-content-fnref-bignote-12345" data-footnote-ref="" aria-describedby="footnote-label">2</a></sup>
281+
</p>
282+
283+
<section data-footnotes="" class="footnotes">
284+
<h2 id="footnote-label" class="sr-only">Footnotes</h2>
285+
<ol>
286+
<li id="user-content-fn-1-12345">
287+
<p>This is the first footnote. <a href="#user-content-fnref-1-12345" data-footnote-backref="" class="data-footnote-backref" aria-label="Back to content"><g-emoji class="g-emoji" alias="leftwards_arrow_with_hook" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/21a9.png">↩</g-emoji></a></p>
288+
</li>
289+
<li id="user-content-fn-bignote-12345">
290+
<p>Here's one with multiple paragraphs and code.</p>
291+
<p>Indent paragraphs to include them in the footnote.</p>
292+
<p><code>{ my code }</code></p>
293+
<p>Add as many paragraphs as you like. <a href="#user-content-fnref-bignote-12345" data-footnote-backref="" class="data-footnote-backref" aria-label="Back to content"><g-emoji class="g-emoji" alias="leftwards_arrow_with_hook" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/21a9.png">↩</g-emoji></a></p>
294+
</li>
295+
</ol>
296+
</section>
297+
279298
<pre><code>This is the final element on the page and there should be no margin below this.</code></pre>
280299
</div>
281300
```
@@ -447,6 +466,18 @@ Large images should always scale down and fit in the content container.
447466
448467
![](http://placekitten.com/g/1200/800/)
449468
469+
Here's a simple footnote,[^1] and here's a longer one.[^bignote]
470+
471+
[^1]: This is the first footnote.
472+
473+
[^bignote]: Here's one with multiple paragraphs and code.
474+
475+
Indent paragraphs to include them in the footnote.
476+
477+
`{ my code }`
478+
479+
Add as many paragraphs as you like.
480+
450481
```
451482
This is the final element on the page and there should be no margin below this.
452483
```

src/markdown/footnotes.scss

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// stylelint-disable selector-max-type
2+
// stylelint-disable selector-max-compound-selectors
3+
4+
.markdown-body .footnotes {
5+
font-size: $h6-size;
6+
color: var(--color-fg-muted);
7+
border-top: $border;
8+
9+
ol {
10+
padding-left: $spacer-3;
11+
}
12+
13+
li {
14+
position: relative;
15+
}
16+
17+
li:target::before {
18+
position: absolute;
19+
top: -$spacer-2;
20+
right: -$spacer-2;
21+
bottom: -$spacer-2;
22+
left: -$spacer-4;
23+
pointer-events: none;
24+
content: "";
25+
// stylelint-disable-next-line primer/borders
26+
border: 2px $border-style var(--color-accent-emphasis);
27+
border-radius: $border-radius;
28+
}
29+
30+
li:target {
31+
color: var(--color-fg-default);
32+
}
33+
34+
.data-footnote-backref g-emoji {
35+
font-family: monospace;
36+
}
37+
}

src/markdown/index.scss

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
@import "./images.scss";
77
@import "./code.scss";
88
@import "./blob-csv.scss";
9+
@import "./footnotes.scss";

src/markdown/markdown-body.scss

+8
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,12 @@
9393
margin-bottom: 0;
9494
}
9595
}
96+
97+
sup > a::before {
98+
content: "[";
99+
}
100+
101+
sup > a::after {
102+
content: "]";
103+
}
96104
}

0 commit comments

Comments
 (0)