diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/mdbook/src/theme | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/mdbook/src/theme')
-rw-r--r-- | vendor/mdbook/src/theme/css/chrome.css | 19 | ||||
-rw-r--r-- | vendor/mdbook/src/theme/index.hbs | 6 | ||||
-rw-r--r-- | vendor/mdbook/src/theme/mod.rs | 36 |
3 files changed, 51 insertions, 10 deletions
diff --git a/vendor/mdbook/src/theme/css/chrome.css b/vendor/mdbook/src/theme/css/chrome.css index 59eae11fd..29992f7b6 100644 --- a/vendor/mdbook/src/theme/css/chrome.css +++ b/vendor/mdbook/src/theme/css/chrome.css @@ -2,12 +2,6 @@ @import 'variables.css'; -::-webkit-scrollbar { - background: var(--bg); -} -::-webkit-scrollbar-thumb { - background: var(--scrollbar); -} html { scrollbar-color: var(--scrollbar) var(--bg); } @@ -18,6 +12,19 @@ a > .hljs { color: var(--links); } +/* + body-container is necessary because mobile browsers don't seem to like + overflow-x on the body tag when there is a <meta name="viewport"> tag. +*/ +#body-container { + /* + This is used when the sidebar pushes the body content off the side of + the screen on small screens. Without it, dragging on mobile Safari + will want to reposition the viewport in a weird way. + */ + overflow-x: clip; +} + /* Menu Bar */ #menu-bar, diff --git a/vendor/mdbook/src/theme/index.hbs b/vendor/mdbook/src/theme/index.hbs index 147eb9af2..6f3948c65 100644 --- a/vendor/mdbook/src/theme/index.hbs +++ b/vendor/mdbook/src/theme/index.hbs @@ -54,6 +54,7 @@ {{/if}} </head> <body> + <div id="body-container"> <!-- Provide site root to javascript --> <script> var path_to_root = "{{ path_to_root }}"; @@ -91,10 +92,12 @@ <!-- Hide / unhide sidebar before it is displayed --> <script> var html = document.querySelector('html'); - var sidebar = 'hidden'; + var sidebar = null; if (document.body.clientWidth >= 1080) { try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } sidebar = sidebar || 'visible'; + } else { + sidebar = 'hidden'; } html.classList.remove('sidebar-visible'); html.classList.add("sidebar-" + sidebar); @@ -309,5 +312,6 @@ {{/if}} {{/if}} + </div> </body> </html> diff --git a/vendor/mdbook/src/theme/mod.rs b/vendor/mdbook/src/theme/mod.rs index 7af5e2b70..6e6b509d1 100644 --- a/vendor/mdbook/src/theme/mod.rs +++ b/vendor/mdbook/src/theme/mod.rs @@ -9,7 +9,7 @@ pub mod searcher; use std::fs::File; use std::io::Read; -use std::path::Path; +use std::path::{Path, PathBuf}; use crate::errors::*; use log::warn; @@ -54,6 +54,8 @@ pub struct Theme { pub general_css: Vec<u8>, pub print_css: Vec<u8>, pub variables_css: Vec<u8>, + pub fonts_css: Option<Vec<u8>>, + pub font_files: Vec<PathBuf>, pub favicon_png: Option<Vec<u8>>, pub favicon_svg: Option<Vec<u8>>, pub js: Vec<u8>, @@ -104,7 +106,7 @@ impl Theme { ), ]; - let load_with_warn = |filename: &Path, dest| { + let load_with_warn = |filename: &Path, dest: &mut Vec<u8>| { if !filename.exists() { // Don't warn if the file doesn't exist. return false; @@ -121,6 +123,29 @@ impl Theme { load_with_warn(&filename, dest); } + let fonts_dir = theme_dir.join("fonts"); + if fonts_dir.exists() { + let mut fonts_css = Vec::new(); + if load_with_warn(&fonts_dir.join("fonts.css"), &mut fonts_css) { + theme.fonts_css.replace(fonts_css); + } + if let Ok(entries) = fonts_dir.read_dir() { + theme.font_files = entries + .filter_map(|entry| { + let entry = entry.ok()?; + if entry.file_name() == "fonts.css" { + None + } else if entry.file_type().ok()?.is_dir() { + log::info!("skipping font directory {:?}", entry.path()); + None + } else { + Some(entry.path()) + } + }) + .collect(); + } + } + // If the user overrides one favicon, but not the other, do not // copy the default for the other. let favicon_png = &mut theme.favicon_png.as_mut().unwrap(); @@ -153,6 +178,8 @@ impl Default for Theme { general_css: GENERAL_CSS.to_owned(), print_css: PRINT_CSS.to_owned(), variables_css: VARIABLES_CSS.to_owned(), + fonts_css: None, + font_files: Vec::new(), favicon_png: Some(FAVICON_PNG.to_owned()), favicon_svg: Some(FAVICON_SVG.to_owned()), js: JS.to_owned(), @@ -209,10 +236,10 @@ mod tests { "favicon.png", "favicon.svg", "css/chrome.css", - "css/fonts.css", "css/general.css", "css/print.css", "css/variables.css", + "fonts/fonts.css", "book.js", "highlight.js", "tomorrow-night.css", @@ -223,6 +250,7 @@ mod tests { let temp = TempFileBuilder::new().prefix("mdbook-").tempdir().unwrap(); fs::create_dir(temp.path().join("css")).unwrap(); + fs::create_dir(temp.path().join("fonts")).unwrap(); // "touch" all of the special files so we have empty copies for file in &files { @@ -240,6 +268,8 @@ mod tests { general_css: Vec::new(), print_css: Vec::new(), variables_css: Vec::new(), + fonts_css: Some(Vec::new()), + font_files: Vec::new(), favicon_png: Some(Vec::new()), favicon_svg: Some(Vec::new()), js: Vec::new(), |