Skip to content

feat: add route-keyed page transitions with Framer Motion#100

Open
Kavlin-Kaur wants to merge 1 commit intoyashvikram30:mainfrom
Kavlin-Kaur:feature/route-transitions
Open

feat: add route-keyed page transitions with Framer Motion#100
Kavlin-Kaur wants to merge 1 commit intoyashvikram30:mainfrom
Kavlin-Kaur:feature/route-transitions

Conversation

@Kavlin-Kaur
Copy link

@Kavlin-Kaur Kavlin-Kaur commented Aug 10, 2025

## Description

Please include a summary of the changes and any related issue.

Fixes # (issue)

## Type of change

- [ ] Bug fix

- [ ] New feature

- [ ] Documentation update

- [ ] Other (please describe):

## Checklist

- [ ] I have read the contributing guidelines

- [ ] My changes follow the code style of this project

- [ ] I have added tests if needed

- [ ] I have updated documentation where necessary

Summary by CodeRabbit

  • Refactor
    • Improved layout structure for better organization and maintainability.
    • Enhanced route transition animations for smoother navigation.
    • Updated styling and formatting for consistency.
    • Adjusted placement of notification and analytics components for improved user experience.

@vercel
Copy link

vercel bot commented Aug 10, 2025

@Kavlin-Kaur is attempting to deploy a commit to the yash vikram's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Aug 10, 2025

Walkthrough

The layout structure of the application was refactored. The ClientLayout component now omits explicit <html> and <body> tags, consolidates styling, and implements route-keyed animated transitions using AnimatePresence and usePathname. The RootLayout now explicitly wraps content in <html> and <body>, and adjusts the placement of analytics and style imports.

Changes

Cohort / File(s) Change Summary
Client Layout Refactor
app/clientLayout.tsx
Removed explicit <html>/<body>, consolidated styling, added route-keyed animation with AnimatePresence, moved Toaster, and made formatting adjustments.
Root Layout Structure
app/layout.tsx
Moved global CSS import, restructured to explicitly use <html>/<body>, adjusted placement of Analytics and ClientLayout, and made minor formatting changes.

Sequence Diagram(s)

sequenceDiagram
    participant Browser
    participant RootLayout
    participant ClientLayout
    participant AuthProvider
    participant ThemeProvider
    participant AnimatePresence
    participant Toaster

    Browser->>RootLayout: Loads app
    RootLayout->>ClientLayout: Renders children
    ClientLayout->>AuthProvider: Wraps content
    AuthProvider->>ThemeProvider: Wraps content
    ThemeProvider->>AnimatePresence: Handles route transitions
    AnimatePresence->>Toaster: Renders notifications
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Poem

In the warren of code where layouts reside,
We tidied our tags and let <html> hide.
With routes that now fade, transitions anew,
The rabbit hops softly—animations in view!
A sprinkle of style, a dash of delight,
Our layout now gleams—oh, what a sight!
🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
app/clientLayout.tsx (1)

31-31: Confirm whether query/hash changes should also animate

key={pathname} ignores search params and hash. If you want transitions on query/hash changes, derive a key from both.

Optional change:

-import { usePathname } from "next/navigation"
+import { usePathname, useSearchParams } from "next/navigation"

-const pathname = usePathname()
+const pathname = usePathname()
+const search = useSearchParams()
+const routeKey = `${pathname}?${search.toString()}`

And:

- key={pathname}
+ key={routeKey}

If you only want path changes to animate (current behavior), keep as-is.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fbe9681 and 8b4004d.

📒 Files selected for processing (2)
  • app/clientLayout.tsx (1 hunks)
  • app/layout.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/layout.tsx (1)
app/clientLayout.tsx (1)
  • ClientLayout (17-47)
🔇 Additional comments (6)
app/clientLayout.tsx (4)

29-36: Route-keyed transitions correctly implemented

Using AnimatePresence with mode="wait" and initial={false} plus exit/enter opacity variants is a solid setup for smooth page fades.


25-25: Verify ThemeProvider configuration is intentional

attribute="class" with enableSystem={false} and defaultTheme="light" ignores OS preference. Confirm this is product-intended.


7-7: Import aligns with usage

usePathname import is correct for the route-keyed motion div.


12-12: Toaster placement looks good

Keeping Toaster within ThemeProvider (but outside the animated container) prevents remount on route changes and keeps it themed.

app/layout.tsx (2)

6-6: Global CSS import at the root is correct

Importing "./globals.css" here ensures it’s applied once at the app root, per Next.js App Router guidance.


21-28: HTML skeleton separation is clean

Shifting and into RootLayout and rendering as a sibling to is a solid separation of concerns. suppressHydrationWarning on is appropriate with client-side theming.

If you adopt applying the theme class on (next-themes default), this config should remain stable; confirm there’s no duplicate theme class handling elsewhere.

</html>
<AuthProvider>
<ThemeProvider attribute="class" defaultTheme="light" enableSystem={false} disableTransitionOnChange>
<div className={`${inter.className} flex min-h-screen flex-col bg-background`}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Apply the Inter font at the level to style portal content (e.g., Toaster)

Placing ${inter.className} on an inner div won’t affect portal-based UI (react-hot-toast renders to document.body), causing font inconsistency. Apply the font to in RootLayout and drop it from this div.

Follow-up diffs:

In app/layout.tsx (outside the shown changed lines, add import and font init):

import { Inter } from "next/font/google"
const inter = Inter({ subsets: ["latin"] })

Then within the changed block:

-  <body>
+  <body className={`${inter.className} min-h-screen bg-background antialiased`}>

In app/clientLayout.tsx (remove font from the inner container and the Inter usage here):

-import { Inter } from "next/font/google"
-const inter = Inter({ subsets: ["latin"] })
...
-        <div className={`${inter.className} flex min-h-screen flex-col bg-background`}>
+        <div className="flex min-h-screen flex-col bg-background">

This ensures consistent typography across the app, including toast notifications.

I can push a patch that applies these changes across both files if you prefer.

🤖 Prompt for AI Agents
In app/clientLayout.tsx at line 26, remove the `${inter.className}` from the
div's className to avoid applying the Inter font only to an inner container.
Instead, import and initialize the Inter font in app/layout.tsx and apply
`${inter.className}` to the <body> element there. This change ensures consistent
font styling across portal-based UI like react-hot-toast. Also, remove any Inter
font usage from app/clientLayout.tsx accordingly.

@Kavlin-Kaur
Copy link
Author

@yashvikram30 can u please assign me this and merge it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant