Compose Pages
Composes extracted React components into stateful page orchestrators. Takes a component library (from decompose-pages or similar) and wires it into thin Astro page routes with proper state management, event threading, and layout shells.
When to Use
After extracting a component library from raw HTML pages. The components exist as stateless presentation units — this skill turns them into working pages.
Phases
Phase 1: Inventory and Map
- •Read all components in
src/components/, catalog exported names and props interfaces. - •Read screen specs (
screens/*.md,plan.md, or equivalent UX docs). - •Build a component-to-page mapping table — which components appear on which screens.
Phase 2: Identify Page Architecture
- •Determine which HTML pages are separate routes vs. states of the same page.
- •Multiple pages with the same layout but different panel contents = one route with conditional rendering.
- •Pages with fundamentally different layouts = separate routes.
- •Identify state variables needed to toggle between states (e.g.,
rightPanelMode,selectedTone,dropdownOpen). - •Identify shared layout shells (common
<head>, body classes, global CSS).
Phase 3: Configure Framework
- •Add framework integration to
package.json(e.g.,@astrojs/react,react,react-dom). - •Update
astro.config.mjsto register the integration. - •Extract shared CSS into
src/styles/global.css(scrollbar styles, card styles, utility classes). - •Extract theme tokens into proper Tailwind config (currently duplicated inline in every page).
- •Ensure shared fonts/icons load from the layout shell.
Phase 4: Create Layout Shell
- •Create
src/layouts/AppLayout.astrowith:- •Proper
<html>,<head>with fonts, meta tags, global CSS imports. - •Body classes matching the design system.
- •
<slot />for page content.
- •Proper
Phase 5: Compose Page Components
- •Create page component files in
src/components/pages/. - •Each page component:
- •Owns all state for that route.
- •Composes child components via props and callbacks.
- •Contains no raw HTML — only component composition and layout wrappers.
- •Wire events: callbacks flow down, state updates flow up.
- •Use mock/demo data for initial implementation.
Phase 6: Rewrite Astro Pages
- •Replace raw HTML in
src/pages/*.astrowith thin wrappers:- •Import the layout shell.
- •Import the page component with
client:load.
- •Delete/archive pages that collapsed into state variants of other pages.
Phase 7: Verify
- •Run
npm install && npm run dev. - •Visit each route and visually compare against original HTML pages.
- •Verify state transitions work (toggles, selections, overlays).
- •Run
npm run buildto ensure no type/build errors.
References
- •
references/COMPOSITION_PATTERNS.md— patterns for state collapse, thin pages, overlay-as-state, and prop drilling guidelines.