skills/canvas-navigation-components/SKILL.md
Plans and builds Drupal Canvas navigation UI (main nav, footer links, sidebar nav, mobile drawers, breadcrumbs) using design decomposition for structure and props/slots, then JSON:API menu or page-context patterns from canvas-data-fetching. Use when the user asks for navigation, header or footer links, menus, menu_items, mobile nav, or breadcrumb trails. Run after canvas-design-decomposition for layout and API sketches; follow canvas-data-fetching for SWR, JsonApiClient, sortMenu, and menu fallbacks.
npx skillsauth add drupal-canvas/skills canvas-navigation-componentsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Build navigation that fits Canvas: reusable names, clear props
(variant, menuName) and slots (logo, utilities, mega-menu regions),
correct data source (Drupal menu vs breadcrumb context vs static), and
accessible markup.
This skill stacks on:
canvas-design-decomposition —
regions, tree, prop/slot sketch, reuse-first naming before code.canvas-data-fetching — SWR,
JsonApiClient, menu resource pattern, Workbench rules.Then apply canvas-component-metadata,
canvas-component-definition
(including
references/naming.md),
canvas-styling-conventions, and
canvas-component-composability
for slots and repeatable groups.
Follow canvas-design-decomposition
through at least Phase E (props/slots) before writing React or
component.yml.
Navigation-specific prompts:
canvas-component-composability/references/repeatable-content.md.machineNames (main-navigation, footer-navigation), not
page-specific names. Express placement in the page, not the component name.variant for layout modes (horizontal, drawer, compact footer).menuName in the sketch when the nav reads from a Drupal menu
(see step 2). Use slots for logo, utility links, or CTAs when authors
compose those blocks.See references/data-sources.md for a decision table. Summary:
| Source | When |
| --------------- | --------------------------------------------------------------------------- |
| Drupal menu | Editors manage links in Structure → Menus; use menu_items + getResource |
| Breadcrumb | Trail from current page context via getPageData() |
| Static | Rare; document why; still provide sensible defaults or slots |
Use the Navigation / Menu Components section in
canvas-data-fetching:
useSWR(menuName ? ['menu_items', menuName] : null, ([type, id]) => client.getResource(type, id))Array.from(sortMenu(data)) when data is valid; otherwise
FALLBACK_LINKSFALLBACK_LINKS so Workbench and sites without the menu
still render.menuName in component.yml when editors should pick the Drupal
menu (machine name, e.g. main, footer). Hard-coding only the default in
JSX without a prop is fine for examples; production nav that must switch
menus should register menuName per data-fetching rules.menuName omitted or null in props: use SWR key null and show fallback when
you need static-only preview behavior.Do not fabricate JSON:API menu payloads in Workbench mocks. Prefer real loading/error/empty behavior; fallback links cover the empty-menu case.
Menus in Drupal (preferred): Production navigation should live in Drupal
menus (CMS), not only as hardcoded arrays in code. FALLBACK_LINKS are
for Workbench / empty-menu cases — not a long-term substitute for CMS menus on a
real site.
On Acquia Source, prefer creating or updating menus via Source MCP using
acquia-source-navigation-menus
when automating that environment; otherwise use Structure → Menus in Drupal.
Align menu_name with this component’s menuName prop.
For non–Acquia Source targets, use the Drupal admin (or your deployment
process) — do not apply the Source MCP menu skill. If there is no admin/MCP
access, tell the user exactly which menus to create (match menuName /
machine names such as main, footer) and link to Structure → Menus as in
canvas-data-fetching.
Breadcrumbs come from page context, not menu_items. Precedent:
examples/components/breadcrumb/index.jsx
(getPageData(), breadcrumbs). Probe or read existing patterns before
inventing fields.
<nav> with distinct aria-label (or
aria-labelledby pointing at visible heading text).aria-expanded, aria-controls when you wire IDs; button
type="button".aria-current="page"—only the true current item when
the design requires it.canvas-component-metadata.canvas-component-definition.canvas-styling-conventions.Menu + SWR + sortMenu pattern:
examples/components/main_navigation/index.jsx.
Consider adding menuName to component.yml when editors must choose the
menu without code changes.
JsonApiClient call the component will use (see
canvas-data-fetching) before mapping
children.menuName YAML live under Navigation / Menu
Components in
canvas-data-fetching.canvas-design-decomposition.testing
Use for any task touching site chrome — header, footer, sidebar, or global navigation that repeats across pages — and for any region-spec work (create, modify, review, validate region JSON, or the project-level layout component). Also load when a task creates or edits multiple pages that share chrome, or asks for a "site" or "navigation between pages"; shared chrome belongs in regions, never inlined into page JSON.
content-media
Create and modify content templates that map Drupal content entities to Canvas component layouts. Use when asked to (1) Create a new content template, (2) Modify an existing content template, (3) Add or change entity field mappings in a template, (4) Compose components in a content template via slots. Content templates live in the configured `contentTemplatesDir` (default `content-templates/`) and define how Drupal entity types, bundles, and view modes render as Canvas component trees.
development
Plans structure for a component library with props/slots and right-sized component granularity. Run before building or adding Canvas components (new `src/components/` folders, component.yml, React), or for plan-only / breakdown-only work, whenever UI must map to a coherent tree. Mandatory for every new Figma frame or greenfield screen—repository drafts do not replace phases A–G.
development
Use when work must be verified in local Canvas Workbench, or when the user asks to run, open, check, or author component mocks or page previews in Workbench. Verifies that Canvas Workbench is available through the project's package runner, starts the local Workbench dev server, and keeps Workbench verification as part of the implementation workflow.