3 files changed, +166, -61
dadbf01Move the phone header's styles into style.css
+4, -39
@@ -33,20 +33,11 @@ const MARKDOWN_BOX: &str = "box markdown-body";
33 33
34 34 pub const ARCHIVE_FORMATS: [&str; 2] = ["zip", "tar.gz"];
35 35
36 -const REPO_FILES: [(&str, &str, f32, [&str; 2]); 2] = [
37 - ("README", "book", 3.717, README_NAMES),
38 - ("LICENSE", "law", 3.874, ["LICENSE", "COPYING"]),
36+const REPO_FILES: [(&str, &str, [&str; 2]); 2] = [
37+ ("README", "book", README_NAMES),
38+ ("LICENSE", "law", ["LICENSE", "COPYING"]),
39 39 ];
40 40
41 -const NAV_CSS: &str = include_str!("nav.css");
42 -const TAB_GAP: f32 = 1.1;
43 -const COUNT_GAP: f32 = 0.2;
44 -const DIGIT_WIDTH: f32 = 0.4875;
45 -const DOC_ICON: f32 = 1.0;
46 -const DOC_GAP: f32 = 1.0;
47 -const PAGE_MARGINS: f32 = 2.0;
48 -const SCROLLBAR: f32 = 1.0;
49 -
50 41 const IMAGE_TYPES: [(&str, &str); 6] = [
51 42 ("png", "image/png"),
52 43 ("jpg", "image/jpeg"),
@@ -128,17 +119,6 @@ impl Tab {
128119 }
129120 }
130121
131 - fn width(self) -> f32 {
132 - match self {
133 - Tab::Summary => 7.752,
134 - Tab::Tree => 3.657,
135 - Tab::Commits => 7.227,
136 - Tab::Branches => 7.682,
137 - Tab::Tags => 3.849,
138 - Tab::Releases => 7.348,
139 - }
140 - }
141 -
142122 fn main_class(self) -> &'static str {
143123 match self {
144124 Tab::Summary => "",
@@ -261,7 +241,6 @@ struct DocLink {
261241 href: String,
262242 label: &'static str,
263243 icon: &'static str,
264 - width: f32,
265244 }
266245
267246 fn doc_links(nav: &RepoNav, repo_root: &str) -> Vec<DocLink> {
@@ -273,7 +252,7 @@ fn doc_links(nav: &RepoNav, repo_root: &str) -> Vec<DocLink> {
273252 };
274253 REPO_FILES
275254 .iter()
276 - .filter_map(|&(label, icon, width, names)| {
255+ .filter_map(|&(label, icon, names)| {
277256 let path = follow_links(git_ref, &repo_file(root, &names)?.name)?;
278257 let href = path_href(git_ref, repo_root, &path)?;
279258 Some(DocLink {
@@ -285,7 +264,6 @@ fn doc_links(nav: &RepoNav, repo_root: &str) -> Vec<DocLink> {
285264 href: escape_str(&href),
286265 label,
287266 icon,
288 - width,
289267 })
290268 })
291269 .collect()
@@ -372,7 +350,6 @@ fn wrap_page(title: &str, nav: Option<&RepoNav>, body: &str) -> String {
372350 None => (String::new(), title.to_string()),
373351 };
374352 let mut header = String::from("<header class=\"topbar\">\n<div id=\"header\">\n");
375 - let mut menu_style = String::new();
376353 let (main_class, footer) = match nav {
377354 Some(nav) => {
378355 let repo_root = "../".repeat(nav.depth);
@@ -389,7 +366,6 @@ fn wrap_page(title: &str, nav: Option<&RepoNav>, body: &str) -> String {
389366 let on_file = docs.iter().any(|doc| !doc.current.is_empty());
390367 let mut tabs = String::new();
391368 let mut items = String::new();
392 - let mut width = -TAB_GAP;
393369 for tab in repo_tabs(nav.repo) {
394370 let current = match (tab == nav.tab, on_file) {
395371 (false, _) => "",
@@ -409,13 +385,11 @@ fn wrap_page(title: &str, nav: Option<&RepoNav>, body: &str) -> String {
409385 "<a class=\"tab\"{current} href=\"{href}\"><span class=\"tab-label\" data-label=\"{label}\">{label}</span>"
410386 ));
411387 items.push_str(&format!("<a href=\"{href}\"{current}><span>{label}</span>"));
412 - width += TAB_GAP + tab.width();
413388 if let Some(count) = count {
414389 tabs.push_str(&format!(
415390 "<span class=\"tab-count\"><span class=\"vh\">, </span>{count}</span>"
416391 ));
417392 items.push_str(&format!("<span>{count}</span>"));
418 - width += COUNT_GAP + DIGIT_WIDTH * count.to_string().len() as f32;
419393 }
420394 tabs.push_str("</a>\n");
421395 items.push_str("</a>\n");
@@ -453,7 +427,6 @@ fn wrap_page(title: &str, nav: Option<&RepoNav>, body: &str) -> String {
453427 ));
454428 if !docs.is_empty() {
455429 header.push_str("<nav class=\"repo-docs\" aria-label=\"documents\">\n");
456 - width -= DOC_GAP;
457430 for doc in &docs {
458431 let DocLink {
459432 current,
@@ -465,11 +438,9 @@ fn wrap_page(title: &str, nav: Option<&RepoNav>, body: &str) -> String {
465438 "<a class=\"doc-link\"{current} href=\"{href}\">{}{label}</a>\n",
466439 icon(doc.icon)
467440 ));
468 - width += DOC_GAP + DOC_ICON + doc.width;
469441 }
470442 header.push_str("</nav>\n");
471443 }
472 - menu_style = nav_style(width);
473444 (
474445 nav.tab.main_class(),
475446 "<footer class=\"site-footer\">powered by <a href=\"https://git.paramogi.world/wit/\">wit</a></footer>\n",
@@ -498,7 +469,6 @@ fn wrap_page(title: &str, nav: Option<&RepoNav>, body: &str) -> String {
498469 <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\
499470 <title>{}</title>\n\
500471 <link rel=\"stylesheet\" href=\"{root}style.css\">\n\
501 -{menu_style}\
502472 <link rel=\"icon\" href=\"{root}favicon.ico\">\n\
503473 </head>\n\
504474 <body>\n\
@@ -515,11 +485,6 @@ fn wrap_page(title: &str, nav: Option<&RepoNav>, body: &str) -> String {
515485 )
516486 }
517487
518 -fn nav_style(width: f32) -> String {
519 - let below = ((width + PAGE_MARGINS + SCROLLBAR) * 100.0).ceil() / 100.0;
520 - format!("<style media=\"(width < {below}rem)\">\n{NAV_CSS}</style>\n")
521 -}
522 -
523488 fn description(repo: &RepoInfo) -> (&'static str, String) {
524489 if repo.description.is_empty() {
525490 (" empty", NO_DESCRIPTION.to_string())
+0, -22
@@ -1,22 +0,0 @@
1 -.topbar:has(> .repo-tabs) { padding-top: 1rem; margin-bottom: 1rem; }
2 -.topbar:has(> .repo-tabs) > :is(.repo-tabs, .repo-docs) { display: none; }
3 -.topbar #header { flex-wrap: nowrap; align-items: center; height: 2.1rem; }
4 -.topbar #site_path { flex: 0 1 auto; min-width: 0; align-items: center; }
5 -.topbar #site_path > a { display: flex; }
6 -.topbar:has(> .repo-tabs) :is(#site_path, a.brand) { font-size: var(--text-base); }
7 -.topbar:has(> .repo-tabs) #site_path::before, .topbar:has(> .repo-tabs) .nav-only { content: "/"; display: block; flex-shrink: 0; margin: 0 0.25rem; font-family: var(--font-ui); font-size: var(--text-base); font-weight: 300; font-style: normal; font-variation-settings: "MONO" 0; letter-spacing: 0; line-height: 1.5; color: var(--muted); }
8 -.nav-btn { display: flex; flex-shrink: 0; align-items: center; box-sizing: border-box; height: 2.1rem; gap: 0.25rem; padding: 0 0.35rem; font: inherit; font-size: var(--text-base); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
9 -.nav-menu.ref-menu-list { min-width: 13rem; position-area: bottom span-left; }
10 -.nav-menu.ref-menu-list a { display: flex; gap: 1.5rem; }
11 -.nav-menu a > span:last-child:not(:first-child) { margin-left: auto; font-family: var(--font-mono); font-variation-settings: "MONO" 1; color: var(--muted); }
12 -.nav-icons { display: flex; flex: 1 1 0; justify-content: flex-end; column-gap: 0.45rem; min-width: 2.2rem; padding-left: 0.65rem; container-type: inline-size; }
13 -.nav-icons.docs-2 { min-width: 4.15rem; }
14 -.nav-icons a { display: flex; flex: none; align-items: center; box-sizing: border-box; height: 2.1rem; gap: 0.25rem; padding: 0 0.1rem; font-size: var(--text-sm); line-height: 1.25rem; --link: var(--muted); }
15 -.nav-icons a > svg { flex-shrink: 0; }
16 -@container (width < 5.15rem) { .docs-1 span { display: none; } .docs-1 svg { width: 21px; height: 21px; } }
17 -@container (width < 10.45rem) { .docs-2 span { display: none; } .docs-2 svg { width: 21px; height: 21px; } }
18 -.nav-icons a[aria-current] { --link: var(--fg); font-weight: 600; }
19 -.nav-icons a[aria-current] > svg { color: var(--fg); }
20 -.sticky, .view-switch, .action-code .view-switch { position: relative; top: 0; }
21 -.log-date { position: static; }
22 -.sticky, .action-code .ref-bar, .view-switch, .view-switch > :first-child, .view-switch > :last-child { animation: none; }
+162, -0
@@ -2457,3 +2457,165 @@ mtr > mtd:last-child {
24572457 margin-bottom: 0.15ex;
24582458 }
24592459 }
2460+
2461+@media only screen and (width < 60em) {
2462+ .topbar:has(> .repo-tabs) {
2463+ padding-top: 1rem;
2464+ margin-bottom: 1rem;
2465+ }
2466+
2467+ .topbar:has(> .repo-tabs) > :is(.repo-tabs, .repo-docs) {
2468+ display: none;
2469+ }
2470+
2471+ .topbar:has(> .repo-tabs) #header {
2472+ flex-wrap: nowrap;
2473+ align-items: center;
2474+ height: 2.1rem;
2475+ }
2476+
2477+ .topbar #site_path {
2478+ flex: 0 1 auto;
2479+ min-width: 0;
2480+ align-items: center;
2481+ }
2482+
2483+ .topbar #site_path > a {
2484+ display: flex;
2485+ }
2486+
2487+ .topbar:has(> .repo-tabs) :is(#site_path, a.brand) {
2488+ font-size: var(--text-base);
2489+ }
2490+
2491+ .topbar:has(> .repo-tabs) #site_path::before,
2492+ .topbar:has(> .repo-tabs) .nav-only {
2493+ content: "/";
2494+ display: block;
2495+ flex-shrink: 0;
2496+ margin: 0 0.25rem;
2497+ font-family: var(--font-ui);
2498+ font-size: var(--text-base);
2499+ font-weight: 300;
2500+ font-style: normal;
2501+ font-variation-settings: "MONO" 0;
2502+ letter-spacing: 0;
2503+ line-height: 1.5;
2504+ color: var(--muted);
2505+ }
2506+
2507+ .nav-btn {
2508+ display: flex;
2509+ flex-shrink: 0;
2510+ align-items: center;
2511+ box-sizing: border-box;
2512+ height: 2.1rem;
2513+ gap: 0.25rem;
2514+ padding: 0 0.35rem;
2515+ font: inherit;
2516+ font-size: var(--text-base);
2517+ color: var(--fg);
2518+ border: 1px solid var(--line);
2519+ border-radius: var(--radius);
2520+ background: var(--surface);
2521+ cursor: pointer;
2522+ }
2523+
2524+ .nav-menu.ref-menu-list {
2525+ min-width: 13rem;
2526+ position-area: bottom span-left;
2527+ }
2528+
2529+ .nav-menu.ref-menu-list a {
2530+ display: flex;
2531+ gap: 1.5rem;
2532+ }
2533+
2534+ .nav-menu a > span:last-child:not(:first-child) {
2535+ margin-left: auto;
2536+ font-family: var(--font-mono);
2537+ font-variation-settings: "MONO" 1;
2538+ color: var(--muted);
2539+ }
2540+
2541+ .nav-icons {
2542+ display: flex;
2543+ flex: 1 1 0;
2544+ justify-content: flex-end;
2545+ column-gap: 0.45rem;
2546+ min-width: 2.2rem;
2547+ padding-left: 0.65rem;
2548+ container-type: inline-size;
2549+ }
2550+
2551+ .nav-icons.docs-2 {
2552+ min-width: 4.15rem;
2553+ }
2554+
2555+ .nav-icons a {
2556+ display: flex;
2557+ flex: none;
2558+ align-items: center;
2559+ box-sizing: border-box;
2560+ height: 2.1rem;
2561+ gap: 0.25rem;
2562+ padding: 0 0.1rem;
2563+ font-size: var(--text-sm);
2564+ line-height: 1.25rem;
2565+ --link: var(--muted);
2566+ }
2567+
2568+ .nav-icons a > svg {
2569+ flex-shrink: 0;
2570+ }
2571+
2572+ @container (width < 5.15rem) {
2573+ .docs-1 span {
2574+ display: none;
2575+ }
2576+
2577+ .docs-1 svg {
2578+ width: 21px;
2579+ height: 21px;
2580+ }
2581+ }
2582+
2583+ @container (width < 10.45rem) {
2584+ .docs-2 span {
2585+ display: none;
2586+ }
2587+
2588+ .docs-2 svg {
2589+ width: 21px;
2590+ height: 21px;
2591+ }
2592+ }
2593+
2594+ .nav-icons a[aria-current] {
2595+ --link: var(--fg);
2596+ font-weight: 600;
2597+ }
2598+
2599+ .nav-icons a[aria-current] > svg {
2600+ color: var(--fg);
2601+ }
2602+
2603+ .sticky,
2604+ .view-switch,
2605+ .action-code .view-switch {
2606+ position: relative;
2607+ top: 0;
2608+ }
2609+
2610+ .log-date {
2611+ position: static;
2612+ }
2613+
2614+ .sticky,
2615+ .action-code .ref-bar,
2616+ .view-switch,
2617+ .view-switch > :first-child,
2618+ .view-switch > :last-child {
2619+ animation: none;
2620+ }
2621+}