A component becomes reusable when its assumptions become small enough to carry elsewhere.
Begin with a useful piece
I like building a framework incrementally. A concrete page gives me a real problem: a readable card, a compact preference selector, a form that explains what happened, or navigation that fits a narrow screen. I solve that problem, then look for the part whose meaning survives outside the page.
That last question determines where the code belongs. A carousel knows about a rail and items. Translation knows about messages and a selected language. A theme knows about surfaces, spacing, and emphasis. The blog knows which articles are pinned and which month appears first. Those are different kinds of knowledge, even when they cooperate to produce one screen.
A namespace makes the decision visible. Generic HTML and interaction helpers live under net.html. Language behavior lives under net.i18n. Astro, my visual system, lives under net.design.astro. The site-specific assembly lives under net.blog. Reading an import list should help me understand the component's actual responsibilities.
lsdep keeps the authoring model small
I wrote lsdep so I could author modules in LiveScript and bundle them for environments such as Windows Script Host. A dependency declaration near the top of a source file names the module that provides a function or object. The bundler reads those declarations, resolves the namespace paths, orders dependencies, and composes the bundle.
The dependency word is a convention understood by my tooling. It gives the source an import-like vocabulary without extending LiveScript's grammar. Modules expose ordinary objects, and destructuring brings the needed members into the caller's local scope. The resulting code is still inspectable, and the runtime does not need a package loader to find each source file.
This is especially comfortable for the WSH build. I can write helpers using LiveScript conveniences and execute the generated JScript with cscript. Compilation does not manufacture missing host APIs, so I keep the environment boundary explicit: filesystem operations belong to the build, DOM operations belong to browser modules, and each module receives the services it needs.
do ->
{ css, css-var } = dependency 'net.html.Css'
{ surface, stack } = dependency 'net.design.astro.Rules'
panel-styles = (doc) ->
doc.style do
css '.panel', surface, stack,
gap: css-var 'space-sm'
padding: css-var 'space-md'
api =
{ panel-styles }
api
Tokens describe relationships
My first level of visual reuse is a set of CSS custom properties. They describe roles: primary and secondary surfaces, readable and muted text, an accent, a small spacing scale, reading width, control size, and headline sizes. A component refers to the role instead of repeating a literal value every time it needs a color or a gap.
This is useful when changing a theme, but its everyday value is consistency. A quiet label should have a predictable relationship to body text. A card title should be stronger without dwarfing everything around it. The header's utility controls should remain subordinate to the person's name and motto. A narrow type scale helps those decisions remain coherent.
Responsive values also belong in that vocabulary. A page gutter can use clamp; a prose column can use a character-based measure; the header's measured height can inform sticky offsets. The code should describe the relationship I want, then let the browser resolve the current space. Arbitrary pixel corrections tend to preserve a screenshot instead of a design.
Shared declarations are the visual grammar
Tokens alone do not remove repetition. Several components may all need a surface, a border, a reading font, or a horizontal arrangement. I keep those declarations as small named objects such as surface, row, stack, prose, and quiet-control. The CSS helper combines objects from left to right, with the component's local declarations taking precedence.
This is intentionally ordinary composition. A panel can be a surface and a stack. A contact link can be a row and an unstyled link. The component adds only the properties that explain its difference. When creating a derived declaration set, I copy the base object before extending it so that changing one component cannot mutate the shared rule.
The names also become a review vocabulary. If a button is too visually loud, I can ask whether it should use the quiet-control role. If reading text is inconsistent, I can inspect the shared prose declaration. These are better places to make a coherent correction than a growing trail of selector-specific overrides.
Appearance and behavior meet through a contract
A theme should not decide which article a click opens. A translation component should not know where the blog stores its YAML files. A form submission helper should not contain the wording for a particular contact page. Those choices belong to the composition that uses the components.
The shared form is a concrete example. Its markup describes fields and a place for feedback. The submission controller handles pending state and a verified iframe acknowledgement. The translation function supplies messages. Astro styles the fields, focus, and result. The comment board and the private contact page assemble these pieces with different inputs.
The same principle applies to motion. The scrolling controller calculates progress through a focus region. The theme supplies scale, opacity, blur, and transitions. The blog chooses where that behavior belongs. A carousel can share the progress machinery while retaining a subtler horizontal treatment, with no blur on its cards. Reuse works because the inputs express the variation.
The output remains ordinary web material
The stylesheet builder assembles selected style functions and writes ordinary CSS files. Browser dependencies enter the document through shared slots. Modules and generated assets have separate jobs: lsdep organizes source dependencies for a bundle; runtime slot keys prevent repeated insertion of page resources. Confusing those two mechanisms would make both harder to understand.
I judge the design system by how comfortably I can move a component. Could the contact links appear on a portfolio? Could the form feedback work in a small local tool? Could the reading styles support a documentation page? Each time the answer requires less blog-specific knowledge, the framework gains a useful piece.
I also keep comments near aesthetic decisions: why the scale is narrow, why hover changes stay quiet, why a control wraps, why a line length is limited. Those comments preserve intent across later edits. A design system is easier to maintain when the code explains the visual relationship it is trying to protect.
