feat: add client-side routing and page structure#68
Conversation
Add RescriptReactRouter with pattern-matched URL routing. Split monolithic App.res into separate pages (Home, Components, Posts, Login) with a sticky NavBar and 404 fallback. Add historyApiFallback to Rspack dev server for client-side routing support. Closes #36
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughRestructured the application with client-side routing by introducing a Router component, creating separate page components (Home, Components, Posts, Login, NotFound), adding a NavBar for persistent navigation, removing scaffolding components from App.res, configuring devServer history API fallback, and refactoring theme color references throughout. Changes
Sequence DiagramsequenceDiagram
participant User
participant Browser
participant Router
participant NavBar
participant Page
User->>Browser: Navigate to URL / click link
Browser->>Router: URL change detected
Router->>Router: useUrl() reads path
Router->>Router: Pattern match on path
Router->>NavBar: Render NavBar component
NavBar->>NavBar: useUrl() gets currentPath
NavBar->>NavBar: Apply active state styling
NavBar->>Browser: Display with active link
Router->>Page: Render matched page component
Page->>Browser: Display page content
User->>NavBar: Click navigation link
NavBar->>Router: handleNav() calls RescriptReactRouter.push()
Router->>Router: useUrl() detects new path
Router->>Router: Re-render with matched page
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
RescriptReactRouterwith URL pattern matching inRouter.resApp.resinto 4 pages: Home, Components, Posts (placeholder), Login (placeholder)NavBarcomponent with active link highlighting and SPA navigationhistoryApiFallback: trueto Rspack dev server configApp.resis now a clean shell: NavBar + Router + FooterNew files
src/Router.res— URL → page component mappingsrc/components/NavBar/NavBar.res— sticky nav with active statessrc/pages/HomePage.res— hero + features (extracted from App.res)src/pages/ComponentsPage.res— component showcase (extracted from App.res)src/pages/PostsPage.res— placeholder for Phase 2 (Relay)src/pages/LoginPage.res— placeholder for Phase 3 (Auth)Test plan
bun run res:build— 88 modules compiled, zero warningsbun run build— production build succeedsbun run test— all 18 tests passCloses #36
Summary by CodeRabbit
New Features
Refactor