Skip to content

Commit f957ddc

Browse files
authored
Bad spacing after tool switcher (Universe issue) (github#32330)
1 parent 26ffdea commit f957ddc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

stylesheets/index.scss

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@import "@primer/css/alerts/index.scss";
99

1010
@import "extended-markdown.scss";
11+
@import "markdown-overrides.scss";
1112
@import "headings.scss";
1213
@import "images.scss";
1314
@import "shadows.scss";

stylesheets/markdown-overrides.scss

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// What might happens is that we have a DOM of
2+
//
3+
// <div class="markdown-body">
4+
// <div style="display: none">Note</div>
5+
// <h2>Heading</h2>
6+
// ...
7+
//
8+
// When this is the case, by default, that first <div> that is the first
9+
// gets the `margin-top: 0 !important` and not the first <h2>.
10+
// Generally, the reason this even exists is because <h2> (and <h3>) elements
11+
// are given extra margin-top so as to divide the article into sections
12+
// with some extra whitespace. That's fine, but we don't to start the
13+
// top of the page with too much whitespace. That's why @primer/css
14+
// has a solution for that. Just the problem that it fails then first
15+
// element isn't actually a heading.
16+
// Note we're also doing it for a possible <h3> being the first element.
17+
// See https://github.com/primer/css/issues/2303
18+
// See internal issue #2368
19+
.markdown-body {
20+
> h2:first-of-type,
21+
> h3:first-of-type {
22+
margin-top: 0 !important;
23+
}
24+
}

0 commit comments

Comments
 (0)