pathland_render_html/css.rs
1//! The renderer's built-in CSS — delivered inline in a `<style>` tag.
2//!
3//! The stylesheet is the generated HTML base design:
4//! - a **preflight reset** (vendored from Tailwind CSS, MIT — see
5//! `THIRD_PARTY_NOTICES`),
6//! - `:root` **design tokens** as CSS custom properties, named to match the
7//! protocol's design-token paths (e.g. `color.primary` → `--pl-color-primary`)
8//! so `SET_DESIGN_TOKEN` over the wire can retheme the renderer,
9//! - `.pathland-*` component defaults written against the tokens.
10//!
11//! Layout and per-node styling come from inline `style` (all opcode properties);
12//! this bundle provides the component look + interactive states (hover/focus/
13//! disabled) which cannot be expressed inline.
14//!
15//! Source of truth: `design/` (Style Dictionary tokens + `design/html/*.css`).
16//! `design/build/base.css` is synced here by `scripts/sync-design-css.sh` and
17//! committed so the crate packages the built-in design without a Node toolchain.
18//! Do not edit `assets/base.css` by hand.
19
20const CSS: &str = include_str!("../assets/base.css");
21const CSS_NAME: &str = include_str!("../assets/base.css.name");
22
23/// The generated base-design stylesheet (without the wrapping `<style>` tag).
24#[must_use]
25pub fn builtin_css() -> &'static str {
26 CSS
27}
28
29/// The content-hashed asset name of [`builtin_css`] (e.g. `base-5f86423db422.css`).
30/// Hosts serve the stylesheet at this name under `/_pathland/` so a new build
31/// busts the immutable asset cache via a fresh URL.
32#[must_use]
33pub fn builtin_css_name() -> &'static str {
34 CSS_NAME.trim()
35}
36
37/// The complete `<style>` block injected into every rendered document.
38pub const STYLE: &str = concat!("<style>", include_str!("../assets/base.css"), "</style>");