Stan2001002 commited on
Commit
2d7cf20
·
verified ·
1 Parent(s): b5e376e

Add 3 files

Browse files
Files changed (3) hide show
  1. app.js +53 -0
  2. index.html +21 -19
  3. style.css +63 -19
app.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let global = {};
2
+
3
+ // AlpineJS initialization
4
+ Alpine.start();
5
+
6
+ // Get the inputs and buttons
7
+ const inputs = document.querySelectorAll(".inputs input");
8
+ const addButton = document.querySelector(".add-btn");
9
+ const toDoList = document.querySelector(".to-do-list");
10
+ const toDos = [];
11
+
12
+ // Add an event listener to the add button
13
+ addButton.addEventListener("click", () => {
14
+ let input = inputs.value;
15
+ let title = input[0].value;
16
+ let startTime = input[1].value;
17
+ let endTime = input[2].value;
18
+ let duration = input[3].value;
19
+ if (title.length && startTime.length && endTime.length && duration.length > 0) {
20
+ toDos.push({ title, startTime, endTime, duration });
21
+ inputs[0].value = "";
22
+ inputs[1].value = "";
23
+ inputs[2].value = "";
24
+ inputs[3].value = "";
25
+ }
26
+ });
27
+
28
+ // Add an event listener to the to-do list item
29
+ toDoList.addEventListener("click", async (e) => {
30
+ if (e.target.classList.contains("delete-btn")) {
31
+ const id = e.target.parentElement.dataset.id;
32
+ const toDo = document.querySelector(`[data-id="${id}"]`);
33
+ e.stopPropagation();
34
+ if (confirm("Are you sure you want to delete this to-do?")) {
35
+ await deleteToDo(id);
36
+ toDo.remove();
37
+ }
38
+ }
39
+ });
40
+
41
+ // Function to delete a to-do
42
+ async function deleteToDo(id) {
43
+ try {
44
+ const response = await fetch(`${baseUrl}/todos/${id}`, {
45
+ method: "DELETE",
46
+ });
47
+ if (response.status !== 200) {
48
+ throw new Error("Failed to delete the to-do.");
49
+ }
50
+ } catch (err) {
51
+ console.error(err);
52
+ }
53
+ }
index.html CHANGED
@@ -1,19 +1,21 @@
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
+ <html><head><link href="https://cdn.jsdelivr.net/npm/daisyui@3.1.6/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>Multi-To Do App</title></head>
2
+ <body>
3
+ <main id="app"><article class="prose"><h1>To-Do List</h1><p>Keep track of your tasks and extend deadlines as needed.</p></article><div class="border rounded-md break mt-8"><table class="table table-compact table-fixed border border-solid border-gray-200"><thead><tr><th scope="col" class="px-4 py-2">Title</th><th scope="col" class="px-4 py-2">Start Time</th><th scope="col" class="px-4 py-2">End Time</th><th scope="col" class="px-4 py-2">Duration</th><th scope="col" class="px-4 py-2"></th></tr></thead><tbody><tr x-data="{ open: false }" :wrap="false">
4
+ <th class="px-4 py-2 font-bold"><input type="text" class="bg-gray-50 border-blue-500 placeholder-gray-500 text-gray-800" placeholder="To-Do Title" x-model="title"></th>
5
+ <th class="px-4 py-2 font-bold">
6
+ <input type="time" class="bg-gray-50 border-blue-500 placeholder-gray-500 text-gray-800" placeholder="HH:MM" x-model="startTime"></th>
7
+ <th class="px-4 py-2 font-bold">
8
+ <input type="time" class="bg-gray-50 border-blue-500 placeholder-gray-500 text-gray-800" placeholder="HH:MM" x-model="endTime"></th>
9
+ <th class="px-4 py-2 font-bold">
10
+ <input type="number" class="bg-gray-50 border-blue-500 placeholder-gray-500 text-gray-800" placeholder="HH:MM" x-model="duration"></th>
11
+ <th class="px-4 py-2 font-bold"><button :disabled="open" class="bg-gray-50 border-blue-500 text-gray-800 hover:bg-blue-500 hover:text-gray-50" @click="open = !open">Add</button></th></tr><template x-for="toDo in toDos" x-key="toDo.id" x-bind:open="toDo.open" x-bind:class="toDo.open ? 'prose' : 'hidden'">
12
+ <tr class="bg-gray-50 border-b border-gray-200 hover:bg-gray-100"><td class="px-4 py-2"><input type="text" class="bg-gray-50 border-blue-500 placeholder-gray-500 text-gray-800" placeholder="To-Do Title" x-model="toDo.title"></td>
13
+ <td class="px-4 py-2"><input type="time" class="bg-gray-50 border-blue-500 placeholder-gray-500 text-gray-800" placeholder="HH:MM" x-model="toDo.startTime"></td>
14
+ <td class="px-4 py-2"><input type="time" class="bg-gray-50 border-blue-500 placeholder-gray-500 text-gray-800" placeholder="HH:MM" x-model="toDo.endTime"></td>
15
+ <td class="px-4 py-2"><input type="number" class="bg-gray-50 border-blue-500 placeholder-gray-500 text-gray-800" placeholder="HH:MM" x-model="toDo.duration"></td>
16
+ <td class="px-4 py-2"><button class="bg-gray-50 border-blue-500 text-gray-800 hover:bg-blue-500 hover:text-gray-50" @click="toDo.open = !toDo.open">Edit</button></td></tr></template>
17
+ </table>
18
+ </div>
19
+ </div>
20
+ </main>
21
+ </body></html>
style.css CHANGED
@@ -1,28 +1,72 @@
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
+ * {
2
+ box-sizing: border-box;
3
+ margin: 0;
4
+ padding: 0;
5
+ font-family: sans-serif;
6
+ }
7
+ main {
8
+ margin: 2rem auto;
9
+ max-width: 40rem;
10
+ border: 0.5px solid gray;
11
+ padding: 1rem;
12
+ box-shadow: 10px 10px 5px #888888;
13
  }
14
 
15
+ .header {
16
+ background-color: #4CAF50;
17
+ color: white;
18
+ padding: 1rem;
19
+ text-align: center;
20
  }
21
 
22
+ .container {
23
+ padding: 1rem;
24
+ display: grid;
25
+ grid-template-columns: 1fr 1fr 1fr 1fr;
26
+ grid-gap: 10px;
27
  }
28
 
29
+ input[type="text"],
30
+ input[type="time"] {
31
+ width: 100%;
32
+ padding: 12px 20px;
33
+ margin: 8px 0;
34
+ display: inline-block;
35
+ border: 1px solid #ccc;
36
+ border-radius: 4px;
37
+ box-sizing: border-box;
38
  }
39
 
40
+ input[type="number"] {
41
+ width: 100%;
42
+ padding: 12px 20px;
43
+ margin: 8px 0;
44
+ display: inline-block;
45
+ border: 1px solid #ccc;
46
+ border-radius: 4px;
47
+ box-sizing: border-box;
48
  }
49
+
50
+ button {
51
+ background-color: #4CAF50;
52
+ color: white;
53
+ padding: 12px 20px;
54
+ border: none;
55
+ border-radius: 4px;
56
+ cursor: pointer;
57
+ float: right;
58
+ }
59
+
60
+ .prose {
61
+ padding: 1rem;
62
+ margin: 1rem 0;
63
+ line-height: 1.25;
64
+ border-top: 1px solid #ddd;
65
+ border-bottom: 1px solid #ddd;
66
+ }
67
+
68
+ @media (max-width: 768px) {
69
+ .container {
70
+ grid-template-columns: 1fr;
71
+ }
72
+ }