Skip to content

Commit bc45d19

Browse files
authored
Fix badges display & positioning (strapi#2740)
1 parent 4307bdb commit bc45d19

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

docusaurus/src/scss/badge.scss

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ h1 + .h1-badges-container {
259259
}
260260
}
261261

262-
h1
263262
/**
264263
* New/updated badges in main content gutter
265264
*/
@@ -294,11 +293,21 @@ main .badge--content {
294293
--custom-badge-tooltip-color: var(--strapi-alternative-600);
295294
}
296295
}
296+
297297
&:hover .badge__tooltip {
298298
visibility: visible;
299299
}
300300
}
301301

302+
main h2 + .badge--content:hover .badge__tooltip,
303+
main h3 + .badge--content:hover .badge__tooltip,
304+
main h4 + .badge--content:hover .badge__tooltip,
305+
main h5 + .badge--content:hover .badge__tooltip,
306+
main h6 + .badge--content:hover .badge__tooltip {
307+
visibility: hidden !important;
308+
display: none !important;
309+
}
310+
302311
main .badge--featureflag,
303312
main .badge--developer,
304313
main .badge--essential,
@@ -449,6 +458,15 @@ h2 .badge {
449458
}
450459
}
451460

461+
/* Reduce spacing after badges that follow headings */
462+
h2 + .badge:not(.badge--inline) ~ p,
463+
h3 + .badge:not(.badge--inline) ~ p,
464+
h4 + .badge:not(.badge--inline) ~ p,
465+
h5 + .badge:not(.badge--inline) ~ p,
466+
h6 + .badge:not(.badge--inline) ~ p {
467+
margin-top: 1rem;
468+
}
469+
452470
/**
453471
* On mobile, badges can not necessarily
454472
* be shown in the gutter, because there is not enough
@@ -777,4 +795,26 @@ main [role="tablist"] + .margin-top--md:has([role="tabpanel"] .badge) [role="tab
777795
// padding-right: 60px;
778796
}
779797
}
798+
}
799+
800+
/**
801+
* Force headings followed by badges to be block-level
802+
* so badges wrap to next line naturally
803+
*/
804+
h2:has(+ .badge:not(.badge--inline)),
805+
h3:has(+ .badge:not(.badge--inline)),
806+
h4:has(+ .badge:not(.badge--inline)),
807+
h5:has(+ .badge:not(.badge--inline)),
808+
h6:has(+ .badge:not(.badge--inline)) {
809+
display: block !important;
810+
margin-bottom: 0;
811+
}
812+
813+
/* Style the badges that follow headings */
814+
h2 + .badge:not(.badge--inline),
815+
h3 + .badge:not(.badge--inline),
816+
h4 + .badge:not(.badge--inline),
817+
h5 + .badge:not(.badge--inline),
818+
h6 + .badge:not(.badge--inline) {
819+
margin-top: 0.5rem;
780820
}

0 commit comments

Comments
 (0)