Skip to content

Commit d0c5107

Browse files
authored
Theme changing transition added. (JhaSourav07#1878)
## Description Fixes JhaSourav07#1334 ## Pillar - [x] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [ ] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview https://github.com/user-attachments/assets/31037add-80cf-4d81-a537-84394e6b9f9b ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [x] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents b7031f5 + 20e75f3 commit d0c5107

4 files changed

Lines changed: 615 additions & 25 deletions

File tree

β€Žapp/components/navbar.tsxβ€Ž

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react';
44
import Link from 'next/link';
55
import { Menu, X, Activity, Moon, Sun } from 'lucide-react';
66
import { useGlowEffect } from '@/hooks/useGlowEffect';
7+
import { useThemeToggle } from './theme-switch';
78

89
function GithubMark() {
910
return (
@@ -28,31 +29,13 @@ const NAV_LINKS = [
2829

2930
export default function Navbar() {
3031
const [open, setOpen] = useState(false);
31-
const [mounted, setMounted] = useState(false);
32-
33-
const [isDark, setIsDark] = useState(() => {
34-
if (typeof window === 'undefined' || !window.localStorage) return true;
35-
return window.localStorage.getItem('theme') !== 'light';
36-
});
3732

3833
const { shellRef, shellVars, handleMouseEnter, handleMouseMove, handleMouseLeave } =
3934
useGlowEffect();
40-
41-
useEffect(() => {
42-
// eslint-disable-next-line react-hooks/set-state-in-effect
43-
setMounted(true);
44-
}, []);
45-
46-
useEffect(() => {
47-
document.documentElement.classList.toggle('dark', isDark);
48-
if (typeof window !== 'undefined' && window.localStorage) {
49-
window.localStorage.setItem('theme', isDark ? 'dark' : 'light');
50-
}
51-
}, [isDark]);
52-
53-
const toggleTheme = () => {
54-
setIsDark((prev) => !prev);
55-
};
35+
const { isDark, mounted, toggleTheme } = useThemeToggle({
36+
variant: 'circle',
37+
start: 'top-right',
38+
});
5639

5740
useEffect(() => {
5841
const mediaQuery = window.matchMedia('(min-width: 768px)');

0 commit comments

Comments
Β (0)