KK21200211 commited on
Commit
1855dfe
·
verified ·
1 Parent(s): 6930558

create a modem task magaer app with animation effect and light and dark mode toggle

Browse files
Files changed (6) hide show
  1. README.md +8 -5
  2. components/footer.js +30 -0
  3. components/navbar.js +54 -0
  4. index.html +86 -19
  5. script.js +151 -0
  6. style.css +45 -19
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Modem Magic Manager
3
- emoji: 🔥
4
- colorFrom: gray
5
- colorTo: indigo
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: Modem Magic Manager
3
+ colorFrom: red
4
+ colorTo: yellow
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
components/footer.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomFooter extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ footer {
7
+ transition: all 0.3s ease;
8
+ }
9
+ </style>
10
+ <footer class="bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 py-6 mt-8">
11
+ <div class="container mx-auto px-4 text-center text-gray-600 dark:text-gray-300">
12
+ <p>© ${new Date().getFullYear()} Modem Magic Manager. All rights reserved.</p>
13
+ <div class="flex justify-center space-x-4 mt-2">
14
+ <a href="#" class="hover:text-primary-500 transition-colors">
15
+ <i data-feather="github"></i>
16
+ </a>
17
+ <a href="#" class="hover:text-primary-500 transition-colors">
18
+ <i data-feather="twitter"></i>
19
+ </a>
20
+ <a href="#" class="hover:text-primary-500 transition-colors">
21
+ <i data-feather="mail"></i>
22
+ </a>
23
+ </div>
24
+ </div>
25
+ </footer>
26
+ `;
27
+ }
28
+ }
29
+
30
+ customElements.define('custom-footer', CustomFooter);
components/navbar.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomNavbar extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ .theme-toggle {
7
+ transition: all 0.3s ease;
8
+ }
9
+ .theme-toggle:hover {
10
+ transform: rotate(30deg);
11
+ }
12
+ </style>
13
+ <nav class="bg-white dark:bg-gray-800 shadow-sm">
14
+ <div class="container mx-auto px-4 py-4 flex justify-between items-center">
15
+ <div class="flex items-center space-x-2">
16
+ <i data-feather="wifi" class="text-primary-500"></i>
17
+ <span class="text-xl font-bold text-gray-800 dark:text-white">Modem Magic</span>
18
+ </div>
19
+ <div class="flex items-center space-x-4">
20
+ <button id="themeToggle" class="theme-toggle p-2 rounded-full bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-200">
21
+ <i data-feather="moon"></i>
22
+ </button>
23
+ </div>
24
+ </div>
25
+ </nav>
26
+ `;
27
+
28
+ // Theme toggle functionality
29
+ const themeToggle = this.shadowRoot.getElementById('themeToggle');
30
+ themeToggle.addEventListener('click', () => {
31
+ const html = document.documentElement;
32
+ if (html.classList.contains('dark')) {
33
+ html.classList.remove('dark');
34
+ localStorage.setItem('theme', 'light');
35
+ themeToggle.innerHTML = `<i data-feather="sun"></i>`;
36
+ } else {
37
+ html.classList.add('dark');
38
+ localStorage.setItem('theme', 'dark');
39
+ themeToggle.innerHTML = `<i data-feather="moon"></i>`;
40
+ }
41
+ feather.replace();
42
+ });
43
+
44
+ // Initialize theme icon
45
+ const html = document.documentElement;
46
+ if (html.classList.contains('dark')) {
47
+ themeToggle.innerHTML = `<i data-feather="moon"></i>`;
48
+ } else {
49
+ themeToggle.innerHTML = `<i data-feather="sun"></i>`;
50
+ }
51
+ }
52
+ }
53
+
54
+ customElements.define('custom-navbar', CustomNavbar);
index.html CHANGED
@@ -1,19 +1,86 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="dark">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Modem Magic Manager</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script>
12
+ tailwind.config = {
13
+ darkMode: 'class',
14
+ theme: {
15
+ extend: {
16
+ colors: {
17
+ primary: {
18
+ 500: '#6366f1',
19
+ },
20
+ secondary: {
21
+ 500: '#10b981',
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }
27
+ </script>
28
+ </head>
29
+ <body class="bg-gray-100 dark:bg-gray-900 transition-colors duration-300 min-h-screen">
30
+ <custom-navbar></custom-navbar>
31
+
32
+ <main class="container mx-auto px-4 py-8">
33
+ <div class="flex justify-between items-center mb-8">
34
+ <h1 class="text-3xl font-bold text-gray-800 dark:text-white">Modem Tasks</h1>
35
+ <button id="addTaskBtn" class="bg-primary-500 hover:bg-primary-600 text-white px-4 py-2 rounded-lg flex items-center gap-2 transition-all hover:scale-105">
36
+ <i data-feather="plus"></i> Add Task
37
+ </button>
38
+ </div>
39
+
40
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
41
+ <!-- Task cards will be inserted here by JavaScript -->
42
+ </div>
43
+ </main>
44
+
45
+ <custom-footer></custom-footer>
46
+
47
+ <!-- Add Task Modal -->
48
+ <div id="taskModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
49
+ <div class="bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md animate-fade-in">
50
+ <div class="flex justify-between items-center mb-4">
51
+ <h2 class="text-xl font-semibold text-gray-800 dark:text-white">Add New Task</h2>
52
+ <button id="closeModalBtn" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
53
+ <i data-feather="x"></i>
54
+ </button>
55
+ </div>
56
+ <form id="taskForm" class="space-y-4">
57
+ <div>
58
+ <label for="taskName" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Task Name</label>
59
+ <input type="text" id="taskName" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-primary-500 dark:bg-gray-700 dark:text-white" required>
60
+ </div>
61
+ <div>
62
+ <label for="taskDescription" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Description</label>
63
+ <textarea id="taskDescription" rows="3" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-primary-500 dark:bg-gray-700 dark:text-white"></textarea>
64
+ </div>
65
+ <div>
66
+ <label for="taskPriority" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Priority</label>
67
+ <select id="taskPriority" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-primary-500 dark:bg-gray-700 dark:text-white">
68
+ <option value="low">Low</option>
69
+ <option value="medium">Medium</option>
70
+ <option value="high">High</option>
71
+ </select>
72
+ </div>
73
+ <button type="submit" class="w-full bg-primary-500 hover:bg-primary-600 text-white py-2 px-4 rounded-md transition-colors">Add Task</button>
74
+ </form>
75
+ </div>
76
+ </div>
77
+
78
+ <script src="components/navbar.js"></script>
79
+ <script src="components/footer.js"></script>
80
+ <script src="script.js"></script>
81
+ <script>
82
+ feather.replace();
83
+ </script>
84
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
85
+ </body>
86
+ </html>
script.js ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ // DOM Elements
3
+ const addTaskBtn = document.getElementById('addTaskBtn');
4
+ const taskModal = document.getElementById('taskModal');
5
+ const closeModalBtn = document.getElementById('closeModalBtn');
6
+ const taskForm = document.getElementById('taskForm');
7
+ const tasksContainer = document.querySelector('.grid');
8
+
9
+ // Sample tasks data
10
+ let tasks = [
11
+ {
12
+ id: 1,
13
+ name: 'Configure Modem Settings',
14
+ description: 'Update the modem firmware and configure security settings',
15
+ priority: 'high',
16
+ completed: false,
17
+ date: new Date()
18
+ },
19
+ {
20
+ id: 2,
21
+ name: 'Check Network Speed',
22
+ description: 'Run speed tests at different times of day',
23
+ priority: 'medium',
24
+ completed: false,
25
+ date: new Date()
26
+ },
27
+ {
28
+ id: 3,
29
+ name: 'Document Configuration',
30
+ description: 'Create documentation for current modem setup',
31
+ priority: 'low',
32
+ completed: true,
33
+ date: new Date()
34
+ }
35
+ ];
36
+
37
+ // Event Listeners
38
+ addTaskBtn.addEventListener('click', openModal);
39
+ closeModalBtn.addEventListener('click', closeModal);
40
+ taskForm.addEventListener('submit', handleTaskSubmit);
41
+
42
+ // Render initial tasks
43
+ renderTasks();
44
+
45
+ // Functions
46
+ function openModal() {
47
+ taskModal.classList.remove('hidden');
48
+ }
49
+
50
+ function closeModal() {
51
+ taskModal.classList.add('hidden');
52
+ }
53
+
54
+ function handleTaskSubmit(e) {
55
+ e.preventDefault();
56
+
57
+ const taskName = document.getElementById('taskName').value;
58
+ const taskDescription = document.getElementById('taskDescription').value;
59
+ const taskPriority = document.getElementById('taskPriority').value;
60
+
61
+ const newTask = {
62
+ id: Date.now(),
63
+ name: taskName,
64
+ description: taskDescription,
65
+ priority: taskPriority,
66
+ completed: false,
67
+ date: new Date()
68
+ };
69
+
70
+ tasks.unshift(newTask);
71
+ renderTasks();
72
+ closeModal();
73
+ taskForm.reset();
74
+ }
75
+
76
+ function renderTasks() {
77
+ tasksContainer.innerHTML = '';
78
+
79
+ tasks.forEach(task => {
80
+ const taskCard = document.createElement('div');
81
+ taskCard.className = `task-card bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 ${task.priority}-priority ${task.completed ? 'completed' : ''}`;
82
+
83
+ taskCard.innerHTML = `
84
+ <div class="flex justify-between items-start mb-2">
85
+ <h3 class="text-lg font-semibold text-gray-800 dark:text-white">${task.name}</h3>
86
+ <span class="text-xs px-2 py-1 rounded-full ${getPriorityClass(task.priority)}">
87
+ ${task.priority}
88
+ </span>
89
+ </div>
90
+ <p class="text-gray-600 dark:text-gray-300 mb-4">${task.description}</p>
91
+ <div class="flex justify-between items-center text-sm text-gray-500 dark:text-gray-400">
92
+ <span>${formatDate(task.date)}</span>
93
+ <div class="flex gap-2">
94
+ <button class="task-complete-btn p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700" data-id="${task.id}">
95
+ <i data-feather="${task.completed ? 'check-circle' : 'circle'}" class="${task.completed ? 'text-green-500' : 'text-gray-400'}"></i>
96
+ </button>
97
+ <button class="task-delete-btn p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700" data-id="${task.id}">
98
+ <i data-feather="trash-2" class="text-red-400"></i>
99
+ </button>
100
+ </div>
101
+ </div>
102
+ `;
103
+
104
+ tasksContainer.appendChild(taskCard);
105
+ });
106
+
107
+ // Add event listeners to new buttons
108
+ document.querySelectorAll('.task-complete-btn').forEach(btn => {
109
+ btn.addEventListener('click', toggleTaskComplete);
110
+ });
111
+
112
+ document.querySelectorAll('.task-delete-btn').forEach(btn => {
113
+ btn.addEventListener('click', deleteTask);
114
+ });
115
+
116
+ feather.replace();
117
+ }
118
+
119
+ function toggleTaskComplete(e) {
120
+ const taskId = parseInt(e.currentTarget.getAttribute('data-id'));
121
+ const taskIndex = tasks.findIndex(task => task.id === taskId);
122
+
123
+ if (taskIndex !== -1) {
124
+ tasks[taskIndex].completed = !tasks[taskIndex].completed;
125
+ renderTasks();
126
+ }
127
+ }
128
+
129
+ function deleteTask(e) {
130
+ const taskId = parseInt(e.currentTarget.getAttribute('data-id'));
131
+ tasks = tasks.filter(task => task.id !== taskId);
132
+ renderTasks();
133
+ }
134
+
135
+ function getPriorityClass(priority) {
136
+ switch(priority) {
137
+ case 'high': return 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200';
138
+ case 'medium': return 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200';
139
+ case 'low': return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';
140
+ default: return '';
141
+ }
142
+ }
143
+
144
+ function formatDate(date) {
145
+ return new Date(date).toLocaleDateString('en-US', {
146
+ month: 'short',
147
+ day: 'numeric',
148
+ year: 'numeric'
149
+ });
150
+ }
151
+ });
style.css CHANGED
@@ -1,28 +1,54 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
 
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @keyframes fadeIn {
2
+ from { opacity: 0; transform: translateY(10px); }
3
+ to { opacity: 1; transform: translateY(0); }
4
  }
5
 
6
+ @keyframes pulse {
7
+ 0%, 100% { transform: scale(1); }
8
+ 50% { transform: scale(1.05); }
9
  }
10
 
11
+ .animate-fade-in {
12
+ animation: fadeIn 0.3s ease-out forwards;
 
 
 
13
  }
14
 
15
+ .task-card {
16
+ transition: all 0.3s ease;
 
 
 
 
17
  }
18
 
19
+ .task-card:hover {
20
+ transform: translateY(-5px);
21
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
22
  }
23
+
24
+ .dark .task-card:hover {
25
+ box-shadow: 0 10px 25px -5px rgba(255, 255, 255, 0.1);
26
+ }
27
+
28
+ .priority-high {
29
+ border-left: 4px solid #ef4444;
30
+ }
31
+
32
+ .priority-medium {
33
+ border-left: 4px solid #f59e0b;
34
+ }
35
+
36
+ .priority-low {
37
+ border-left: 4px solid #10b981;
38
+ }
39
+
40
+ .completed {
41
+ position: relative;
42
+ }
43
+
44
+ .completed::after {
45
+ content: '';
46
+ position: absolute;
47
+ top: 0;
48
+ left: 0;
49
+ right: 0;
50
+ bottom: 0;
51
+ background: rgba(16, 185, 129, 0.1);
52
+ z-index: 1;
53
+ border-radius: 0.5rem;
54
+ }