Niveus is the interface language the project uses from here on -- this site
first, applications after it. Rebuilding the site on it is what proves the
system is one, rather than a folder of CSS with a README.
**`style.css` is gone.** 21 KB that transcribed include/theme.h by hand:
palette, type scale, shadows, spacing, every component. The intent was right --
"a site describing an operating system should look like the operating system"
-- and the mechanism was a copy, which means two files that have to be kept in
step by remembering to. What replaced it is `app.css`, which is layout and
nothing else, and one declaration in each page:
:root { --nv-brand: #7C5CFF; }
That is SCH_ACCENT. Niveus derives the accent and its states, the link colour,
the focus ring, the tint in the greys and how far the status colours lean, for
light and dark both. One number to keep true instead of forty.
**The site is now adaptive.** Dark by default, because the OS is dark, with a
Light/Dark/Auto group in the bar that is real. The choice is kept in
localStorage and re-applied by an inline script before first paint, so the page
never renders in one appearance and corrects itself while you watch.
**PSOGM keeps its one purple, and now says so structurally.** #4B1D9A is
spelled the way Niveus spells a subtree with its own colour -- `data-nv-brand`
with its own `--nv-brand` on that section -- so every role inside re-derives
from it rather than being painted on. Still exactly one place, which is what
branding/README.md asks for.
Content is unchanged; what changed is what it is made of. Cards are `.nv-card`,
tags are `.nv-badge`, the support table is `.nv-table`, the crash section is a
`.nv-bed`, and the docs reader's two rails are `.nv-nav--vertical` with the
current document marked by `aria-current` rather than a class of our own.
`docs.js` emits `.nv-table` and `.nv-code`, so a change to the system reaches
the documentation too.
Three things were found by looking at it in a browser rather than by reading
it, and all three are the same mistake: **a `.nv-card` carries no padding of
its own -- its parts do.** The stat tiles, the "One ISO, one stick" band and
the card headers were all built from bare children, so numbers ran to the card
edge, the USB mark hung off it, and a title and its badge sat at opposite ends
of a row meant for a title and a trailing slot. Where the component had a right
way to say it, the markup now says it that way; where it did not -- a tile has
no parts -- `app.css` supplies the padding and says why.
Checked: every nv- class used across the three pages and docs.js exists in the
CSS, every token referenced by app.css is defined, and app.css contains no hex
value at all. Niveus's own tools/check.py passes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
113 lines
3.6 KiB
Python
Vendored
113 lines
3.6 KiB
Python
Vendored
#!/usr/bin/env python3
|
|
"""Bundle the Niveus sources into a single stylesheet.
|
|
|
|
`niveus/niveus.css` is the authored entry point and works as-is over HTTP: the
|
|
browser resolves the @import chain itself. That costs a request per file and,
|
|
more importantly, blocks rendering until the whole chain has loaded — so for
|
|
anything shipped, this script flattens the chain into `dist/niveus.css`.
|
|
|
|
Each `@import url("…") layer(name)` becomes a `@layer name { … }` block holding
|
|
the file's contents, which is exactly equivalent to what the browser does with
|
|
the import. Nothing is minified and nothing is reordered; the output is meant
|
|
to stay readable and to diff cleanly against the sources.
|
|
|
|
python3 tools/build.py [--check]
|
|
|
|
--check verifies dist/ is current without writing, for use in CI.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
ENTRY = ROOT / "niveus" / "niveus.css"
|
|
OUTPUT = ROOT / "dist" / "niveus.css"
|
|
|
|
IMPORT = re.compile(
|
|
r"""@import\s+url\(\s*["']([^"']+)["']\s*\)\s*(?:layer\(\s*([^)]+?)\s*\))?\s*;""",
|
|
re.VERBOSE,
|
|
)
|
|
|
|
|
|
def indent(text: str, prefix: str = " ") -> str:
|
|
return "\n".join(prefix + line if line.strip() else line for line in text.split("\n"))
|
|
|
|
|
|
def bundle(path: Path, seen: set[Path] | None = None) -> str:
|
|
"""Inline every @import in `path`, depth first."""
|
|
seen = seen if seen is not None else set()
|
|
resolved = path.resolve()
|
|
if resolved in seen:
|
|
raise SystemExit(f"circular @import involving {resolved.relative_to(ROOT)}")
|
|
seen.add(resolved)
|
|
|
|
source = path.read_text(encoding="utf-8")
|
|
out: list[str] = []
|
|
cursor = 0
|
|
|
|
for match in IMPORT.finditer(source):
|
|
out.append(source[cursor : match.start()])
|
|
cursor = match.end()
|
|
|
|
target = (path.parent / match.group(1)).resolve()
|
|
if not target.is_file():
|
|
raise SystemExit(f"{path.relative_to(ROOT)}: cannot resolve {match.group(1)}")
|
|
|
|
# The import's own comment header is kept; it explains the section.
|
|
contents = bundle(target, seen).strip("\n")
|
|
layer = match.group(2)
|
|
if layer:
|
|
out.append(f"@layer {layer} {{\n{indent(contents)}\n}}")
|
|
else:
|
|
out.append(contents)
|
|
|
|
out.append(source[cursor:])
|
|
seen.discard(resolved)
|
|
return "".join(out)
|
|
|
|
|
|
def build() -> str:
|
|
header = (
|
|
"/* Niveus — generated bundle. Do not edit.\n"
|
|
" Source: niveus/niveus.css and the files it imports.\n"
|
|
" Rebuild: python3 tools/build.py\n"
|
|
"*/\n\n"
|
|
)
|
|
body = bundle(ENTRY)
|
|
# Collapse the runs of blank lines left behind by the inlined imports.
|
|
body = re.sub(r"\n{3,}", "\n\n", body).strip() + "\n"
|
|
return header + body
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument(
|
|
"--check",
|
|
action="store_true",
|
|
help="fail if dist/niveus.css differs from the sources",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
result = build()
|
|
|
|
if args.check:
|
|
current = OUTPUT.read_text(encoding="utf-8") if OUTPUT.is_file() else None
|
|
if current != result:
|
|
print("dist/niveus.css is out of date — run: python3 tools/build.py")
|
|
return 1
|
|
print("dist/niveus.css is up to date")
|
|
return 0
|
|
|
|
OUTPUT.parent.mkdir(parents=True, exist_ok=True)
|
|
OUTPUT.write_text(result, encoding="utf-8")
|
|
size = len(result.encode("utf-8"))
|
|
print(f"wrote {OUTPUT.relative_to(ROOT)} ({size:,} bytes)")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|