From da80b5d444360ad303a4079cc8bade90ddd74411 Mon Sep 17 00:00:00 2001 From: MHR81 Date: Thu, 25 Dec 2025 13:58:06 +0330 Subject: [PATCH] color palette --- src/App.jsx | 11 ++ src/components/ToggleTheme.jsx | 11 ++ src/components/layout/Header/header.jsx | 30 ++-- src/components/layout/Sidebar/sidebar.jsx | 170 ++++++++++---------- src/pages/CafeManagement/CafeManagement.jsx | 8 +- src/pages/CafeManagement/EditCafe.jsx | 16 +- src/pages/Login/Login.jsx | 30 ++-- src/styles/index.css | 105 ++++++++++++ 8 files changed, 254 insertions(+), 127 deletions(-) create mode 100644 src/components/ToggleTheme.jsx diff --git a/src/App.jsx b/src/App.jsx index 0bcb932..02edb33 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,6 +1,17 @@ import AppRoutes from "./routes/routes"; +import { useEffect } from "react"; function App() { + + const checkTheme = () => { + if (localStorage.theme ? (localStorage.theme === "dark") : (window.matchMedia("(prefers-color-scheme: dark)").matches)) { + document.documentElement.classList.add("dark"); + } + }; + + useEffect(() => { + checkTheme(); + }, []); return ( ); diff --git a/src/components/ToggleTheme.jsx b/src/components/ToggleTheme.jsx new file mode 100644 index 0000000..42d3def --- /dev/null +++ b/src/components/ToggleTheme.jsx @@ -0,0 +1,11 @@ +export default function toggleTheme() { + const html = document.documentElement; + + if (html.classList.contains("dark")) { + html.classList.remove("dark"); + localStorage.theme = "light"; + } else { + html.classList.add("dark"); + localStorage.theme = "dark"; + } +} diff --git a/src/components/layout/Header/header.jsx b/src/components/layout/Header/header.jsx index 3064c37..b4834de 100644 --- a/src/components/layout/Header/header.jsx +++ b/src/components/layout/Header/header.jsx @@ -29,26 +29,34 @@ import Search from "../../../assets/icons/search.svg"; import Arrow from "../../../assets/icons/arrow.svg"; import Vector7 from "../../../assets/icons/Vector7.svg"; import Pic from "../../../assets/icons/pic.png"; +import toggleTheme from "../../ToggleTheme"; const Header = ({ title }) => { return ( -
+
{/*

{title}

*/}
-
+
search
- -
- user -

سارا راد

- arrow -
- - vector +
-
+ +
+ user +

سارا راد

+ arrow +
+ + vector + +
); }; diff --git a/src/components/layout/Sidebar/sidebar.jsx b/src/components/layout/Sidebar/sidebar.jsx index 42a9cac..d6f62e9 100644 --- a/src/components/layout/Sidebar/sidebar.jsx +++ b/src/components/layout/Sidebar/sidebar.jsx @@ -6,6 +6,42 @@ import { PiCoffee } from "react-icons/pi"; import { HiOutlineLogout } from "react-icons/hi"; import { FiMenu, FiX } from "react-icons/fi"; +const SIDEBAR = { + logo: LogoDM, + navigation: [ + { + id: 'dashboard', + path: '/dashboard', + icon: BiBarChartAlt2, + label: 'داشبورد', + }, + { + id: 'cafe-management', + path: '/cafe-management', + icon: PiCoffee, + label: 'مدیریت کافه ها', + }, + { + id: 'stats', + path: '/stats', + icon: AiOutlinePieChart, + label: 'آمار و تحلیل', + }, + ], + logout: { + icon: HiOutlineLogout, + label: 'خروج', + }, + styles: { + activeColor: '#7F4629', + inactiveColor: '#402E32', + borderColor: '#D9CAB3', + padding: 'p-2.5', + gap: 'gap-2.5', + rounded: 'rounded-lg', + }, +}; + export default function Sidebar({ className, isOpen, setIsOpen }) { const location = useLocation(); const navigate = useNavigate(); @@ -19,9 +55,6 @@ export default function Sidebar({ className, isOpen, setIsOpen }) { localStorage.removeItem('token'); localStorage.removeItem('adminInfo'); - console.log('Tokens cleared from localStorage'); - console.log('Current token:', localStorage.getItem('token')); - navigate('/login'); } catch (error) { console.error('Logout error:', error); @@ -31,11 +64,46 @@ export default function Sidebar({ className, isOpen, setIsOpen }) { const closeSidebar = () => setIsOpen(false); + const renderNavItem = (item) => { + const Icon = item.icon; + const active = isActive(item.path); + + return ( + + + + {item.label} + + + ); + }; + return ( <> diff --git a/src/pages/CafeManagement/CafeManagement.jsx b/src/pages/CafeManagement/CafeManagement.jsx index 6534104..d065d56 100644 --- a/src/pages/CafeManagement/CafeManagement.jsx +++ b/src/pages/CafeManagement/CafeManagement.jsx @@ -43,7 +43,7 @@ const CafeManagement = () => { if (loading) { return (
-
در حال بارگذاری...
+
در حال بارگذاری...
); } @@ -112,7 +112,7 @@ const CafeManagement = () => { ادیت @@ -153,7 +153,7 @@ const CafeManagement = () => { ادیت کافه @@ -169,7 +169,7 @@ const CafeManagement = () => {
{/* بخش دکمه اضافه کردن */}
- diff --git a/src/pages/CafeManagement/EditCafe.jsx b/src/pages/CafeManagement/EditCafe.jsx index 932fbc7..9739285 100644 --- a/src/pages/CafeManagement/EditCafe.jsx +++ b/src/pages/CafeManagement/EditCafe.jsx @@ -161,7 +161,7 @@ export default function EditCafe() { if (loading) { return (
-
در حال بارگذاری...
+
در حال بارگذاری...
); } @@ -213,11 +213,11 @@ export default function EditCafe() {
-
@@ -279,7 +279,7 @@ export default function EditCafe() {

دسته‌بندی‌ها

@@ -323,7 +323,7 @@ export default function EditCafe() { <> handleEditCategory(idx)} - className="text-[#7f4629] cursor-pointer hover:text-[#5f494f] w-4 h-4 ml-1" + className="text-button1 cursor-pointer hover:text-[#5f494f] w-4 h-4 ml-1" title="ویرایش" /> setIsAddingCategory(true)} - className="flex-shrink-0 text-[#7f4629] hover:text-[#5f494f] font-bold text-sm md:text-base transition-colors whitespace-nowrap" + className="flex-shrink-0 text-button1 hover:text-[#5f494f] font-bold text-sm md:text-base transition-colors whitespace-nowrap" > + افزودن @@ -369,7 +369,7 @@ export default function EditCafe() { value={newCategory} onChange={(e) => setNewCategory(e.target.value)} placeholder="دسته جدید" - className="border-2 border-[#bb8f70] rounded-lg px-2 py-1 text-xs md:text-sm focus:outline-none focus:border-[#7f4629] min-w-[100px]" + className="border-2 border-[#bb8f70] rounded-lg px-2 py-1 text-xs md:text-sm focus:outline-none focus:border-button1 min-w-[100px]" autoFocus /> diff --git a/src/pages/Login/Login.jsx b/src/pages/Login/Login.jsx index 9de7c6c..393a84f 100644 --- a/src/pages/Login/Login.jsx +++ b/src/pages/Login/Login.jsx @@ -71,7 +71,7 @@ export default function Login() {
Logo
- @@ -85,15 +85,15 @@ export default function Login() {
{/* Center Links (Hidden on Mobile) */} -
@@ -109,7 +109,7 @@ export default function Login() { backgroundPosition: 'center', backgroundAttachment: 'fixed' }} - className="w-full md:w-1/2 flex items-start justify-center md:justify-start md:bg-[#f5f0e8] px-4 md:px-12 lg:px-24 py-8 md:py-16 relative"> + className="w-full md:w-1/2 flex items-start justify-center md:justify-start md:bg-background px-4 md:px-12 lg:px-24 py-8 md:py-16 relative"> {/* Dark Overlay */}
@@ -122,7 +122,7 @@ export default function Login() { {/* Header */}
-

ورود ادمین

+

ورود ادمین

دسترسی ویژه برای مدیریت و گزارش‌ها

@@ -137,14 +137,14 @@ export default function Login() { {/* Username Field */}
- +
setUserName(e.target.value)} placeholder="userName" - className="w-full pl-12 pr-4 py-3 border-2 bg-[#f5f0e8] border-gray-300 rounded-xl focus:outline-none focus:border-[#7f4629] transition-colors text-sm" + className="w-full pl-12 pr-4 py-3 border-2 bg-background border-gray-300 rounded-xl focus:outline-none focus:border-button1 transition-colors text-sm" dir="ltr" required /> @@ -154,14 +154,14 @@ export default function Login() { {/* Password Field */}
- +
setPassword(e.target.value)} placeholder="password" - className="w-full pl-12 pr-4 py-3 border-2 bg-[#f5f0e8] border-gray-300 rounded-xl focus:outline-none focus:border-[#7f4629] transition-colors text-sm" + className="w-full pl-12 pr-4 py-3 border-2 bg-background border-gray-300 rounded-xl focus:outline-none focus:border-button1 transition-colors text-sm" dir="ltr" required /> @@ -171,7 +171,7 @@ export default function Login() { {/* Forgot Password */} @@ -180,7 +180,7 @@ export default function Login() { diff --git a/src/styles/index.css b/src/styles/index.css index 181bab5..1863831 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -1,4 +1,48 @@ @import "tailwindcss"; +@custom-variant dark (&:where(.dark, .dark *)); + +:root { + --color-primary: #7f4629; + --color-button1: #99582a; + + --color-header: #f3efe7; + --color-header2: #e6dbcc; + + --color-sidebar: #efeeee; + + --color-background: #fdf8f4; + + + --font-sans: "Vazirmatn", system-ui, sans-serif; +} + +.dark { + --color-primary: #d9cab3; + --color-button1: #99582a; + + --color-header: #342e2c; + --color-header2: #5e5450; + + --color-sidebar: #564c49; + + --color-background: #272322; +} + +html { + font-family: var(--font-sans); +} + +body { + background-color: var(--background); + color: var(--foreground); + line-height: 1.6; + /* فاصله مناسب خطوط متن */ + -webkit-font-smoothing: antialiased; + /* نرم‌تر شدن فونت */ + text-rendering: optimizeLegibility; + /* خوانایی بهتر متن */ +} + @font-face { font-family: "MyEstedad"; @@ -10,6 +54,33 @@ @theme { --font-MyEstedad: "MyEstedad", sans-serif; + + --color-primary: var(--color-primary); + --color-header: var(--color-header); + --color-sidebar: var(--color-sidebar); + --color-background: var(--color-background); + + --color-button1: var(--color-button1); + + /* --color-text1: var(--color-text1-menu-and-card); + --color-text2: var(--color-text2); + --color-text3: var(--color-text3); + --color-text4: var(--color-text4); + + --color-btn1: var(--color-button1); + --color-btn2: var(--color-button2); + --color-btn3: var(--color-button3); + + --color-primary1: var(--color-primary1); + --color-primary2: var(--color-primary2); + --color-primary3: var(--color-primary3); + --color-primary4: var(--color-primary4); + --color-primary5-dark: var(--color-primary5-dark); + --color-primary6-dark: var(--color-primary6-dark); + + + --color-bg-light: var(--color-background-light); + --color-bg-dark: var(--color-background-dark); */ } @layer base { @@ -22,4 +93,38 @@ font-family: var(--font-MyEstedad); direction: rtl; } +} + + + +*::before, +*::after { + margin: 0; + padding: 0; + box-sizing: border-box; +} + + +/* دکمه‌ها فونت پروژه رو بگیرن */ +button { + font-family: inherit; + cursor: pointer; +} + +/* تصاویر و مدیاها ریسپانسیو باشن */ +img, +picture, +video, +canvas, +svg { + display: block; + max-width: 100%; +} + +/* رنگ انتخاب متن (drag select) */ +::selection { + background-color: var(--primary-200); + /* بک‌گراند انتخاب */ + color: var(--primary-foreground); + /* رنگ متن انتخاب */ } \ No newline at end of file