DocHoax commited on
Commit
89e5f5f
·
verified ·
1 Parent(s): 8a0958f

Create a Custom Countdown Timer for productivity, personal, anticipatory activities. Let users create multiple timers for things they're excited about (e.g., Vacation, Album Release, Project deadline.). Allow them to customize the background and name.

Browse files
Files changed (2) hide show
  1. README.md +8 -5
  2. index.html +312 -18
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Countdownchronicle
3
- emoji: 😻
4
- colorFrom: purple
5
- colorTo: pink
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: CountdownChronicle 🕒
3
+ colorFrom: gray
4
+ colorTo: blue
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://deepsite.hf.co).
index.html CHANGED
@@ -1,19 +1,313 @@
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">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>CountdownChronicle</title>
7
+ <link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⏱️</text></svg>">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://unpkg.com/feather-icons"></script>
10
+ <script>
11
+ tailwind.config = {
12
+ theme: {
13
+ extend: {
14
+ colors: {
15
+ undefined: {
16
+ 500: '#6366f1',
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ </script>
23
+ <style>
24
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
25
+ body {
26
+ font-family: 'Poppins', sans-serif;
27
+ background-color: #f9fafb;
28
+ }
29
+ .timer-card {
30
+ transition: all 0.3s ease;
31
+ }
32
+ .timer-card:hover {
33
+ transform: translateY(-5px);
34
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
35
+ }
36
+ .countdown-number {
37
+ font-weight: 700;
38
+ font-size: 2.5rem;
39
+ line-height: 1;
40
+ }
41
+ @media (max-width: 640px) {
42
+ .countdown-number {
43
+ font-size: 1.75rem;
44
+ }
45
+ }
46
+ </style>
47
+ </head>
48
+ <body class="min-h-screen bg-gray-50">
49
+ <!-- Header -->
50
+ <header class="bg-white shadow-sm">
51
+ <div class="container mx-auto px-4 py-6 flex justify-between items-center">
52
+ <div class="flex items-center space-x-2">
53
+ <div class="bg-undefined-500 p-2 rounded-lg">
54
+ <i data-feather="clock" class="text-white"></i>
55
+ </div>
56
+ <h1 class="text-2xl font-bold text-gray-800">CountdownChronicle</h1>
57
+ </div>
58
+ <button id="addTimerBtn" class="bg-undefined-500 hover:bg-undefined-600 text-white font-medium py-2 px-4 rounded-lg flex items-center transition duration-300">
59
+ <i data-feather="plus" class="mr-1"></i> New Timer
60
+ </button>
61
+ </div>
62
+ </header>
63
+
64
+ <!-- Main Content -->
65
+ <main class="container mx-auto px-4 py-8">
66
+ <div id="timersContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
67
+ <!-- Timer cards will be dynamically inserted here -->
68
+ </div>
69
+
70
+ <!-- Empty state -->
71
+ <div id="emptyState" class="text-center py-16 hidden">
72
+ <div class="bg-gray-200 border-2 border-dashed rounded-xl w-16 h-16 mx-auto mb-4"></div>
73
+ <h2 class="text-xl font-semibold text-gray-700 mb-2">No timers yet</h2>
74
+ <p class="text-gray-500 mb-6">Create your first countdown timer to get started</p>
75
+ <button id="createFirstTimerBtn" class="bg-undefined-500 hover:bg-undefined-600 text-white font-medium py-2 px-4 rounded-lg transition duration-300">
76
+ Create Timer
77
+ </button>
78
+ </div>
79
+ </main>
80
+
81
+ <!-- Modal -->
82
+ <div id="timerModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
83
+ <div class="bg-white rounded-xl w-full max-w-md p-6">
84
+ <div class="flex justify-between items-center mb-4">
85
+ <h3 class="text-xl font-bold text-gray-800">Create New Timer</h3>
86
+ <button id="closeModalBtn" class="text-gray-500 hover:text-gray-700">
87
+ <i data-feather="x"></i>
88
+ </button>
89
+ </div>
90
+
91
+ <form id="timerForm">
92
+ <div class="mb-4">
93
+ <label class="block text-gray-700 text-sm font-medium mb-2" for="timerName">
94
+ Event Name
95
+ </label>
96
+ <input type="text" id="timerName" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-undefined-500" placeholder="e.g. Summer Vacation" required>
97
+ </div>
98
+
99
+ <div class="mb-4">
100
+ <label class="block text-gray-700 text-sm font-medium mb-2" for="targetDate">
101
+ Target Date
102
+ </label>
103
+ <input type="datetime-local" id="targetDate" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-undefined-500" required>
104
+ </div>
105
+
106
+ <div class="mb-6">
107
+ <label class="block text-gray-700 text-sm font-medium mb-2">
108
+ Background Color
109
+ </label>
110
+ <div class="grid grid-cols-6 gap-2">
111
+ <div class="color-option w-8 h-8 rounded-full bg-red-400 cursor-pointer border-2 border-transparent" data-color="bg-red-400"></div>
112
+ <div class="color-option w-8 h-8 rounded-full bg-blue-400 cursor-pointer border-2 border-transparent" data-color="bg-blue-400"></div>
113
+ <div class="color-option w-8 h-8 rounded-full bg-green-400 cursor-pointer border-2 border-transparent" data-color="bg-green-400"></div>
114
+ <div class="color-option w-8 h-8 rounded-full bg-yellow-400 cursor-pointer border-2 border-transparent" data-color="bg-yellow-400"></div>
115
+ <div class="color-option w-8 h-8 rounded-full bg-purple-400 cursor-pointer border-2 border-transparent" data-color="bg-purple-400"></div>
116
+ <div class="color-option w-8 h-8 rounded-full bg-pink-400 cursor-pointer border-2 border-transparent" data-color="bg-pink-400"></div>
117
+ </div>
118
+ <input type="hidden" id="selectedColor" value="bg-blue-400">
119
+ </div>
120
+
121
+ <div class="flex justify-end space-x-3">
122
+ <button type="button" id="cancelTimerBtn" class="px-4 py-2 text-gray-600 font-medium rounded-lg hover:bg-gray-100 transition duration-300">
123
+ Cancel
124
+ </button>
125
+ <button type="submit" class="bg-undefined-500 hover:bg-undefined-600 text-white font-medium py-2 px-4 rounded-lg transition duration-300">
126
+ Create Timer
127
+ </button>
128
+ </div>
129
+ </form>
130
+ </div>
131
+ </div>
132
+
133
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
134
+ <script>
135
+ // Initialize feather icons
136
+ feather.replace();
137
+
138
+ // DOM Elements
139
+ const timersContainer = document.getElementById('timersContainer');
140
+ const emptyState = document.getElementById('emptyState');
141
+ const timerModal = document.getElementById('timerModal');
142
+ const timerForm = document.getElementById('timerForm');
143
+ const addTimerBtn = document.getElementById('addTimerBtn');
144
+ const createFirstTimerBtn = document.getElementById('createFirstTimerBtn');
145
+ const closeModalBtn = document.getElementById('closeModalBtn');
146
+ const cancelTimerBtn = document.getElementById('cancelTimerBtn');
147
+ const colorOptions = document.querySelectorAll('.color-option');
148
+ const selectedColorInput = document.getElementById('selectedColor');
149
+
150
+ // State
151
+ let timers = JSON.parse(localStorage.getItem('countdownTimers')) || [];
152
+
153
+ // Set min date for datetime picker to today
154
+ const now = new Date();
155
+ const year = now.getFullYear();
156
+ const month = String(now.getMonth() + 1).padStart(2, '0');
157
+ const day = String(now.getDate()).padStart(2, '0');
158
+ const hours = String(now.getHours()).padStart(2, '0');
159
+ const minutes = String(now.getMinutes()).padStart(2, '0');
160
+ document.getElementById('targetDate').min = `${year}-${month}-${day}T${hours}:${minutes}`;
161
+
162
+ // Event Listeners
163
+ addTimerBtn.addEventListener('click', () => {
164
+ timerForm.reset();
165
+ document.getElementById('targetDate').min = `${year}-${month}-${day}T${hours}:${minutes}`;
166
+ timerModal.classList.remove('hidden');
167
+ });
168
+
169
+ createFirstTimerBtn.addEventListener('click', () => {
170
+ addTimerBtn.click();
171
+ });
172
+
173
+ closeModalBtn.addEventListener('click', () => {
174
+ timerModal.classList.add('hidden');
175
+ });
176
+
177
+ cancelTimerBtn.addEventListener('click', () => {
178
+ timerModal.classList.add('hidden');
179
+ });
180
+
181
+ // Color selection
182
+ colorOptions.forEach(option => {
183
+ option.addEventListener('click', () => {
184
+ colorOptions.forEach(opt => opt.classList.remove('border-white'));
185
+ option.classList.add('border-white');
186
+ selectedColorInput.value = option.dataset.color;
187
+ });
188
+ });
189
+
190
+ // Form submission
191
+ timerForm.addEventListener('submit', (e) => {
192
+ e.preventDefault();
193
+
194
+ const name = document.getElementById('timerName').value;
195
+ const targetDate = new Date(document.getElementById('targetDate').value);
196
+ const backgroundColor = selectedColorInput.value;
197
+
198
+ if (targetDate <= new Date()) {
199
+ alert('Please select a future date and time.');
200
+ return;
201
+ }
202
+
203
+ const newTimer = {
204
+ id: Date.now(),
205
+ name,
206
+ targetDate: targetDate.toISOString(),
207
+ backgroundColor
208
+ };
209
+
210
+ timers.push(newTimer);
211
+ saveTimers();
212
+ renderTimers();
213
+ timerModal.classList.add('hidden');
214
+ });
215
+
216
+ // Timer functions
217
+ function saveTimers() {
218
+ localStorage.setItem('countdownTimers', JSON.stringify(timers));
219
+ }
220
+
221
+ function deleteTimer(id) {
222
+ timers = timers.filter(timer => timer.id !== id);
223
+ saveTimers();
224
+ renderTimers();
225
+ }
226
+
227
+ function updateCountdown(timer) {
228
+ const now = new Date();
229
+ const target = new Date(timer.targetDate);
230
+ const diff = target - now;
231
+
232
+ if (diff <= 0) {
233
+ return { days: 0, hours: 0, minutes: 0, seconds: 0 };
234
+ }
235
+
236
+ const days = Math.floor(diff / (1000 * 60 * 60 * 24));
237
+ const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
238
+ const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
239
+ const seconds = Math.floor((diff % (1000 * 60)) / 1000);
240
+
241
+ return { days, hours, minutes, seconds };
242
+ }
243
+
244
+ function renderTimers() {
245
+ timersContainer.innerHTML = '';
246
+
247
+ if (timers.length === 0) {
248
+ emptyState.classList.remove('hidden');
249
+ return;
250
+ }
251
+
252
+ emptyState.classList.add('hidden');
253
+
254
+ timers.forEach(timer => {
255
+ const countdown = updateCountdown(timer);
256
+
257
+ const timerCard = document.createElement('div');
258
+ timerCard.className = `timer-card rounded-xl p-6 text-white ${timer.backgroundColor} shadow-md`;
259
+ timerCard.innerHTML = `
260
+ <div class="flex justify-between items-start mb-4">
261
+ <h3 class="text-xl font-bold">${timer.name}</h3>
262
+ <button class="delete-timer text-white hover:text-gray-200" data-id="${timer.id}">
263
+ <i data-feather="x"></i>
264
+ </button>
265
+ </div>
266
+ <div class="grid grid-cols-4 gap-2 text-center">
267
+ <div>
268
+ <div class="countdown-number">${countdown.days}</div>
269
+ <div class="text-sm opacity-90">Days</div>
270
+ </div>
271
+ <div>
272
+ <div class="countdown-number">${countdown.hours}</div>
273
+ <div class="text-sm opacity-90">Hours</div>
274
+ </div>
275
+ <div>
276
+ <div class="countdown-number">${countdown.minutes}</div>
277
+ <div class="text-sm opacity-90">Minutes</div>
278
+ </div>
279
+ <div>
280
+ <div class="countdown-number">${countdown.seconds}</div>
281
+ <div class="text-sm opacity-90">Seconds</div>
282
+ </div>
283
+ </div>
284
+ <div class="mt-4 text-sm opacity-90">
285
+ Target: ${new Date(timer.targetDate).toLocaleString()}
286
+ </div>
287
+ `;
288
+
289
+ timersContainer.appendChild(timerCard);
290
+ });
291
+
292
+ // Add event listeners to delete buttons
293
+ document.querySelectorAll('.delete-timer').forEach(button => {
294
+ button.addEventListener('click', (e) => {
295
+ const id = parseInt(e.currentTarget.dataset.id);
296
+ deleteTimer(id);
297
+ });
298
+ });
299
+
300
+ // Reinitialize feather icons
301
+ feather.replace();
302
+ }
303
+
304
+ // Update countdowns every second
305
+ setInterval(() => {
306
+ renderTimers();
307
+ }, 1000);
308
+
309
+ // Initial render
310
+ renderTimers();
311
+ </script>
312
+ </body>
313
  </html>