Skip to content

Commit 75a08cc

Browse files
committed
rustdoc: make sidebar highlight cover whole click target
1 parent 5fc30b8 commit 75a08cc

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

src/librustdoc/html/static/css/rustdoc.css

+41-2
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ ul.block, .block li {
564564
/* extend click target to far edge of screen (mile wide bar) */
565565
border-left: solid var(--sidebar-elems-left-padding) transparent;
566566
margin-left: calc(-0.25rem - var(--sidebar-elems-left-padding));
567-
background-clip: padding-box;
567+
background-clip: border-box;
568568
}
569569

570570
.sidebar h2 {
@@ -641,11 +641,50 @@ ul.block, .block li {
641641
text-align: center;
642642
}
643643

644+
.sidebar-crate .logo-container img {
645+
/* When in a horizontal logo lockup, the highlight color of the crate name menu item
646+
extends underneath the actual logo (in a vertical lockup, that background highlight
647+
extends to the left edge of the screen).
648+
649+
To prevent a weird-looking colored band from appearing under the logo, cover it up
650+
with the sidebar's background. Additionally, the crate name extends slightly above
651+
the logo, so that its highlight has a bit of space to let the ascenders breath while
652+
also having those ascenders meet exactly with the top of the logo.
653+
654+
In ANSI art, make it look like this:
655+
| ┌─────┐
656+
| (R) │ std │
657+
| └─────┘
658+
659+
Not like this (which would happen without the z-index):
660+
| ┌────────┐
661+
| (│ std │
662+
| └────────┘
663+
664+
Not like this (which would happen without the background):
665+
| ┌────────┐
666+
| (R) std │
667+
| └────────┘
668+
669+
Nor like this (which would happen without the negative margin):
670+
| ─────────┐
671+
| (R) │ std │
672+
| └─────┘
673+
*/
674+
margin-top: -16px;
675+
border-top: solid 16px transparent;
676+
box-sizing: content-box;
677+
position: relative;
678+
background-color: var(--sidebar-background-color);
679+
background-clip: border-box;
680+
z-index: 1;
681+
}
682+
644683
.sidebar-crate h2 a {
645684
display: block;
646685
/* extend click target to far edge of screen (mile wide bar) */
647686
border-left: solid var(--sidebar-elems-left-padding) transparent;
648-
background-clip: padding-box;
687+
background-clip: border-box;
649688
margin: 0 calc(-24px + 0.25rem) 0 calc(-0.2rem - var(--sidebar-elems-left-padding));
650689
/* Align the sidebar crate link with the search bar, which have different
651690
font sizes.

0 commit comments

Comments
 (0)