Skip to content

Commit 6132993

Browse files
Rollup merge of rust-lang#106462 - notriddle:notriddle/logo-container-sidebar, r=GuillaumeGomez
rustdoc: remove unnecessary wrapper around sidebar and mobile logos This commit changes `.sidebar a:hover:not(.logo-container)` to add the `:not()` pseudo-class, retaining the old appearance of the logo when mousing over it. This didn't used to be necessary because the `a.sidebar-logo` was `display:inline`, and was what got the `background` changed on hover, while the `div.logo-container` inside it was `display:block`. This resulted in the hover rule not having any effect, because the logo-container box was not actually nested inside the sidebar-logo box: https://www.w3.org/TR/CSS2/visuren.html#anonymous-block-level > When an inline box contains an in-flow block-level box, the inline box (and its inline ancestors within the same line box) are broken around the block-level box (and any block-level siblings that are consecutive or separated only by collapsible whitespace and/or out-of-flow elements), splitting the inline box into two boxes (even if either side is empty), one on each side of the block-level box(es). The line boxes before the break and after the break are enclosed in anonymous block boxes, and the block-level box becomes a sibling of those anonymous boxes. When such an inline box is affected by relative positioning, any resulting translation also affects the block-level box contained in the inline box.
2 parents 5ce6311 + 01196c5 commit 6132993

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ img {
352352
.sub-logo-container, .logo-container {
353353
/* zero text boxes so that computed line height = image height exactly */
354354
line-height: 0;
355+
display: block;
355356
}
356357

357358
.sub-logo-container {
@@ -495,7 +496,7 @@ ul.block, .block li {
495496
color: var(--sidebar-link-color);
496497
}
497498
.sidebar .current,
498-
.sidebar a:hover {
499+
.sidebar a:hover:not(.logo-container) {
499500
background-color: var(--sidebar-current-link-background-color);
500501
}
501502

@@ -1570,7 +1571,7 @@ in storage.js
15701571

15711572
/* Hide the logo and item name from the sidebar. Those are displayed
15721573
in the mobile-topbar instead. */
1573-
.sidebar .sidebar-logo,
1574+
.sidebar .logo-container,
15741575
.sidebar .location {
15751576
display: none;
15761577
}

src/librustdoc/html/templates/page.html

+12-16
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,24 @@
7272
{%- if page.css_class != "source" -%}
7373
<nav class="mobile-topbar"> {#- -#}
7474
<button class="sidebar-menu-toggle">&#9776;</button> {#- -#}
75-
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
76-
<div class="logo-container"> {#- -#}
77-
{%- if !layout.logo.is_empty() -%}
78-
<img src="{{layout.logo}}" alt="logo"> {#- -#}
79-
{%- else -%}
80-
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#}
81-
{%- endif -%}
82-
</div> {#- -#}
75+
<a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
76+
{%- if !layout.logo.is_empty() -%}
77+
<img src="{{layout.logo}}" alt="logo"> {#- -#}
78+
{%- else -%}
79+
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#}
80+
{%- endif -%}
8381
</a> {#- -#}
8482
<h2></h2> {#- -#}
8583
</nav> {#- -#}
8684
{%- endif -%}
8785
<nav class="sidebar"> {#- -#}
8886
{%- if page.css_class != "source" -%}
89-
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
90-
<div class="logo-container"> {#- -#}
91-
{%- if !layout.logo.is_empty() %}
92-
<img src="{{layout.logo}}" alt="logo"> {#- -#}
93-
{%- else -%}
94-
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#}
95-
{%- endif -%}
96-
</div> {#- -#}
87+
<a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
88+
{%- if !layout.logo.is_empty() %}
89+
<img src="{{layout.logo}}" alt="logo"> {#- -#}
90+
{%- else -%}
91+
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#}
92+
{%- endif -%}
9793
</a> {#- -#}
9894
{%- endif -%}
9995
{{- sidebar|safe -}}

0 commit comments

Comments
 (0)