Skip to content

Task Done#525

Merged
mehul-m-prajapati merged 1 commit into
GitMetricsLab:mainfrom
jeetvasoya21:#521
May 29, 2026
Merged

Task Done#525
mehul-m-prajapati merged 1 commit into
GitMetricsLab:mainfrom
jeetvasoya21:#521

Conversation

@jeetvasoya21
Copy link
Copy Markdown
Contributor

@jeetvasoya21 jeetvasoya21 commented May 25, 2026

Related Issue


Description

Implemented smooth theme transition animations across the UI to improve visual polish and enhance the user experience when toggling between light and dark modes.

Changes Made

  • Added smooth transition animations for theme changes
  • Applied consistent fade effects across UI components during mode switch
  • Configured animation timing for a responsive and polished interaction experience

Animation Details

  • Transition duration set to:

    300ms
  • The animation provides a smooth yet snappy feel when switching themes

User Experience Improvements

  • Eliminated abrupt visual changes between themes
  • Improved overall UI fluidity and responsiveness
  • Created a more cohesive dark/light mode interaction experience

How Has This Been Tested?

Theme Toggle Test

  1. Started the application locally
  2. Clicked the theme toggle button repeatedly
  3. Verified the entire UI transitions smoothly between light and dark modes
  4. Confirmed animations complete within 300ms without lag or flickering

UI Consistency Test

  • Checked transitions across multiple pages/components
  • Verified smooth fade effects are applied consistently throughout the interface

Screenshots (if applicable)

  • Added screen recordings demonstrating:

    • Smooth light-to-dark mode transition
    • Smooth dark-to-light mode transition
    • Consistent UI fade animations across components
theme_toggle.mp4

Type of Change

  • Code style update
  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Summary by CodeRabbit

Release Notes

  • New Features
    • Theme transitions are now animated with smooth visual effects. UI elements including colors, backgrounds, borders, and shadows gracefully transition when switching between light and dark modes.

Review Change Stack

The animation duration is set to 300ms for a smooth but snappy feel. Test it out by clicking the theme toggle—you should see the entire UI fade smoothly between light and dark modes!
@netlify
Copy link
Copy Markdown

netlify Bot commented May 25, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 63b33f0
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a146943f1f5920008c545e1
😎 Deploy Preview https://deploy-preview-525--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

📝 Walkthrough

Walkthrough

This PR adds smooth fade-in/fade-out animations during light/dark theme switches. A new 300ms transition duration is established in the context layer, global CSS rules trigger animations on theme-relevant properties, the ThemeContext temporarily applies a theme-transitioning class to trigger those animations, and the Navbar's toggle button icon rotates and scales in sync with the theme change.

Changes

Theme Transition Animation

Layer / File(s) Summary
Theme transition timing and CSS rules
src/context/ThemeContext.tsx, src/App.css
Introduces TRANSITION_DURATION constant (300ms) and defines CSS rules on html.theme-transitioning and descendants to animate background-color, color, border-color, and box-shadow with !important priority.
Context-level transition class toggle
src/context/ThemeContext.tsx
ThemeWrapper's useEffect applies the theme-transitioning class to document.documentElement before updating the dark class, then removes it after 300ms, with proper cleanup on effect re-run or unmount.
Navbar button animation
src/components/Navbar.tsx
Navbar adds isThemeToggling state and handleThemeToggle handler that resets after 300ms; both desktop and mobile theme toggle buttons now include conditional icon transform classes (rotate-180 scale-0 vs rotate-0 scale-100) and updated transition styling.

Sequence Diagram

sequenceDiagram
  participant User
  participant Navbar
  participant ThemeContext
  participant DOM as document.documentElement
  participant CSS as CSS Transitions
  User->>Navbar: Click theme toggle button
  Navbar->>Navbar: Set isThemeToggling=true
  Navbar->>ThemeContext: Call toggleTheme()
  ThemeContext->>DOM: Add theme-transitioning class
  ThemeContext->>DOM: Update dark class
  ThemeContext->>DOM: Persist to localStorage
  CSS->>CSS: Transition background, color, border, shadow
  Navbar->>Navbar: Icon rotates and scales during transition
  ThemeContext->>DOM: Remove theme-transitioning class after 300ms
  Navbar->>Navbar: Set isThemeToggling=false after 300ms
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • GitMetricsLab/github_tracker#330: Both PRs modify src/components/Navbar.tsx around the theme toggle UI/behavior (main PR adds isThemeToggling + handleThemeToggle/icon animation, while the retrieved PR reworks the navbar/theme-toggle markup and styling), so they overlap at the same code area.

Suggested labels

level:intermediate, quality:clean

Poem

🌙✨ Theme toggle blooms with grace,
Smooth transitions light the face,
Icons twirl and shadows dance,
Three hundred mills of elegance—
A rabbit-smooth CSS romance! 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'Task Done' is vague and generic, failing to convey any meaningful information about the changeset's primary purpose. Change title to something descriptive like 'Add smooth theme transition animations' or 'Implement 300ms theme toggle fade effect' to clearly communicate the main change.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is comprehensive and well-structured, covering all required sections including related issue, detailed changes, testing methodology, and appropriate type of change classification.
Linked Issues check ✅ Passed All coding objectives from issue #521 are met: smooth animated transitions implemented, fade transitions between themes with color interpolation applied, theme toggle icon animation added, and performance preserved.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #521: CSS theme transition styling, Navbar theme toggle animation state management, and ThemeContext transition class handling are all required for the enhancement.
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: 2

🧹 Nitpick comments (1)
src/App.css (1)

1-13: ⚡ Quick win

Respect reduced-motion preferences for global theme animation.

Line 6 applies transitions globally, but there’s no reduced-motion fallback. Add a prefers-reduced-motion: reduce override to disable/shorten these transitions.

♿ Proposed fix
 :root {
   --transition-duration: 300ms;
 }
 
 html.theme-transitioning,
 html.theme-transitioning * {
   transition: background-color var(--transition-duration) ease-in-out,
               color var(--transition-duration) ease-in-out,
               border-color var(--transition-duration) ease-in-out,
               box-shadow var(--transition-duration) ease-in-out !important;
 }
+
+@media (prefers-reduced-motion: reduce) {
+  html.theme-transitioning,
+  html.theme-transitioning * {
+    transition: none !important;
+  }
+}
🤖 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/App.css` around lines 1 - 13, The global theme-transition CSS applies
transitions via :root and html.theme-transitioning but does not respect users'
reduced-motion preference; add a media query for prefers-reduced-motion: reduce
that overrides --transition-duration to 0ms (or removes transitions) and/or
disables transitions on html.theme-transitioning and html.theme-transitioning *
so animations are suppressed for users who prefer reduced motion.
🤖 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 `@src/components/Navbar.tsx`:
- Line 4: The import list in Navbar.tsx includes an unused symbol "Github" which
causes ESLint errors; remove "Github" from the import statement (leaving the
other used icons Moon, Sun, Menu, X) so the file no longer imports an unused
identifier and linting passes.
- Around line 17-25: handleThemeToggle currently creates a new setTimeout on
every click which can race and fire after unmount; fix it by tracking the
timeout id in a ref (e.g., themeToggleTimeoutRef), clear any existing timeout
with clearTimeout before creating a new one, assign the new id to the ref, and
also clear the timeout in a useEffect cleanup to prevent it firing after
unmount; keep using setIsThemeToggling and toggleTheme but ensure the timeout
lifecycle is managed via the ref and cleanup.

---

Nitpick comments:
In `@src/App.css`:
- Around line 1-13: The global theme-transition CSS applies transitions via
:root and html.theme-transitioning but does not respect users' reduced-motion
preference; add a media query for prefers-reduced-motion: reduce that overrides
--transition-duration to 0ms (or removes transitions) and/or disables
transitions on html.theme-transitioning and html.theme-transitioning * so
animations are suppressed for users who prefer reduced motion.
🪄 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: 58a8bac2-7c45-4bd8-9c0e-abc2932f0b0f

📥 Commits

Reviewing files that changed from the base of the PR and between 6c6bc3e and 63b33f0.

📒 Files selected for processing (3)
  • src/App.css
  • src/components/Navbar.tsx
  • src/context/ThemeContext.tsx

Comment thread src/components/Navbar.tsx
import { useState, useContext } from "react";
import { useState, useContext, useRef } from "react";
import { ThemeContext } from "../context/ThemeContext";
import { Moon, Sun, Menu, X, Github } from "lucide-react";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove unused Github import to satisfy lint checks.

Line 4 imports Github but it isn’t used, and ESLint already flags this as an error.

🧹 Proposed fix
-import { Moon, Sun, Menu, X, Github } from "lucide-react";
+import { Moon, Sun, Menu, X } from "lucide-react";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { Moon, Sun, Menu, X, Github } from "lucide-react";
import { Moon, Sun, Menu, X } from "lucide-react";
🧰 Tools
🪛 ESLint

[error] 4-4: 'Github' is defined but never used.

(@typescript-eslint/no-unused-vars)

🤖 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/components/Navbar.tsx` at line 4, The import list in Navbar.tsx includes
an unused symbol "Github" which causes ESLint errors; remove "Github" from the
import statement (leaving the other used icons Moon, Sun, Menu, X) so the file
no longer imports an unused identifier and linting passes.

Comment thread src/components/Navbar.tsx
Comment on lines +17 to +25
const handleThemeToggle = () => {
setIsThemeToggling(true);
toggleTheme();

// Reset animation state after transition
setTimeout(() => {
setIsThemeToggling(false);
}, 300);
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify timeout lifecycle handling in Navbar theme toggle
rg -n -C2 'handleThemeToggle|setTimeout|clearTimeout|isThemeToggling|useEffect' src/components/Navbar.tsx

Repository: GitMetricsLab/github_tracker

Length of output: 2086


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="src/components/Navbar.tsx"

# Show the whole component header area (imports + state/refs + handleThemeToggle)
sed -n '1,120p' "$FILE"

# Check for any other usage of themeToggleRef in the file
echo "---- themeToggleRef usages ----"
rg -n "themeToggleRef" "$FILE" || true

Repository: GitMetricsLab/github_tracker

Length of output: 4204


Stabilize theme-toggle timer lifecycle to avoid animation race conditions.

handleThemeToggle schedules setTimeout on every click without clearing prior timers, so rapid clicks can set isThemeToggling to false too early; a pending timer can also fire after unmount.

⏱️ Proposed fix
-import { useState, useContext, useRef } from "react";
+import { useState, useContext, useRef, useEffect } from "react";
@@
-  const themeToggleRef = useRef<HTMLButtonElement>(null);
+  const themeToggleTimeoutRef = useRef<number | null>(null);
@@
   const handleThemeToggle = () => {
+    if (themeToggleTimeoutRef.current !== null) {
+      clearTimeout(themeToggleTimeoutRef.current);
+    }
     setIsThemeToggling(true);
     toggleTheme();
-    
-    // Reset animation state after transition
-    setTimeout(() => {
+
+    // Reset animation state after transition
+    themeToggleTimeoutRef.current = window.setTimeout(() => {
       setIsThemeToggling(false);
     }, 300);
   };
+
+  useEffect(() => {
+    return () => {
+      if (themeToggleTimeoutRef.current !== null) {
+        clearTimeout(themeToggleTimeoutRef.current);
+      }
+    };
+  }, []);
@@
-            ref={themeToggleRef}
             onClick={handleThemeToggle}
🤖 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/components/Navbar.tsx` around lines 17 - 25, handleThemeToggle currently
creates a new setTimeout on every click which can race and fire after unmount;
fix it by tracking the timeout id in a ref (e.g., themeToggleTimeoutRef), clear
any existing timeout with clearTimeout before creating a new one, assign the new
id to the ref, and also clear the timeout in a useEffect cleanup to prevent it
firing after unmount; keep using setIsThemeToggling and toggleTheme but ensure
the timeout lifecycle is managed via the ref and cleanup.

@mehul-m-prajapati mehul-m-prajapati merged commit 406d224 into GitMetricsLab:main May 29, 2026
7 checks passed
@github-actions
Copy link
Copy Markdown

🎉🎉 Thank you for your contribution! Your PR #525 has been merged! 🎉🎉

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.

Enhancement: Add Theme Transition Animation Between Light/Dark Mode

2 participants