-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathApp.jsx
More file actions
101 lines (90 loc) · 4.33 KB
/
App.jsx
File metadata and controls
101 lines (90 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React, { useEffect, useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { PlusIcon, MoonIcon, SunIcon } from '@heroicons/react/24/outline';
import { TaskProvider } from './context/TaskContext';
import { TagProvider } from './context/TagContext';
import { ListProvider } from './context/ListContext';
import GlobalTaskForm from './features/tasks/components/GlobalTaskForm';
import TaskBoard from './features/lists/components/TaskBoard';
function App() {
const [showInput, setShowInput] = useState(false);
const [isDarkMode, setIsDarkMode] = useState(() => {
if (typeof window === 'undefined') {
return false;
}
const storedTheme = window.localStorage.getItem('task-dashboard.theme');
if (storedTheme) {
return storedTheme === 'dark';
}
return window.matchMedia('(prefers-color-scheme: dark)').matches;
});
useEffect(() => {
if (typeof document !== 'undefined') {
document.documentElement.classList.toggle('dark', isDarkMode);
}
if (typeof window !== 'undefined') {
window.localStorage.setItem('task-dashboard.theme', isDarkMode ? 'dark' : 'light');
}
}, [isDarkMode]);
return (
<TaskProvider>
<TagProvider>
<ListProvider>
<div className="App min-h-screen bg-gradient-to-br from-primary-50 to-secondary-50 dark:from-neutral-950 dark:via-slate-950 dark:to-neutral-900 flex flex-col items-center py-12 px-4 transition-colors duration-300" data-testid="app">
<div className="w-full max-w-6xl">
<motion.div
className="mb-6 bg-white dark:bg-neutral-900 dark:border dark:border-neutral-800 rounded-2xl shadow-soft p-6 transition-colors duration-300"
initial={{ opacity: 0, y: -20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5 }}
data-testid="app-header"
>
<div className="flex justify-between items-center mb-6">
<h1 className="text-3xl font-bold text-neutral-800 dark:text-neutral-100 tracking-tight">Task Dashboard</h1>
<button
type="button"
className="inline-flex items-center gap-2 rounded-xl border border-neutral-200 dark:border-neutral-700 bg-white/70 dark:bg-neutral-800 px-3 py-2 text-sm font-medium text-neutral-700 dark:text-neutral-200 hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"
onClick={() => setIsDarkMode(prev => !prev)}
data-testid="theme-toggle-button"
aria-label={isDarkMode ? 'Switch to light mode' : 'Switch to dark mode'}
>
{isDarkMode ? <SunIcon className="h-4 w-4" /> : <MoonIcon className="h-4 w-4" />}
{isDarkMode ? 'Light' : 'Dark'}
</button>
</div>
<AnimatePresence>
{showInput ? (
<motion.div
initial={{ opacity: 0, height: 0 }}
animate={{ opacity: 1, height: 'auto' }}
exit={{ opacity: 0, height: 0 }}
className="overflow-hidden"
data-testid="task-form-container"
>
<GlobalTaskForm onCancel={() => setShowInput(false)} />
</motion.div>
) : (
<motion.button
className="flex items-center justify-center w-full py-3 px-4 bg-primary-500 hover:bg-primary-600 text-white rounded-xl font-medium transition-colors"
onClick={() => setShowInput(true)}
whileTap={{ scale: 0.97 }}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
data-testid="show-task-form-button"
>
<PlusIcon className="h-5 w-5 mr-2" />
Add New Task
</motion.button>
)}
</AnimatePresence>
</motion.div>
{/* The TaskBoard component now manages all task lists */}
<TaskBoard />
</div>
</div>
</ListProvider>
</TagProvider>
</TaskProvider>
);
}
export default App;