Auto merge of #103165 - matthiaskrgr:rollup-guw8oh6, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #103152 (Use named arguments to make GUI test more clear) - #103160 (rustdoc: factor JS mobile scroll lock into its own function) - #103161 (rustdoc: remove redundant CSS on `#copy-path`) - #103162 (rustdoc: remove redundant CSS `#crate-search { border-radius }`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
194140bef5
5 changed files with 64 additions and 85 deletions
|
@ -1 +1 @@
|
||||||
0.12.5
|
0.12.6
|
|
@ -1431,10 +1431,7 @@ h3.variant {
|
||||||
}
|
}
|
||||||
|
|
||||||
#settings-menu > a, #help-button > a, #copy-path {
|
#settings-menu > a, #help-button > a, #copy-path {
|
||||||
padding: 5px;
|
|
||||||
width: 33px;
|
width: 33px;
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 2px;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
@ -1444,10 +1441,18 @@ h3.variant {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: block;
|
display: block;
|
||||||
background-color: var(--button-background-color);
|
background-color: var(--button-background-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#copy-path {
|
#copy-path {
|
||||||
color: var(--copy-path-button-color);
|
color: var(--copy-path-button-color);
|
||||||
|
background: var(--main-background-color);
|
||||||
|
height: 34px;
|
||||||
|
margin-left: 10px;
|
||||||
|
padding: 0;
|
||||||
|
padding-left: 2px;
|
||||||
|
border: 0;
|
||||||
}
|
}
|
||||||
#copy-path > img {
|
#copy-path > img {
|
||||||
filter: var(--copy-path-img-filter);
|
filter: var(--copy-path-img-filter);
|
||||||
|
@ -1495,15 +1500,6 @@ input:checked + .slider {
|
||||||
padding-top: 2px;
|
padding-top: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#copy-path {
|
|
||||||
height: 34px;
|
|
||||||
background-color: var(--main-background-color);
|
|
||||||
margin-left: 10px;
|
|
||||||
padding: 0;
|
|
||||||
padding-left: 2px;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
kbd {
|
kbd {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 3px 5px;
|
padding: 3px 5px;
|
||||||
|
@ -1994,10 +1990,6 @@ in storage.js plus the media query with (min-width: 701px)
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 464px) {
|
@media (max-width: 464px) {
|
||||||
#crate-search {
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.docblock {
|
.docblock {
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -733,37 +733,51 @@ function loadCss(cssFileName) {
|
||||||
|
|
||||||
let oldSidebarScrollPosition = null;
|
let oldSidebarScrollPosition = null;
|
||||||
|
|
||||||
function showSidebar() {
|
// Scroll locking used both here and in source-script.js
|
||||||
|
|
||||||
|
window.rustdocMobileScrollLock = function() {
|
||||||
const mobile_topbar = document.querySelector(".mobile-topbar");
|
const mobile_topbar = document.querySelector(".mobile-topbar");
|
||||||
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT && mobile_topbar) {
|
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
|
||||||
// This is to keep the scroll position on mobile.
|
// This is to keep the scroll position on mobile.
|
||||||
oldSidebarScrollPosition = window.scrollY;
|
oldSidebarScrollPosition = window.scrollY;
|
||||||
document.body.style.width = `${document.body.offsetWidth}px`;
|
document.body.style.width = `${document.body.offsetWidth}px`;
|
||||||
document.body.style.position = "fixed";
|
document.body.style.position = "fixed";
|
||||||
document.body.style.top = `-${oldSidebarScrollPosition}px`;
|
document.body.style.top = `-${oldSidebarScrollPosition}px`;
|
||||||
mobile_topbar.style.top = `${oldSidebarScrollPosition}px`;
|
if (mobile_topbar) {
|
||||||
mobile_topbar.style.position = "relative";
|
mobile_topbar.style.top = `${oldSidebarScrollPosition}px`;
|
||||||
|
mobile_topbar.style.position = "relative";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
oldSidebarScrollPosition = null;
|
oldSidebarScrollPosition = null;
|
||||||
}
|
}
|
||||||
const sidebar = document.getElementsByClassName("sidebar")[0];
|
};
|
||||||
addClass(sidebar, "shown");
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideSidebar() {
|
window.rustdocMobileScrollUnlock = function() {
|
||||||
const mobile_topbar = document.querySelector(".mobile-topbar");
|
const mobile_topbar = document.querySelector(".mobile-topbar");
|
||||||
if (oldSidebarScrollPosition !== null && mobile_topbar) {
|
if (oldSidebarScrollPosition !== null) {
|
||||||
// This is to keep the scroll position on mobile.
|
// This is to keep the scroll position on mobile.
|
||||||
document.body.style.width = "";
|
document.body.style.width = "";
|
||||||
document.body.style.position = "";
|
document.body.style.position = "";
|
||||||
document.body.style.top = "";
|
document.body.style.top = "";
|
||||||
mobile_topbar.style.top = "";
|
if (mobile_topbar) {
|
||||||
mobile_topbar.style.position = "";
|
mobile_topbar.style.top = "";
|
||||||
|
mobile_topbar.style.position = "";
|
||||||
|
}
|
||||||
// The scroll position is lost when resetting the style, hence why we store it in
|
// The scroll position is lost when resetting the style, hence why we store it in
|
||||||
// `oldSidebarScrollPosition`.
|
// `oldSidebarScrollPosition`.
|
||||||
window.scrollTo(0, oldSidebarScrollPosition);
|
window.scrollTo(0, oldSidebarScrollPosition);
|
||||||
oldSidebarScrollPosition = null;
|
oldSidebarScrollPosition = null;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function showSidebar() {
|
||||||
|
window.rustdocMobileScrollLock();
|
||||||
|
const sidebar = document.getElementsByClassName("sidebar")[0];
|
||||||
|
addClass(sidebar, "shown");
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideSidebar() {
|
||||||
|
window.rustdocMobileScrollUnlock();
|
||||||
const sidebar = document.getElementsByClassName("sidebar")[0];
|
const sidebar = document.getElementsByClassName("sidebar")[0];
|
||||||
removeClass(sidebar, "shown");
|
removeClass(sidebar, "shown");
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-path"].value;
|
const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-path"].value;
|
||||||
let oldScrollPosition = null;
|
|
||||||
|
|
||||||
const NAME_OFFSET = 0;
|
const NAME_OFFSET = 0;
|
||||||
const DIRS_OFFSET = 1;
|
const DIRS_OFFSET = 1;
|
||||||
|
@ -70,44 +69,18 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
|
||||||
function toggleSidebar() {
|
function toggleSidebar() {
|
||||||
const child = this.parentNode.children[0];
|
const child = this.parentNode.children[0];
|
||||||
if (child.innerText === ">") {
|
if (child.innerText === ">") {
|
||||||
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
|
window.rustdocMobileScrollLock();
|
||||||
// This is to keep the scroll position on mobile.
|
|
||||||
oldScrollPosition = window.scrollY;
|
|
||||||
document.body.style.position = "fixed";
|
|
||||||
document.body.style.top = `-${oldScrollPosition}px`;
|
|
||||||
} else {
|
|
||||||
oldScrollPosition = null;
|
|
||||||
}
|
|
||||||
addClass(document.documentElement, "source-sidebar-expanded");
|
addClass(document.documentElement, "source-sidebar-expanded");
|
||||||
child.innerText = "<";
|
child.innerText = "<";
|
||||||
updateLocalStorage("source-sidebar-show", "true");
|
updateLocalStorage("source-sidebar-show", "true");
|
||||||
} else {
|
} else {
|
||||||
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT && oldScrollPosition !== null) {
|
window.rustdocMobileScrollUnlock();
|
||||||
// This is to keep the scroll position on mobile.
|
|
||||||
document.body.style.position = "";
|
|
||||||
document.body.style.top = "";
|
|
||||||
// The scroll position is lost when resetting the style, hence why we store it in
|
|
||||||
// `oldScrollPosition`.
|
|
||||||
window.scrollTo(0, oldScrollPosition);
|
|
||||||
oldScrollPosition = null;
|
|
||||||
}
|
|
||||||
removeClass(document.documentElement, "source-sidebar-expanded");
|
removeClass(document.documentElement, "source-sidebar-expanded");
|
||||||
child.innerText = ">";
|
child.innerText = ">";
|
||||||
updateLocalStorage("source-sidebar-show", "false");
|
updateLocalStorage("source-sidebar-show", "false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
if (window.innerWidth >= window.RUSTDOC_MOBILE_BREAKPOINT && oldScrollPosition !== null) {
|
|
||||||
// If the user opens the sidebar in "mobile" mode, and then grows the browser window,
|
|
||||||
// we need to switch away from mobile mode and make the main content area scrollable.
|
|
||||||
document.body.style.position = "";
|
|
||||||
document.body.style.top = "";
|
|
||||||
window.scrollTo(0, oldScrollPosition);
|
|
||||||
oldScrollPosition = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function createSidebarToggle() {
|
function createSidebarToggle() {
|
||||||
const sidebarToggle = document.createElement("div");
|
const sidebarToggle = document.createElement("div");
|
||||||
sidebarToggle.id = "sidebar-toggle";
|
sidebarToggle.id = "sidebar-toggle";
|
||||||
|
@ -125,7 +98,7 @@ function createSidebarToggle() {
|
||||||
return sidebarToggle;
|
return sidebarToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is called from "source-files.js", generated in `html/render/mod.rs`.
|
// This function is called from "source-files.js", generated in `html/render/write_shared.rs`.
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
function createSourceSidebar() {
|
function createSourceSidebar() {
|
||||||
const container = document.querySelector("nav.sidebar");
|
const container = document.querySelector("nav.sidebar");
|
||||||
|
|
|
@ -71,37 +71,37 @@ define-function: (
|
||||||
|
|
||||||
call-function: (
|
call-function: (
|
||||||
"check-colors",
|
"check-colors",
|
||||||
(
|
{
|
||||||
"ayu", // theme
|
"theme": "ayu",
|
||||||
"rgb(197, 197, 197)", // main color
|
"main_color": "rgb(197, 197, 197)",
|
||||||
"rgb(255, 255, 255)", // title color
|
"title_color": "rgb(255, 255, 255)",
|
||||||
"rgb(255, 255, 255)", // fqn color
|
"fqn_color": "rgb(255, 255, 255)",
|
||||||
"rgb(255, 160, 165)", // fqn type color
|
"fqn_type_color": "rgb(255, 160, 165)",
|
||||||
"rgb(57, 175, 215)", // src link
|
"src_link_color": "rgb(57, 175, 215)",
|
||||||
"rgb(83, 177, 219)", // sidebar link
|
"sidebar_link_color": "rgb(83, 177, 219)",
|
||||||
),
|
},
|
||||||
)
|
)
|
||||||
call-function: (
|
call-function: (
|
||||||
"check-colors",
|
"check-colors",
|
||||||
(
|
{
|
||||||
"dark", // theme
|
"theme": "dark",
|
||||||
"rgb(221, 221, 221)", // main color
|
"main_color": "rgb(221, 221, 221)",
|
||||||
"rgb(221, 221, 221)", // title color
|
"title_color": "rgb(221, 221, 221)",
|
||||||
"rgb(221, 221, 221)", // fqn color
|
"fqn_color": "rgb(221, 221, 221)",
|
||||||
"rgb(45, 191, 184)", // fqn type color
|
"fqn_type_color": "rgb(45, 191, 184)",
|
||||||
"rgb(210, 153, 29)", // src link
|
"src_link_color": "rgb(210, 153, 29)",
|
||||||
"rgb(253, 191, 53)", // sidebar link
|
"sidebar_link_color": "rgb(253, 191, 53)",
|
||||||
),
|
},
|
||||||
)
|
)
|
||||||
call-function: (
|
call-function: (
|
||||||
"check-colors",
|
"check-colors",
|
||||||
(
|
{
|
||||||
"light", // theme
|
"theme": "light",
|
||||||
"rgb(0, 0, 0)", // main color
|
"main_color": "rgb(0, 0, 0)",
|
||||||
"rgb(0, 0, 0)", // title color
|
"title_color": "rgb(0, 0, 0)",
|
||||||
"rgb(0, 0, 0)", // fqn color
|
"fqn_color": "rgb(0, 0, 0)",
|
||||||
"rgb(173, 55, 138)", // fqn type color
|
"fqn_type_color": "rgb(173, 55, 138)",
|
||||||
"rgb(56, 115, 173)", // src link
|
"src_link_color": "rgb(56, 115, 173)",
|
||||||
"rgb(53, 109, 164)", // sidebar link
|
"sidebar_link_color": "rgb(53, 109, 164)",
|
||||||
),
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue