فهرست منبع

add dark theme

Daniel Bohry 3 هفته پیش
والد
کامیت
88ce4ab416
3فایلهای تغییر یافته به همراه218 افزوده شده و 39 حذف شده
  1. 193 39
      src/main/resources/static/css/main.css
  2. 8 0
      src/main/resources/static/index.html
  3. 17 0
      src/main/resources/static/js/main.js

+ 193 - 39
src/main/resources/static/css/main.css

@@ -1,3 +1,77 @@
+:root {
+    /* Light theme (default) */
+    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+    --container-bg: #ffffff;
+    --header-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+    --header-text: #ffffff;
+    --text-primary: #333333;
+    --text-secondary: #666666;
+    --tab-bg: #f8f9fa;
+    --tab-text: #666666;
+    --tab-active-text: #667eea;
+    --tab-active-bg: #ffffff;
+    --tab-border: #667eea;
+    --input-border: #e1e5e9;
+    --input-bg: #ffffff;
+    --input-text: #333333;
+    --input-focus-border: #667eea;
+    --input-focus-shadow: rgba(102, 126, 234, 0.1);
+    --button-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+    --button-text: #ffffff;
+    --button-hover-shadow: rgba(102, 126, 234, 0.3);
+    --button-disabled-bg: #cccccc;
+    --user-info-bg: #f8f9fa;
+    --user-details-bg: #ffffff;
+    --section-bg: #f8f9fa;
+    --section-border: #667eea;
+    --message-success-bg: #d4edda;
+    --message-success-text: #155724;
+    --message-success-border: #c3e6cb;
+    --message-error-bg: #f8d7da;
+    --message-error-text: #721c24;
+    --message-error-border: #f5c6cb;
+    --logout-btn-bg: #dc3545;
+    --logout-btn-hover: #c82333;
+    --border-color: #e1e5e9;
+}
+
+/* Dark theme */
+[data-theme="dark"] {
+    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
+    --container-bg: #2d3748;
+    --header-gradient: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
+    --header-text: #f7fafc;
+    --text-primary: #f7fafc;
+    --text-secondary: #cbd5e0;
+    --tab-bg: #4a5568;
+    --tab-text: #cbd5e0;
+    --tab-active-text: #90cdf4;
+    --tab-active-bg: #2d3748;
+    --tab-border: #90cdf4;
+    --input-border: #4a5568;
+    --input-bg: #1a202c;
+    --input-text: #f7fafc;
+    --input-focus-border: #90cdf4;
+    --input-focus-shadow: rgba(144, 205, 244, 0.1);
+    --button-gradient: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
+    --button-text: #ffffff;
+    --button-hover-shadow: rgba(66, 153, 225, 0.3);
+    --button-disabled-bg: #4a5568;
+    --user-info-bg: #4a5568;
+    --user-details-bg: #2d3748;
+    --section-bg: #4a5568;
+    --section-border: #90cdf4;
+    --message-success-bg: #22543d;
+    --message-success-text: #9ae6b4;
+    --message-success-border: #38a169;
+    --message-error-bg: #742a2a;
+    --message-error-text: #feb2b2;
+    --message-error-border: #e53e3e;
+    --logout-btn-bg: #e53e3e;
+    --logout-btn-hover: #c53030;
+    --border-color: #4a5568;
+}
+
 * {
     margin: 0;
     padding: 0;
@@ -6,28 +80,32 @@
 
 body {
     font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
-    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+    background: var(--bg-gradient);
     min-height: 100vh;
     display: flex;
     align-items: center;
     justify-content: center;
+    transition: background 0.3s ease;
 }
 
 .container {
-    background: white;
+    background: var(--container-bg);
     border-radius: 15px;
     box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
     overflow: hidden;
     width: 100%;
     max-width: 400px;
     margin: 20px;
+    transition: background 0.3s ease;
 }
 
 .header {
-    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-    color: white;
+    background: var(--header-gradient);
+    color: var(--header-text);
     text-align: center;
     padding: 30px 20px;
+    position: relative;
+    transition: background 0.3s ease, color 0.3s ease;
 }
 
 .header h1 {
@@ -40,9 +118,59 @@ body {
     font-size: 0.9rem;
 }
 
+/* Theme toggle button styles */
+.theme-toggle {
+    position: absolute;
+    top: 20px;
+    right: 20px;
+    background: rgba(255, 255, 255, 0.2);
+    border: 1px solid rgba(255, 255, 255, 0.3);
+    border-radius: 50%;
+    width: 40px;
+    height: 40px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    cursor: pointer;
+    transition: all 0.3s ease;
+    backdrop-filter: blur(10px);
+}
+
+.theme-toggle:hover {
+    background: rgba(255, 255, 255, 0.3);
+    transform: scale(1.1);
+}
+
+.theme-icon {
+    width: 18px;
+    height: 18px;
+    color: var(--header-text);
+    transition: opacity 0.3s ease;
+}
+
+/* Show sun icon in light theme (default) */
+.sun-icon {
+    opacity: 1;
+}
+
+.moon-icon {
+    opacity: 0;
+    position: absolute;
+}
+
+/* Show moon icon in dark theme */
+[data-theme="dark"] .sun-icon {
+    opacity: 0;
+}
+
+[data-theme="dark"] .moon-icon {
+    opacity: 1;
+}
+
 .tab-container {
     display: flex;
-    background: #f8f9fa;
+    background: var(--tab-bg);
+    transition: background 0.3s ease;
 }
 
 .tab {
@@ -51,15 +179,15 @@ body {
     text-align: center;
     cursor: pointer;
     font-weight: 500;
-    color: #666;
+    color: var(--tab-text);
     border-bottom: 3px solid transparent;
     transition: all 0.3s ease;
 }
 
 .tab.active {
-    color: #667eea;
-    border-bottom-color: #667eea;
-    background: white;
+    color: var(--tab-active-text);
+    border-bottom-color: var(--tab-border);
+    background: var(--tab-active-bg);
 }
 
 .form-container {
@@ -81,30 +209,33 @@ body {
 .form-group label {
     display: block;
     margin-bottom: 8px;
-    color: #333;
+    color: var(--text-primary);
     font-weight: 500;
+    transition: color 0.3s ease;
 }
 
 .form-group input {
     width: 100%;
     padding: 12px 15px;
-    border: 2px solid #e1e5e9;
+    border: 2px solid var(--input-border);
     border-radius: 8px;
     font-size: 1rem;
+    background: var(--input-bg);
+    color: var(--input-text);
     transition: all 0.3s ease;
 }
 
 .form-group input:focus {
     outline: none;
-    border-color: #667eea;
-    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
+    border-color: var(--input-focus-border);
+    box-shadow: 0 0 0 3px var(--input-focus-shadow);
 }
 
 .submit-btn {
     width: 100%;
     padding: 12px;
-    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-    color: white;
+    background: var(--button-gradient);
+    color: var(--button-text);
     border: none;
     border-radius: 8px;
     font-size: 1rem;
@@ -115,11 +246,11 @@ body {
 
 .submit-btn:hover {
     transform: translateY(-2px);
-    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
+    box-shadow: 0 5px 15px var(--button-hover-shadow);
 }
 
 .submit-btn:disabled {
-    background: #ccc;
+    background: var(--button-disabled-bg);
     cursor: not-allowed;
     transform: none;
     box-shadow: none;
@@ -134,22 +265,25 @@ body {
 }
 
 .message.success {
-    background: #d4edda;
-    color: #155724;
-    border: 1px solid #c3e6cb;
+    background: var(--message-success-bg);
+    color: var(--message-success-text);
+    border: 1px solid var(--message-success-border);
+    transition: all 0.3s ease;
 }
 
 .message.error {
-    background: #f8d7da;
-    color: #721c24;
-    border: 1px solid #f5c6cb;
+    background: var(--message-error-bg);
+    color: var(--message-error-text);
+    border: 1px solid var(--message-error-border);
+    transition: all 0.3s ease;
 }
 
 .user-info {
     display: none;
     padding: 20px;
-    background: #f8f9fa;
-    border-top: 1px solid #e1e5e9;
+    background: var(--user-info-bg);
+    border-top: 1px solid var(--border-color);
+    transition: all 0.3s ease;
 }
 
 .user-info.active {
@@ -157,33 +291,38 @@ body {
 }
 
 .user-details {
-    background: white;
+    background: var(--user-details-bg);
     padding: 15px;
     border-radius: 8px;
     margin-bottom: 15px;
+    transition: background 0.3s ease;
 }
 
 .user-details h3 {
-    color: #333;
+    color: var(--text-primary);
     margin-bottom: 10px;
+    transition: color 0.3s ease;
 }
 
 .user-details p {
     margin: 5px 0;
-    color: #666;
+    color: var(--text-secondary);
+    transition: color 0.3s ease;
 }
 
 .change-password-section {
-    background: white;
+    background: var(--user-details-bg);
     padding: 20px;
     border-radius: 8px;
     margin-bottom: 15px;
+    transition: background 0.3s ease;
 }
 
 .change-password-section h3 {
-    color: #333;
+    color: var(--text-primary);
     margin-bottom: 15px;
     font-size: 1.1rem;
+    transition: color 0.3s ease;
 }
 
 .action-buttons {
@@ -193,8 +332,8 @@ body {
 .action-btn {
     width: 100%;
     padding: 12px;
-    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-    color: white;
+    background: var(--button-gradient);
+    color: var(--button-text);
     border: none;
     border-radius: 8px;
     font-size: 0.95rem;
@@ -205,7 +344,7 @@ body {
 
 .action-btn:hover {
     transform: translateY(-1px);
-    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
+    box-shadow: 0 4px 12px var(--button-hover-shadow);
 }
 
 .form-buttons {
@@ -222,8 +361,8 @@ body {
 .logout-btn {
     width: 100%;
     padding: 10px;
-    background: #dc3545;
-    color: white;
+    background: var(--logout-btn-bg);
+    color: var(--button-text);
     border: none;
     border-radius: 8px;
     font-size: 0.9rem;
@@ -232,7 +371,7 @@ body {
 }
 
 .logout-btn:hover {
-    background: #c82333;
+    background: var(--logout-btn-hover);
 }
 
 .loading {
@@ -253,18 +392,33 @@ body {
 .profile-section, .security-section {
     margin-bottom: 25px;
     padding: 15px;
-    background: #f8f9fa;
+    background: var(--section-bg);
     border-radius: 8px;
-    border-left: 3px solid #667eea;
+    border-left: 3px solid var(--section-border);
+    transition: all 0.3s ease;
 }
 
 .profile-section h4, .security-section h4 {
     margin: 0 0 15px 0;
-    color: #333;
+    color: var(--text-primary);
     font-size: 1rem;
     font-weight: 600;
+    transition: color 0.3s ease;
 }
 
 .forgot-password-link {
     margin-top: 10px;
+    text-align: center;
+}
+
+.forgot-password-link a {
+    color: var(--tab-active-text);
+    text-decoration: none;
+    font-size: 0.9rem;
+    transition: all 0.3s ease;
+}
+
+.forgot-password-link a:hover {
+    color: var(--input-focus-border);
+    text-decoration: underline;
 }

+ 8 - 0
src/main/resources/static/index.html

@@ -10,6 +10,14 @@
     <div class="container">
         <div class="header">
             <h1>Auth Service</h1>
+            <button class="theme-toggle" id="themeToggle" onclick="toggleTheme()" title="Switch theme">
+                <svg class="theme-icon sun-icon" viewBox="0 0 24 24" fill="currentColor">
+                    <path d="M12 2.25a.75.75 0 01.75.75v2.25a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM7.5 12a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0zM18.894 6.166a.75.75 0 00-1.06-1.06l-1.591 1.59a.75.75 0 101.06 1.061l1.591-1.59zM21.75 12a.75.75 0 01-.75.75h-2.25a.75.75 0 010-1.5H21a.75.75 0 01.75.75zM17.834 18.894a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 10-1.061 1.06l1.59 1.591zM12 18a.75.75 0 01.75.75V21a.75.75 0 01-1.5 0v-2.25A.75.75 0 0112 18zM7.758 17.303a.75.75 0 00-1.061-1.06l-1.591 1.59a.75.75 0 001.06 1.061l1.591-1.59zM6 12a.75.75 0 01-.75.75H3a.75.75 0 010-1.5h2.25A.75.75 0 016 12zM6.697 7.757a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 00-1.061 1.06l1.59 1.591z"/>
+                </svg>
+                <svg class="theme-icon moon-icon" viewBox="0 0 24 24" fill="currentColor">
+                    <path d="M9.528 1.718a.75.75 0 01.162.819A8.97 8.97 0 009 6a9 9 0 009 9 8.97 8.97 0 003.463-.69.75.75 0 01.981.98 10.503 10.503 0 01-9.694 6.46c-5.799 0-10.5-4.701-10.5-10.5 0-4.368 2.667-8.112 6.46-9.694a.75.75 0 01.818.162z"/>
+                </svg>
+            </button>
         </div>
 
         <div id="authSection">

+ 17 - 0
src/main/resources/static/js/main.js

@@ -2,6 +2,20 @@ const API_BASE_URL = '/api';
 let currentUser = null;
 let resetToken = null;
 
+// Theme management
+function initializeTheme() {
+    const savedTheme = localStorage.getItem('theme') || 'light';
+    document.documentElement.setAttribute('data-theme', savedTheme);
+}
+
+function toggleTheme() {
+    const currentTheme = document.documentElement.getAttribute('data-theme') || 'light';
+    const newTheme = currentTheme === 'light' ? 'dark' : 'light';
+
+    document.documentElement.setAttribute('data-theme', newTheme);
+    localStorage.setItem('theme', newTheme);
+}
+
 function parseURLParams() {
     const urlParams = new URLSearchParams(window.location.search);
     const hasResetFlag = urlParams.has('reset-password');
@@ -14,6 +28,9 @@ function parseURLParams() {
 }
 
 document.addEventListener('DOMContentLoaded', function() {
+    // Initialize theme before anything else
+    initializeTheme();
+
     const urlInfo = parseURLParams();
 
     if (urlInfo.isResetMode) {