The first version of Samla kept a separate HTML component library beside the site. Every change had to be made twice, and the two copies drifted. Here is what we changed.
One source of markup
Section titled “One source of markup”Each element, component and section is now one .astro file. Its markup, styles and any script live together, and a built site is still ordinary static HTML.
Scoped styles
Section titled “Scoped styles”Component CSS sits in a scoped <style> block. Shared values live in tokens.css, and global.css keeps only document-level rules.
Only the JavaScript needed
Section titled “Only the JavaScript needed”Most pieces need no script at all. Where one does, it ships with that piece and nowhere else. Our rule is simple:
- Start from native HTML
- Add JavaScript only where it earns its place
- Keep the page usable before it loads
A piece should work before its script runs.
Check it in a real site
Section titled “Check it in a real site”A component isn’t done until a clean Astro site can render it:
import Statement from "@samla/ui/Statement.astro";The demo site is that clean consumer, so every change is checked there as well as in the docs.
What we learned
Section titled “What we learned”- One copy of the markup is easier to keep right than two.
- Scoped styles stop one piece breaking another.
- Most pieces never needed JavaScript.