euv_docs/lib.rs
1//! euv-docs — a VuePress-style documentation site powered by euv + euv-ui.
2//!
3//! Markdown sources live in `docs/`; `build.rs` compiles them into the
4//! `DocsSite` static consumed here at runtime.
5
6mod component;
7mod data;
8mod router;
9
10mod generated {
11 include!(concat!(env!("OUT_DIR"), "/docs_gen.rs"));
12}
13
14pub use std::{cell::RefCell, fmt::Debug, rc::Rc};
15
16use {
17 data::*,
18 euv::{wasm_bindgen::prelude::*, web_sys::*, *},
19 euv_ui::*,
20 router::*,
21};
22
23use crate::component::*;
24
25/// WASM entry point: injects global styles and mounts the app.
26#[wasm_bindgen]
27pub fn main() {
28 console_error_panic_hook::set_once();
29 inject_app_global_css();
30 Css::inject_css(EUV_MD_CSS);
31 // Site-level CSS override: hide the heading anchor `#` glyph
32 // entirely on every viewport, and stop it from reserving any
33 // horizontal space next to the heading.
34 //
35 // euv-ui's `euv_markdown` wraps every heading in
36 // `<a class="header-anchor"><span>#</span></a>`. The upstream
37 // desktop rule is `float: left; margin-left: -0.9em; opacity: 0`
38 // and reveals the glyph on `h*:hover` via `opacity: 1`. The
39 // mobile rule is `display: inline-flex; width: 1.6em;
40 // margin-left: -1.6em` with a matching `padding-left: 1.6em` on
41 // the heading. Both rules reserve horizontal space for the
42 // anchor even when it is invisible (opacity: 0), so heading
43 // text is pushed right by ~12px (desktop) or ~1.6em (mobile)
44 // regardless of hover state.
45 //
46 // On this docs site the design intent is to drop the `#` glyph
47 // entirely — it is not part of the heading's reading content,
48 // and it added extra spacing and visual noise for no benefit.
49 // The URL fragment that the anchor encodes is still present in
50 // the DOM (so deep links continue to resolve), but the glyph is
51 // never painted and the anchor takes no inline or visual space.
52 //
53 // Loaded after `EUV_MD_CSS` so cascade order places these rules
54 // after the upstream defaults; `!important` keeps the rule safe
55 // against future selector-specificity bumps from upstream.
56 Css::inject_css(
57 ".md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 { padding-left: 0 !important; } \
58 .md-body .header-anchor, .md-body h1:hover .header-anchor, .md-body h2:hover .header-anchor, .md-body h3:hover .header-anchor, .md-body h4:hover .header-anchor, .md-body h5:hover .header-anchor, .md-body h6:hover .header-anchor { display: none !important; }",
59 );
60 App::mount("#app", app);
61}