Web Menu Skills — 高质量后台侧边栏
Purpose
Produce a sidebar that feels "alive": every state change animates smoothly, nothing pops or jumps, and the whole component remains usable by keyboard and assistive technology. Deliver working code, not a static mockup.
The skill bundles a complete, dependency-free reference implementation in assets/sidebar-demo/ (single HTML file with inline CSS + JS) that already implements all six interactions. Copy and adapt it rather than re-inventing from scratch.
When to use
- User requests an admin / dashboard / 后台管理 sidebar with "高级感 / 交互质感 / 动画流畅".
- User lists any of: sliding active indicator, collapsible sidebar, accordion menu, flyout/hover submenu, resizable sidebar, drag-and-drop menu reordering.
- User wants keyboard-accessible, ARIA-correct navigation.
Core workflow
- Read the interaction spec first. Open
references/interaction-specs.md— it defines the exact behavior, timing, CSS properties, and accessibility contract for each of the six interactions. Do not approximate these; the spec is the acceptance criteria. - Choose the base.
- For a quick demo or a framework-agnostic starting point: copy
assets/sidebar-demo/index.htmlinto the user's project and adjust the menu data and theme tokens. - For a React/Vue project: port the same structure and behavior using the framework's state model, but keep the DOM/CSS/ARIA contract from the spec identical.
- For a quick demo or a framework-agnostic starting point: copy
- Implement all six interactions. Even if the user only names one, wire up the others — they share state (collapsed mode affects flyout; resize affects indicator position). A partial implementation breaks the feel. See
references/interaction-specs.md. - Honor the animation rules. Animate
transformandopacity; avoid animating layout properties (width,top,left) where a transform can achieve the same result. Use a single shared easing token and stagger child reveals with smalltransition-delaysteps. - Verify accessibility. Every interaction must be operable by keyboard and expose correct ARIA. Run the accessibility checklist in
references/interaction-specs.mdbefore finishing. - Verify the result actually runs. Open the demo in a browser (or start a static server) and confirm each interaction works. Do not deliver untested animation code.
Design tokens (keep consistent)
Define CSS custom properties for: --sidebar-width, --sidebar-width-collapsed, --indicator color, --ease (e.g. cubic-bezier(.4,0,.2,1)), --dur (e.g. 240ms), --stagger (e.g. 28ms). All animations reference these tokens so timing stays coherent across interactions.
Deliverables checklist
- Working HTML/CSS/JS (or framework component) with all six interactions.
- Slide indicator repositioned on: initial load, menu toggle, resize, reorder, window resize.
- Collapse/expand synchronized with the main content area.
- Flyout works while collapsed, via both hover and keyboard focus.
- Resize handle with min/max clamp; indicator and flyout follow the new width.
- Reorder via pointer and via keyboard (Alt+Arrow), with live region announcing the move.
- ARIA roles/states correct:
nav,aria-expanded,aria-current,aria-controls,role="menu"where appropriate. prefers-reduced-motiondisables/shortens animations.
Resources
references/interaction-specs.md— authoritative spec: behavior, timing, CSS technique, keyboard + ARIA contract, and verification checklist for each of the six interactions. Load this whenever implementing or reviewing the sidebar.assets/sidebar-demo/index.html— complete runnable single-file demo (inline CSS + JS, no dependencies). Copy as the starting scaffold; contains all six interactions and accessibility wiring.