Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6812adb

Browse files
committedDec 8, 2024·
Fix test cases and hide-sidebar mode
1 parent a02218b commit 6812adb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+262
-217
lines changed
 

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,15 +1867,19 @@ a.tooltip:hover::after {
18671867
display: flex;
18681868
margin-right: 4px;
18691869
position: fixed;
1870+
margin-top: 25px;
18701871
left: 6px;
18711872
height: 34px;
18721873
width: 34px;
18731874
background-color: var(--main-background-color);
18741875
z-index: 1;
18751876
}
18761877
.src #sidebar-button {
1878+
margin-top: 0;
1879+
top: 8px;
18771880
left: 8px;
18781881
z-index: calc(var(--desktop-sidebar-z-index) + 1);
1882+
border-color: var(--border-color);
18791883
}
18801884
.hide-sidebar .src #sidebar-button {
18811885
position: static;
@@ -1902,14 +1906,14 @@ button#toggle-all-docs {
19021906
}
19031907
#sidebar-button > a {
19041908
background-color: var(--button-background-color);
1905-
border-color: var(--border-color);
19061909
width: 33px;
19071910
}
19081911

19091912
#search-button > a:hover, #search-button > a:focus-visible,
19101913
.settings-menu > a:hover, .settings-menu > a:focus-visible,
19111914
.help-menu > a:hover, #help-menu > a:focus-visible,
19121915
#sidebar-button > a:hover, #sidebar-button > a:focus-visible,
1916+
#copy-path:hover, #copy-path:focus-visible,
19131917
button#toggle-all-docs:hover, button#toggle-all-docs:focus-visible {
19141918
border-color: var(--settings-button-border-focus);
19151919
text-decoration: none;
@@ -2023,7 +2027,8 @@ rustdoc-toolbar span.label {
20232027
margin-left: 10px;
20242028
padding: 0;
20252029
padding-left: 2px;
2026-
border: 0;
2030+
border: solid 1px transparent;
2031+
border-radius: var(--button-border-radius);
20272032
font-size: 0;
20282033
}
20292034
#copy-path::before {
@@ -2549,6 +2554,9 @@ in src-script.js and main.js
25492554
}
25502555

25512556
/* sidebar button becomes topbar button */
2557+
.hide-sidebar #sidebar-button {
2558+
margin-top: 0;
2559+
}
25522560
#sidebar-button > a:before {
25532561
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \
25542562
viewBox="0 0 22 22" fill="none" stroke="black">\

‎src/librustdoc/html/static/js/main.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,9 @@ function preLoadCss(cssUrl) {
220220
const out = searchState.outputElement().parentElement;
221221
const hdr = document.createElement("div");
222222
hdr.className = "main-heading search-results-main-heading";
223-
const rootPath = getVar("root-path");
224-
const currentCrate = getVar("current-crate");
225223
hdr.innerHTML = `<nav class="sub">
226224
<form class="search-form">
227225
<span></span> <!-- This empty span is a hacky fix for Safari: see #93184 -->
228-
<div id="sidebar-button" tabindex="-1">
229-
<a href="${rootPath}${currentCrate}/all.html" title="show sidebar"></a>
230-
</div>
231226
<input
232227
class="search-input"
233228
name="search"
@@ -1599,7 +1594,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
15991594
// On larger, "desktop-sized" viewports (though that includes many
16001595
// tablets), it's fixed-position, appears in the left side margin,
16011596
// and it can be activated by resizing the sidebar into nothing.
1602-
const sidebarButton = document.getElementById("sidebar-button");
1597+
let sidebarButton = document.getElementById("sidebar-button");
1598+
if (!sidebarButton) {
1599+
sidebarButton = document.createElement("div");
1600+
sidebarButton.id = "sidebar-button";
1601+
const path = `${window.rootPath}${window.currentCrate}/all.html`;
1602+
sidebarButton.innerHTML = `<a href="${path}" title="show sidebar"></a>`;
1603+
const body = document.querySelector(".main-heading");
1604+
body.insertBefore(sidebarButton, body.firstChild);
1605+
}
16031606
if (sidebarButton) {
16041607
sidebarButton.addEventListener("click", e => {
16051608
removeClass(document.documentElement, "hide-sidebar");

0 commit comments

Comments
 (0)
Please sign in to comment.