diff options
| author | Jacob Hoffman-Andrews <github@hoffman-andrews.com> | 2022-01-05 22:20:26 -0500 |
|---|---|---|
| committer | Jacob Hoffman-Andrews <github@hoffman-andrews.com> | 2022-01-14 18:20:15 -0800 |
| commit | c4b994ff80a993fb144d8ce2af6f2caf34b30347 (patch) | |
| tree | 16bedc1662f5605c7d1b6d9da7004374d73d4717 | |
| parent | ad46af24713115e7b9b258346e66b9b2d14eacfc (diff) | |
| download | rust-c4b994ff80a993fb144d8ce2af6f2caf34b30347.tar.gz rust-c4b994ff80a993fb144d8ce2af6f2caf34b30347.zip | |
Pick themes on settings page, not every page
This hides the paintbrush icon on most pages by default, in preference for the settings on the settings page. When loading from a local file, and not in mobile view, continue to show the theme picker. That's because some browsers limit access to localStorage from file:/// URLs, so choosing a theme from settings.html doesn't take effect.
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 17 | ||||
| -rw-r--r-- | src/librustdoc/html/static/js/main.js | 5 | ||||
| -rw-r--r-- | src/librustdoc/templates/page.html | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index d7f33d6131c..b8dd177e2d9 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1755,6 +1755,12 @@ details.rustdoc-toggle[open] > summary.hideme::after { padding-top: 0px; } + /* Space is at a premium on mobile, so remove the theme-picker icon. */ + #theme-picker { + display: none; + width: 0; + } + .rustdoc { flex-direction: column; } @@ -1873,12 +1879,6 @@ details.rustdoc-toggle[open] > summary.hideme::after { height: 100%; } - nav.sub { - width: calc(100% - 32px); - margin-left: 32px; - margin-bottom: 10px; - } - .source nav:not(.sidebar).sub { margin-left: 32px; } @@ -2075,11 +2075,6 @@ details.rustdoc-toggle[open] > summary.hideme::after { border: 0; } - #crate-search + .search-input { - width: calc(100% + 71px); - margin-left: -36px; - } - #theme-picker, #settings-menu { padding: 5px; width: 31px; diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index f41c1bd817a..011e60b8fa0 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -129,10 +129,15 @@ function hideThemeButtonState() { // Set up the theme picker list. (function () { + if (!document.location.href.startsWith("file:///")) { + return; + } var themeChoices = getThemesElement(); var themePicker = getThemePickerElement(); var availableThemes = getVar("themes").split(","); + removeClass(themeChoices.parentElement, "hidden"); + function switchThemeButtonState() { if (themeChoices.style.display === "block") { hideThemeButtonState(); diff --git a/src/librustdoc/templates/page.html b/src/librustdoc/templates/page.html index 02808754b53..1ef001ec2b7 100644 --- a/src/librustdoc/templates/page.html +++ b/src/librustdoc/templates/page.html @@ -96,7 +96,7 @@ {%- endif -%} </a> {#- -#} <nav class="sub"> {#- -#} - <div class="theme-picker"> {#- -#} + <div class="theme-picker hidden"> {#- -#} <button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"> {#- -#} <img width="18" height="18" alt="Pick another theme!" {# -#} src="{{static_root_path|safe}}brush{{page.resource_suffix}}.svg"> {#- -#} |
