-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
109 lines (109 loc) · 3.24 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
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
102
103
104
105
106
107
108
109
<!doctype html>
<html>
<head>
<title>Lifeter - Track your lifts</title>
<meta charset="utf-8" />
</head>
<body>
<div class="container mx-auto max-w-6xl" id="app">
<h1 class="font-black bg-white text-black text-4xl mb-2">Lifeter</h1>
<div
x-data="{
lifts: JSON.parse(localStorage.getItem('lifts') || '[]'),
cur_lift: { body_part: 'Chest', lift_name: 'Push Ups', sets: 3, reps: 10 },
add() {
this.lifts.push(this.cur_lift);
this.cur_lift = { body_part: 'Chest' };
this.saveLocal();
},
deleteLift(id) {
this.lifts.splice(id, 1);
this.saveLocal();
},
saveLocal() {
localStorage.setItem('lifts', JSON.stringify(this.lifts));
}
}"
>
<form @submit.prevent="add()" class="mb-2">
<div class="mb-1 flex gap-1">
<select
class="py-1.5"
name="body_part"
required
x-model="cur_lift.body_part"
>
<option value="Chest">Chest</option>
<option value="Back">Back</option>
<option value="Biceps">Biceps</option>
<option value="Triceps">Triceps</option>
<option value="Shoulders">Shoulders</option>
<option value="Legs">Legs</option>
</select>
<input
type="text"
name="lift_name"
placeholder="Lift Name"
x-model="cur_lift.lift_name"
required
/>
</div>
<div class="mb-1 flex gap-1">
<input
type="number"
name="sets"
placeholder="Sets"
min="1"
max="10"
x-model="cur_lift.sets"
required
/>
<input
type="number"
name="reps"
placeholder="Reps"
min="1"
max="20"
x-model="cur_lift.reps"
required
/>
</div>
<div class="mb-1">
<button type="submit" class="btn btn-primary">Add Lift</button>
</div>
</form>
<hr class="mb-2" />
<h3 class="text-2xl mb-2">Lifts</h3>
<table class="w-full text-left">
<thead class="uppercase bg-gray-50 text-gray-800">
<tr>
<th>Body Part</th>
<th>Lift</th>
<th>Sets</th>
<th>Reps</th>
<th></th>
</tr>
</thead>
<template x-for="(item, index) in lifts" :key="index">
<tr>
<td x-text="item.body_part"></td>
<td x-text="item.lift_name"></td>
<td x-text="item.sets"></td>
<td x-text="item.reps"></td>
<td>
<button
class="btn btn-danger"
type="button"
@click="deleteLift(index)"
>
Delete
</button>
</td>
</tr>
</template>
</table>
</div>
</div>
<script type="module" src="./main.js"></script>
</body>
</html>