From bae5afa73fc3476a44ad3d06c91bdc3e1e394483 Mon Sep 17 00:00:00 2001 From: Johannes Date: Sun, 14 Sep 2025 17:18:01 +0200 Subject: [PATCH] feat: Add admin toggle and dark mode to login page - Add admin toggle switch to switch between user/admin login modes - Implement dark mode toggle button in top-right corner - Style dark mode toggle with adaptive colors and hover effects Enhances login page with flexible authentication modes and improved visual customization options for better user experience. --- frontend/src/pages/LoginPage.js | 105 ++++++++++++++++++++++++++++---- 1 file changed, 94 insertions(+), 11 deletions(-) diff --git a/frontend/src/pages/LoginPage.js b/frontend/src/pages/LoginPage.js index 9cf067a..4cf2aa2 100644 --- a/frontend/src/pages/LoginPage.js +++ b/frontend/src/pages/LoginPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import { Form, Input, Button, Typography, Alert, message } from 'antd'; -import { LockOutlined, UserOutlined } from '@ant-design/icons'; +import { Form, Input, Button, Typography, Alert, message, Switch } from 'antd'; +import { LockOutlined, UserOutlined, SettingOutlined, SunOutlined, MoonOutlined } from '@ant-design/icons'; import { preserveFullUrl } from '../utils/urlUtils'; const { Title } = Typography; @@ -9,7 +9,30 @@ const { Title } = Typography; export default function LoginPage({ onLogin }) { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); - const darkMode = typeof window !== 'undefined' && localStorage.getItem('darkMode') === 'true'; + const [isAdminMode, setIsAdminMode] = useState(false); + const [darkMode, setDarkMode] = useState( + typeof window !== 'undefined' && localStorage.getItem('darkMode') === 'true' + ); + + const toggleDarkMode = () => { + const newDarkMode = !darkMode; + setDarkMode(newDarkMode); + localStorage.setItem('darkMode', newDarkMode.toString()); + + // Update HTML class for immediate visual feedback + const htmlElement = document.documentElement; + const bodyElement = document.body; + + if (newDarkMode) { + htmlElement.classList.add('dark-mode'); + htmlElement.style.backgroundColor = '#181818'; + bodyElement.style.backgroundColor = '#181818'; + } else { + htmlElement.classList.remove('dark-mode'); + htmlElement.style.backgroundColor = '#f5f5f5'; + bodyElement.style.backgroundColor = '#f5f5f5'; + } + }; const onFinish = async (values) => { setLoading(true); @@ -53,8 +76,27 @@ export default function LoginPage({ onLogin }) { display: 'flex', alignItems: 'center', justifyContent: 'center', + position: 'relative' }} > + {/* Dark Mode Toggle in der oberen rechten Ecke */} +