From 7915a913c925d5cf3bc9b6f912ed8be673135463 Mon Sep 17 00:00:00 2001
From: xmanrui <841206367@qq.com>
Date: Mon, 23 Feb 2026 07:09:45 +0800
Subject: [PATCH] feat: add dark/light theme toggle
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Add light theme CSS variables in globals.css
- Create ThemeProvider with localStorage persistence (lib/theme.tsx)
- Add ThemeSwitcher button (☀️/🌙) to sidebar
- Wrap app with ThemeProvider in providers.tsx
---
app/globals.css | 12 +++++++++
app/providers.tsx | 7 +++++-
app/sidebar.tsx | 2 ++
lib/theme.tsx | 62 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+), 1 deletion(-)
create mode 100644 lib/theme.tsx
diff --git a/app/globals.css b/app/globals.css
index 571302f..c25300b 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -12,6 +12,18 @@
--orange: #fb923c;
}
+[data-theme="light"] {
+ --bg: #f8fafc;
+ --card: #ffffff;
+ --border: #e2e8f0;
+ --text: #0f172a;
+ --text-muted: #64748b;
+ --accent: #0284c7;
+ --accent2: #7c3aed;
+ --green: #16a34a;
+ --orange: #ea580c;
+}
+
body {
background: var(--bg);
color: var(--text);
diff --git a/app/providers.tsx b/app/providers.tsx
index 418faa2..421abe1 100644
--- a/app/providers.tsx
+++ b/app/providers.tsx
@@ -1,8 +1,13 @@
"use client";
import { I18nProvider } from "@/lib/i18n";
+import { ThemeProvider } from "@/lib/theme";
import { ReactNode } from "react";
export function Providers({ children }: { children: ReactNode }) {
- return {children};
+ return (
+
+ {children}
+
+ );
}
diff --git a/app/sidebar.tsx b/app/sidebar.tsx
index 1bda7cc..3cd8925 100644
--- a/app/sidebar.tsx
+++ b/app/sidebar.tsx
@@ -4,6 +4,7 @@ import { useState } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useI18n, LanguageSwitcher } from "@/lib/i18n";
+import { ThemeSwitcher } from "@/lib/theme";
const NAV_ITEMS = [
{
@@ -65,6 +66,7 @@ export function Sidebar() {
+