Expand description
Canonical ROLE → semantic HTML element mapping (spec/OPCODE.md §semantic
properties) + typography-driven heading levels, shared with the TypeScript
DOM client: the Rust renderer consumes these tables directly, and
pathland-ts-codegen emits the TS equivalents into generated/role-spec.ts
— so the semantic-tag / ARIA / heading mapping cannot drift between the
renderers.
Rule summary:
ROLEis semantic structure only. The catalog (seepathland_core::role) holds landmarks, headings, paragraphs and lists — interactive/control roles (button, link, checkbox, …) are NOT roles: they are intrinsic to the control components (BUTTON→<button>,TOGGLE→<input type="checkbox">,MENU→role="menu"), and a custom-looking button usesButton+ButtonStyle.- A role retags only a generic
div/spanshell (seeGENERIC_COMPONENTS) to its semantic element (<nav>,<main>, …). - Control components keep their native element and emit no ARIA role
from
ROLE. - Headings come from a
TEXT_STYLEtypography (LargeTitle…Headline →<h1>–<h5>, always a heading) or fromROLE_HEADER(default<h2>); raw font modifiers never imply a heading. Non-heading text defaults to<span>;ROLE_PARAGRAPHgives<p>.
Structs§
- RoleTag
- A role that maps onto a native semantic HTML element. On a generic shell the
role renders as
RoleTag::tag; when the role is applied to a non-generic component,RoleTag::ariais the ARIA fallback.
Enums§
- Shell
Kind - How a role interacts with an element’s shell. Decided from the component when known; the DOM client derives it from the element’s tag when hydrating (it has no component for SSR-provided nodes).
Constants§
- GENERIC_
COMPONENTS - Components whose shell is a generic
div/span— the only shells a semantic role retags. Control components keep their native element. - HEADING_
STYLES - The
TEXT_STYLEtypographies that imply a heading element (<h1>–<h5>), mapping style code → heading level. A title/headline style on aTEXTis always a heading, even withoutROLE_HEADER. - NATIVE_
ROLE_ COMPONENTS - Components whose native element conveys their role — they never emit an
ARIA role from the
ROLEproperty. - ROLE_
TAGS - Semantic roles with a native element.
HEADER(heading) defaults to<h2>— its level is raised by aTEXT_STYLEtypography (seeHEADING_STYLES).SUMMARYmaps to<section>(a named region).
Functions§
- aria_
role - The ARIA
roleattribute value to emit for(shell kind, role), orNonewhen the element already conveys the role (a semantic tag or a native control element). Control roles no longer exist in the catalog, so any unknown/reserved code is a no-op. - heading_
level - The heading level a
TEXT_STYLEtypography implies, orNonefor the non-heading styles (Subheadline, Body, Callout, Footnote, Caption, Caption2). - heading_
tag - The heading element tag for a level (
1→h1…5→h5). - semantic_
tag - The semantic tag a
(shell kind, role)pair resolves to, orNonewhen the element keeps its default shell tag. - shell_
kind - Resolve a component to its shell kind.
- text_
tag - The effective tag for a generic
TEXTshell: a headingTEXT_STYLEwins (always a heading), then the semantic role (ROLE_HEADER→<h2>,ROLE_PARAGRAPH→<p>, landmarks), elseNone(→<span>).