Skip to content

feat: add custom 404 error page#334

Open
JayRathore10 wants to merge 2 commits into
GitMetricsLab:mainfrom
JayRathore10:feat/add-custom-404-page
Open

feat: add custom 404 error page#334
JayRathore10 wants to merge 2 commits into
GitMetricsLab:mainfrom
JayRathore10:feat/add-custom-404-page

Conversation

@JayRathore10
Copy link
Copy Markdown

@JayRathore10 JayRathore10 commented May 19, 2026

Feat #333 — Add Custom 404 Error Page

Description

This PR adds a custom 404 error page to improve the user experience when navigating to invalid or non-existing routes within the application.

Changes Implemented

  • Added a dedicated Custom404 page component
  • Configured React Router wildcard route handling:
<Route path="*" element={<Custom404 />} />
  • Designed a modern and responsive UI using Tailwind CSS
  • Added a homepage redirect button for easier navigation
  • Improved invalid route handling behavior

Features

  • Responsive fullscreen layout
  • Gradient background styling
  • Mobile-friendly design
  • Smooth hover animations
  • Consistent UI with existing application styling

Testing

Verified by visiting invalid routes such as:

/random-page
/unknown-route
/test404

Confirmed:

  • Custom 404 page renders correctly
  • Wildcard route handling works as expected
  • Navigation back to homepage functions properly
  • Layout is responsive across devices

Closes #333


🏷️ Open Source Context

This PR is submitted as part of GSSoC (GirlScript Summer of Code) contribution.

👤 Contributor Profile
GSSoC Profile: https://gssoc.girlscript.org/profile/e47b2f4a-f3e9-4cb4-97b5-ddd8cb15a1e9

Screenshot

image

Summary by CodeRabbit

  • New Features

    • Added a 404 error page that displays when navigating to non-existent routes, with a link to return to the home page.
  • Documentation

    • Updated contribution guidelines with improved formatting and section organization.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 19, 2026

Deploy Preview for github-spy failed.

Name Link
🔨 Latest commit 52019cc
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a0ddfe766eb5e0008811ef6

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

This PR adds a dedicated custom 404 error page that renders when users navigate to non-existent routes. A new Custom404 component displays a "Page Not Found" message with a link back to the homepage, and is integrated into the router via a wildcard catch-all route. Contributing documentation formatting is also adjusted.

Changes

Custom 404 Page

Layer / File(s) Summary
404 page component
src/pages/404.tsx
New Custom404 React component renders a styled 404 page with message and navigation link to homepage.
Router integration
src/Routes/Router.tsx
Custom404 is imported and registered via wildcard route (path="*") to capture all unmatched navigation paths.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

A 404 once lived in the dark,
Lost routes and wanderers, missing their mark.
Now Custom captures all the lost souls,
Guiding them home with links toward their goals. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR contains a minor out-of-scope change: the CONTRIBUTING.md file was reformatted with spacing/layout adjustments unrelated to the 404 page feature. Remove the CONTRIBUTING.md formatting changes or move them to a separate PR to keep this PR focused on the custom 404 error page implementation.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a custom 404 error page component to the application.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering all key template sections including description, changes, testing, and issue closure.
Linked Issues check ✅ Passed The PR fully implements all coding requirements from issue #333: custom 404 component, wildcard route registration, Tailwind styling, responsive design, and homepage navigation button.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@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: 1

🧹 Nitpick comments (2)
src/Routes/Router.tsx (1)

24-27: ⚡ Quick win

Move the wildcard route to the end of the Routes block.

While React Router v6's path ranking ensures the /activity route will match correctly despite appearing after the wildcard, placing the catch-all path="*" route last is a best practice that improves readability and prevents confusion.

📍 Suggested reordering
       <Route path="/contributor/:username" element={<ContributorProfile />} />
-      <Route path="*" element={<Custom404 />} />
 
       {/* ✅ new route */}
       <Route path="/activity" element={<Activity />} />
+      <Route path="*" element={<Custom404 />} />
     </Routes>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Routes/Router.tsx` around lines 24 - 27, The wildcard route Route
path="*" element={<Custom404 />} is placed before the new Route path="/activity"
element={<Activity />}; move the catch-all Route (the one with
path="*"/Custom404) to the very end of the Routes block so all specific routes
like the /activity Route are listed before the wildcard for clarity and
best-practice ordering.
src/pages/404.tsx (1)

5-26: ⚡ Quick win

Consider adding dark mode support.

The linked issue #333 mentions "dark mode support if applicable." While the current light-mode implementation meets the core requirements, adding Tailwind dark: variants would improve consistency with the rest of the application if dark mode is supported elsewhere.

🌙 Suggested dark mode enhancement
-    <section className="min-h-screen w-full flex items-center justify-center bg-gradient-to-br from-gray-50 to-blue-100 px-6">
+    <section className="min-h-screen w-full flex items-center justify-center bg-gradient-to-br from-gray-50 to-blue-100 dark:from-gray-900 dark:to-gray-800 px-6">
       <div className="text-center">
-        <h1 className="text-7xl md:text-8xl font-extrabold text-blue-600 mb-4">
+        <h1 className="text-7xl md:text-8xl font-extrabold text-blue-600 dark:text-blue-400 mb-4">
           404
         </h1>
 
-        <h2 className="text-2xl md:text-3xl font-bold text-gray-900 mb-4">
+        <h2 className="text-2xl md:text-3xl font-bold text-gray-900 dark:text-gray-100 mb-4">
           Page Not Found
         </h2>
 
-        <p className="text-gray-600 text-lg mb-8 max-w-md">
+        <p className="text-gray-600 dark:text-gray-300 text-lg mb-8 max-w-md">
           The page you are looking for does not exist or has been moved.
         </p>
 
         <Link
           to="/"
-          className="inline-block bg-blue-600 text-white px-8 py-4 rounded-lg font-semibold hover:bg-blue-700 transition-all transform hover:scale-105 shadow-lg"
+          className="inline-block bg-blue-600 text-white px-8 py-4 rounded-lg font-semibold hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 transition-all transform hover:scale-105 shadow-lg"
         >
           Go Back Home
         </Link>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/404.tsx` around lines 5 - 26, Add Tailwind dark-mode variants to
the 404 page elements so the page respects the app's dark theme: update the
section, h1, h2, p and Link classNames (refer to the section element and the JSX
elements <h1>, <h2>, <p>, and <Link>) to include appropriate dark: classes
(e.g., dark:bg-*, dark:from-*, dark:to-*, dark:text-*, dark:hover:bg-*) that
invert the background gradient and switch text colors for dark mode while
preserving hover/transition styles; ensure contrast is maintained and the Link
button has a dark:hover:bg variant as well.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CONTRIBUTING.md`:
- Line 1: Leading spaces before Markdown headings cause MD023 failures; remove
the leading spaces so heading markers are left-aligned. Edit each indented
heading (e.g., " # 🌟 Contributing to GitHub Tracker" -> "# 🌟 Contributing to
GitHub Tracker") and the other reported headings (lines referenced in the
review) so the '#' appears at column 0 for each heading to satisfy the linter.

---

Nitpick comments:
In `@src/pages/404.tsx`:
- Around line 5-26: Add Tailwind dark-mode variants to the 404 page elements so
the page respects the app's dark theme: update the section, h1, h2, p and Link
classNames (refer to the section element and the JSX elements <h1>, <h2>, <p>,
and <Link>) to include appropriate dark: classes (e.g., dark:bg-*, dark:from-*,
dark:to-*, dark:text-*, dark:hover:bg-*) that invert the background gradient and
switch text colors for dark mode while preserving hover/transition styles;
ensure contrast is maintained and the Link button has a dark:hover:bg variant as
well.

In `@src/Routes/Router.tsx`:
- Around line 24-27: The wildcard route Route path="*" element={<Custom404 />}
is placed before the new Route path="/activity" element={<Activity />}; move the
catch-all Route (the one with path="*"/Custom404) to the very end of the Routes
block so all specific routes like the /activity Route are listed before the
wildcard for clarity and best-practice ordering.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06dc3225-c6e1-418b-a483-aa8546298784

📥 Commits

Reviewing files that changed from the base of the PR and between e2da6a6 and 52019cc.

📒 Files selected for processing (3)
  • CONTRIBUTING.md
  • src/Routes/Router.tsx
  • src/pages/404.tsx

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add Custom 404 Error Page

1 participant