Repository navigation
Description
What: useAnnounce — Announces a message to screen readers through a visually hidden live region, for state that is otherwise only shown visually.
A good example shows: A filter field above a list of products. As the user types, the visible list shrinks and the hook politely announces "12 results" or "No results", debounced so it does not chatter on every keystroke.
Where:
- Hook source:
packages/core/src/hooks/useAnnounce.ts - Hook doc:
packages/core/src/hooks/useAnnounce.doc.mjs - Example blocks:
packages/cli/assets/templates/blocks/components/(add a<Name>.tsx+<Name>.doc.mjspair, for example underHooks/). Existing hook examples to copy the shape from:Theme/useThemeHookUsageandPopover/PopoverHookUsage.
Acceptance criteria:
-
A template block names
useAnnounceinexampleFor(oralsoExampleFor) and renders in the Examples section of the hook's docsite page. -
The hook visibly drives the behavior: removing the hook call breaks what the example shows. Minimal code; no unrelated UI or styling.
-
Meets the rule
architecture:knowledge-contractsINV28 (docs/architecture/knowledge-contracts.md), quoted here:INV28 — Every public hook has a minimal, runnable example that
demonstrates it. A public hook is a hook that a package's committed API
report lists. Its documentation includes at least one realistic, runnable
example: a live template block that names the hook as its example target
(exampleFor, oralsoExampleForwhen the block also serves another page).
The example:- shows the hook inside a component solving the use case its docs state;
- imports the package's own code only through its public entry points;
- covers the hook's main parameters and return values;
- passes the docs build;
- gets its visible behavior from the hook itself, so removing the hook breaks
what the example shows; and - is minimal: only the code needed to show the use case, with no unrelated UI
or styling.
How a docs page selects and orders its example blocks belongs to
architecture:template-authoring. A public hook without a conforming example
is a docs gap, tracked as an issue in the repository's issue queue (DEC-16).
Good first issue: start with CONTRIBUTING.md. For orientation, run astryx docs and astryx component --list from the repo root (the CLI is node packages/cli/clients/cli/bin/astryx.mjs). The hook's own tests next to its source show how it is called.
Filed by an AI agent on behalf of the maintainer, as part of a docs-coverage sweep.
Activity
docs(useAnnounce): add a filter result count example block
docs(useAnnounce): add a filter result count example block
docs(useAnnounce): add a filter result count example block (meta#9509)