Spaces:
Running
Running
add dark mode toggel button and make color looks good
Browse files- index.html +9 -3
- script.js +42 -2
- style.css +25 -1
index.html
CHANGED
|
@@ -6,7 +6,10 @@
|
|
| 6 |
<title>AuthFlow Groove | Login</title>
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
-
<script
|
|
|
|
|
|
|
|
|
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
<script>
|
| 12 |
tailwind.config = {
|
|
@@ -31,9 +34,12 @@
|
|
| 31 |
}
|
| 32 |
</script>
|
| 33 |
</head>
|
| 34 |
-
<body class="min-h-full bg-gradient-to-br from-primary-50 to-secondary-50 flex items-center justify-center p-4">
|
|
|
|
|
|
|
|
|
|
| 35 |
<main class="w-full max-w-md">
|
| 36 |
-
|
| 37 |
<!-- Auth Header -->
|
| 38 |
<div class="bg-gradient-to-r from-primary-500 to-secondary-500 p-8 text-center">
|
| 39 |
<i data-feather="lock" class="w-12 h-12 mx-auto text-white"></i>
|
|
|
|
| 6 |
<title>AuthFlow Groove | Login</title>
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script>
|
| 10 |
+
tailwind.config = {
|
| 11 |
+
darkMode: 'class',
|
| 12 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 13 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 14 |
<script>
|
| 15 |
tailwind.config = {
|
|
|
|
| 34 |
}
|
| 35 |
</script>
|
| 36 |
</head>
|
| 37 |
+
<body class="min-h-full bg-gradient-to-br from-primary-50 to-secondary-50 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center p-4">
|
| 38 |
+
<button id="themeToggle" class="absolute top-4 right-4 p-2 rounded-lg bg-white dark:bg-gray-800 shadow-md">
|
| 39 |
+
<i data-feather="moon" class="text-gray-700 dark:text-yellow-300"></i>
|
| 40 |
+
</button>
|
| 41 |
<main class="w-full max-w-md">
|
| 42 |
+
<div class="bg-white rounded-2xl shadow-xl overflow-hidden">
|
| 43 |
<!-- Auth Header -->
|
| 44 |
<div class="bg-gradient-to-r from-primary-500 to-secondary-500 p-8 text-center">
|
| 45 |
<i data-feather="lock" class="w-12 h-12 mx-auto text-white"></i>
|
script.js
CHANGED
|
@@ -1,7 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
document.addEventListener('DOMContentLoaded', function() {
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
const loginForm = document.querySelector('form');
|
| 4 |
-
|
| 5 |
loginForm.addEventListener('submit', function(e) {
|
| 6 |
e.preventDefault();
|
| 7 |
|
|
|
|
| 1 |
+
|
| 2 |
+
// Theme toggle functionality
|
| 3 |
+
function initTheme() {
|
| 4 |
+
const themeToggle = document.getElementById('themeToggle');
|
| 5 |
+
const moonIcon = themeToggle.querySelector('i');
|
| 6 |
+
|
| 7 |
+
// Check for saved theme or prefer-color-scheme
|
| 8 |
+
const savedTheme = localStorage.getItem('theme') ||
|
| 9 |
+
(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
| 10 |
+
|
| 11 |
+
if (savedTheme === 'dark') {
|
| 12 |
+
document.documentElement.classList.add('dark');
|
| 13 |
+
moonIcon.setAttribute('data-feather', 'sun');
|
| 14 |
+
} else {
|
| 15 |
+
document.documentElement.classList.remove('dark');
|
| 16 |
+
moonIcon.setAttribute('data-feather', 'moon');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
// Toggle theme on button click
|
| 20 |
+
themeToggle.addEventListener('click', () => {
|
| 21 |
+
if (document.documentElement.classList.contains('dark')) {
|
| 22 |
+
document.documentElement.classList.remove('dark');
|
| 23 |
+
localStorage.setItem('theme', 'light');
|
| 24 |
+
moonIcon.setAttribute('data-feather', 'moon');
|
| 25 |
+
} else {
|
| 26 |
+
document.documentElement.classList.add('dark');
|
| 27 |
+
localStorage.setItem('theme', 'dark');
|
| 28 |
+
moonIcon.setAttribute('data-feather', 'sun');
|
| 29 |
+
}
|
| 30 |
+
feather.replace();
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
document.addEventListener('DOMContentLoaded', function() {
|
| 35 |
+
initTheme();
|
| 36 |
+
// Form submission handler
|
| 37 |
+
// Update the form container class for dark mode
|
| 38 |
+
const authContainer = document.querySelector('.bg-white');
|
| 39 |
+
if (authContainer) {
|
| 40 |
+
authContainer.classList.add('auth-container');
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
const loginForm = document.querySelector('form');
|
| 44 |
+
if (loginForm) {
|
| 45 |
loginForm.addEventListener('submit', function(e) {
|
| 46 |
e.preventDefault();
|
| 47 |
|
style.css
CHANGED
|
@@ -1,9 +1,33 @@
|
|
| 1 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 2 |
-
|
| 3 |
body {
|
| 4 |
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
}
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
/* Custom focus styles */
|
| 8 |
input:focus, button:focus {
|
| 9 |
outline: 2px solid transparent;
|
|
|
|
| 1 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
|
|
|
| 2 |
body {
|
| 3 |
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
| 4 |
+
transition: background 0.3s ease;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
/* Dark mode styles */
|
| 8 |
+
.dark .auth-container {
|
| 9 |
+
background-color: #1a202c;
|
| 10 |
+
color: #e2e8f0;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
.dark input {
|
| 14 |
+
background-color: #2d3748;
|
| 15 |
+
border-color: #4a5568;
|
| 16 |
+
color: #e2e8f0;
|
| 17 |
}
|
| 18 |
|
| 19 |
+
.dark input:focus {
|
| 20 |
+
border-color: #4299e1;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
.dark .auth-footer {
|
| 24 |
+
background-color: #2d3748;
|
| 25 |
+
border-color: #4a5568;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.dark .text-gray-600 {
|
| 29 |
+
color: #a0aec0;
|
| 30 |
+
}
|
| 31 |
/* Custom focus styles */
|
| 32 |
input:focus, button:focus {
|
| 33 |
outline: 2px solid transparent;
|