feat: Remove Theme Switcher

- Update body class to use `dark` instead of `light` for dark mode
- Remove `ThemeSwitcher` component as it is no longer needed
- Update global CSS to set dark mode styles on the `.dark` class instead of `.light`
This commit is contained in:
AderKonstantin
2025-03-28 18:12:21 +03:00
parent f37572f0cf
commit 6c0243c5e2
4 changed files with 2 additions and 55 deletions

View File

@@ -18,6 +18,6 @@ body {
font-family: "JetBrains Mono", monospace;
}
.light {
.dark {
@apply bg-black text-white;
}

View File

@@ -31,7 +31,7 @@ export const metadata: Metadata = {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html className="dark" lang="en">
<body className={`bg-black text-white light:bg-white light:text-black font-sans`}>
<body className={`bg-black text-white dark:bg-white dark:text-black font-sans`}>
<div className="text-xl 2xl:mx-72 xl:mx-36 md:mx-6">
<MainHeader />
{children}

View File

@@ -1,50 +0,0 @@
'use client';
import { useState, useEffect } from 'react';
import Image from 'next/image';
import Link from 'next/link';
import moonPic from '@/public/moon.svg';
import sunPic from '@/public/sun.svg';
export function ThemeSwitcher() {
const [isLightMode, setIsLightMode] = useState(false);
// Initialize theme from localStorage or system preference
useEffect(() => {
const savedTheme = localStorage.getItem('theme');
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'light' || (!savedTheme && !systemPrefersDark)) {
setIsLightMode(true);
document.documentElement.classList.add('light');
}
}, []);
// Toggle theme and save preference
const toggleTheme = () => {
const newLightMode = !isLightMode;
setIsLightMode(newLightMode);
if (newLightMode) {
document.documentElement.classList.add('light');
localStorage.setItem('theme', 'light');
} else {
document.documentElement.classList.remove('light');
localStorage.setItem('theme', 'dark');
}
};
return (
<li className="theme-switcher inline">
<Link href="#" onClick={toggleTheme} className="block p-2">
<Image
src={isLightMode ? moonPic : sunPic}
alt={isLightMode ? 'Switch to dark mode' : 'Switch to light mode'}
width={32}
height={32}
className={`transition-all duration-300 ${isLightMode ? 'filter brightness-0 invert' : 'filter-none'}`}
/>
</Link>
</li>
);
}

View File

@@ -2,8 +2,6 @@
import Image from 'next/image';
import Link from 'next/link';
import { ThemeSwitcher } from './theme-switcher';
import globePic from '../../public/globe.svg';
import emailPic from '../../public/email.svg';
import rssPic from '../../public/rss-feed.svg';
@@ -20,7 +18,6 @@ export default function Toolbar() {
</div>
<div className="flex items-baseline">
<ul className="inline-flex items-center gap-4">
<ThemeSwitcher />
<li className="inline filter brightness-0 invert">
<Link href="#">
<Image