-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
57 lines (52 loc) · 2.88 KB
/
index.html
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
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet">
<title>Todo App</title>
<link rel="manifest" href="manifest.json">
</head>
<body>
<div class="max-w-md mx-auto p-4" x-data="app()">
<h1 class="text-2xl font-bold mb-4">Todo App</h1>
<div class="mb-4">
<input x-model="taskTitle" type="text" class="border border-gray-300 rounded px-4 py-2 w-full" placeholder="Task title">
</div>
<div class="mb-4">
<button @click="addTask" class="bg-blue-500 hover:bg-blue-600 text-white font-bold px-4 py-2 rounded">Add Task</button>
</div>
<div id="taskList" class="space-y-2">
<template x-for="(task, index) in tasks" :key="index">
<div
class="flex border border-gray-300 rounded px-4 py-2"
x-data="taskData(index)"
draggable="true"
@dragstart="dragStart"
@dragover.prevent="dragOver"
@drop="drop(index)"
>
<button @dragstart.prevent="startDrag" class="cursor-move font-bold px-2 py-1 rounded">
<svg class="h-6 w-6" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</button>
<input x-model="task.attributes.title" class="flex-1 border-none outline-none" data-index="index">
<button @click="deleteTask(index)" class="text-red-500 font-bold px-2 py-1 rounded">
<svg aria-hidden="true" class="h-6 w-6" stroke="currentColor" fill="none" stroke-width="1.5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</button>
</div>
</template>
</div>
<div class="mt-4">
<button @click="copyTasks" class="bg-green-500 hover:bg-green-600 text-white font-bold px-4 py-2 rounded">Copy Tasks</button>
<button @click="deleteAllTasks" class="bg-red-500 hover:bg-red-600 text-white font-bold px-4 py-2 rounded">Delete Tasks</button>
</div>
</div>
<script src="https://unpkg.com/alpinejs" defer></script>
<script src="app.js"></script>
</body>
</html>