2.0 KiB
2.0 KiB
name, description, paths
| name | description | paths | ||
|---|---|---|---|---|
| public-pages | Rules for frontend pages and web components |
|
- Pages (
public/pages/*.js) export an asyncrender(container, params)function. No side effects on import — only the defaultrenderexport may mutate state. Pages are invoked bypublic/router.js. - Components (
public/components/*.js) — one custom element per file, class name ends inElement, tag name uses theoikos-prefix (<oikos-task-list>). Register once per file withcustomElements.define. - UI text — every string the user reads goes through
t('key')frompublic/i18n.js. Never hardcode German, English, or any other language. Add the key to every locale file underpublic/locales/.deis the reference locale and must stay complete. - Dates and times —
formatDate(value, opts)andformatTime(value, opts)frompublic/i18n.js. Never calltoLocaleString,toISOString,Intl.DateTimeFormatdirectly in pages or components. - No
innerHTML— not for user data, not for static SVG strings, not for templates. Usedocument.createElement,document.createElementNS(for SVG),replaceChildren,appendChild,textContent. The PostToolUse hook blocks violations on save. - API calls — go through
apiFetch()frompublic/api.js. It handles CSRF, session expiry, and error envelope. Never callfetch()directly from a page. - Navigation — use
router.navigate(path)frompublic/router.js. Never setlocation.hreforlocation.pathnamedirectly. - Styling — reference tokens from
public/styles/tokens.css. No raw hex, rgb(), rem, or px in component CSS — usevar(--token-name). - Icons — use the self-hosted Lucide helper if one exists in the repo, otherwise
createElementNS('http://www.w3.org/2000/svg', ...). Never inline an SVG viainnerHTML. - Lifecycle — components must clean up listeners in
disconnectedCallback. Debounce or throttle heavy handlers viapublic/utils/ux.js.