Loading...

HAXcms Themes Reuse Core Elements, Restyled

RULES.md

A HAXcms theme, bundled or a site's `custom/` theme, generated by a tool or written by hand, builds its chrome from the elements HAXcms already ships. It restyles them for its own look (its own design system) instead of rebuilding them in its own markup. Use `site-title` for the site name and home link, `site-menu` (or `HAXCMSMobileMenu()` / `HAXCMSFlexMenu()` from `HAXCMSMobileMenuMixin`) for navigation, `site-menu-button type="prev|next"` for pagers, `site-breadcrumb` for the trail, `site-active-title` for the page title and `site-region` for content regions. Reach for the others in `@haxtheweb/haxcms-elements/lib/ui-components/` (`site-search`, `site-active-media-banner`, `site-print-button`, `site-modal`) before writing an equivalent. These elements already read the site store, follow edit mode (they go inert and dim while editing), honor page settings such as "hide page title", and carry HAX's accessibility and i18n fixes. A hand-built copy loses all of that and drifts. Style them through what they expose: their CSS custom properties (`--site-title-*`, `--site-menu-*` and the `--map-menu-*` it passes down, `--site-menu-button-*`, `--site-breadcrumb-*`), `::part()` (for example `site-title::part(site-name)`), slotted content (`site-menu-button` takes visible text in its `prefix` / `suffix` slots, and that text becomes its accessible name), and light DOM where the element renders there (`site-active-title h1`). Import them with explicit `.js` paths under `@haxtheweb/`. When a look needs markup a core element can't produce (a bulleted 1990s link list that `site-menu` / `map-menu` can't draw), keep the element's engine and draw only the markup. Read the data from the store HAXcms already computed (`store.routerManifest`, which drops unpublished pages, plus `store.activeId`; honor `metadata.hideInMenu`) or from `site-query`, and use core routes for behavior (`x/random` for a random page). Don't re-walk the raw manifest or reimplement routing. This also keeps heavier element stacks off the page when the theme doesn't use them. Build your own markup only for things HAXcms has no element for (a visitor counter, badges, a marquee). Make it follow edit mode the way core does, for example with the `--haxcms-theme-parts-edit-mode-active-*` values. If a core element lacks a styling hook a theme needs, open an issue in https://github.com/haxtheweb/issues to add one rather than forking the element. Previews that cannot load HAX (a generator's static wizard preview) may draw plain-HTML stand-ins, but the theme itself uses the real elements. In PRAW RULES.md (scope: haxcms). Nothing enforces this yet.

Status: gap

Connects to

Links