minor tweaks
Marco Andronaco andronacomarco@gmail.com
Fri, 18 Oct 2024 12:34:16 +0200
5 files changed,
29 insertions(+),
27 deletions(-)
M
src/app/functions.go
→
src/app/functions.go
@@ -184,34 +184,24 @@ }
return } -func toHabitDisplay(habit Habit) HabitDisplay { - var ( - days int - lastAck string - class string - ) - +func toHabitDisplay(habit Habit) (d HabitDisplay) { if habit.LastAck != nil { - days, lastAck = formatDuration(*habit.LastAck) - class = getClassForAck(habit, days) + var days int + days, d.LastAck = formatDuration(*habit.LastAck) + d.Class = getClassForAck(habit, days) } else { - lastAck = "-" + d.LastAck = "-" if habit.Negative { - class = classGood - } - - if !habit.Disabled { - class = classBad + d.Class = classGood + } else if !habit.Disabled { + d.Class = classBad } } - return HabitDisplay{ - ID: habit.ID, - Name: habit.Name, - LastAck: lastAck, - Disabled: habit.Disabled, - Class: class, - } + d.ID = habit.ID + d.Name = habit.Name + d.Disabled = habit.Disabled + return } func getClassForAck(habit Habit, days int) string {
M
static/style.css
→
static/style.css
@@ -19,6 +19,10 @@ justify-content: space-between;
align-items: center; } +.habits-title > h3 { + margin-block: 10px; +} + .actions { display: grid; grid-template-columns: auto auto;@@ -32,6 +36,10 @@ }
thead { font-weight: bold; +} + +.spaced { + margin-top: 25px; } .good {
M
templates/habits-id.tmpl
→
templates/habits-id.tmpl
@@ -4,6 +4,7 @@ {{define "title" -}}Edit - {{end}}
{{define "content" -}} <h1>Edit habit</h1> + <a href="/habits">← Back</a> <form method="post" action="/habits/{{ .ID }}"> <label>@@ -20,9 +21,9 @@ <span>Enabled:</span>
<input type="checkbox" name="enabled"{{ if not .Disabled }} checked{{ end }} /> </label> {{ end }} - <input type="submit" value="Save" /> + <input type="submit" value="Save" class="spaced" /> </form> <form method="post" action="/delete/{{ .ID }}"> - <input type="submit" value="Delete" /> + <input type="submit" value="Delete" class="spaced" /> </form> {{end}}
M
templates/habits.tmpl
→
templates/habits.tmpl
@@ -4,7 +4,8 @@ {{define "title" -}}Habits - {{end}}
{{define "content" -}} <h1>Welcome, <i>{{.User.Username}}</i>!</h1> - <a href="/logout">Logout</a><br /> + <a href="/logout">← Logout</a><br /> + <div style="margin-top:20px;"></div> <div class="habits-title"> <h3>Positive habits</h3> <a href="/new-positive" class="button">+ Add</a>@@ -24,10 +25,11 @@ <tr class="{{.Class}}">
<td>{{ .Name }}</td> <td><i>{{ .LastAck }}</i></td> <td class="actions"> + {{ if not .Disabled }} <form action="/ack/{{ .ID }}" method="post"> <input type="submit" value="Ack" /> </form> - + {{ end }} <form action="/habits/{{ .ID }}" method="get"> <input type="submit" value="Edit" /> </form>
M
templates/new.tmpl
→
templates/new.tmpl
@@ -4,6 +4,7 @@ {{define "title" -}}New - {{end}}
{{define "content" -}} <h1>New habit</h1> + <a href="/habits">← Back</a> <h4> {{ if .Negative }} Which negative habit are you trying to stop?@@ -26,6 +27,6 @@ <span>Days:</span>
<input type="number" name="days" autocomplete="off" placeholder="Days" min="1" max="60" required /> </label> {{ end }} - <input type="submit" value="Create" /> + <input type="submit" value="Create" class="spaced" /> </form> {{end}}