Skip to content

Commit feb78f2

Browse files
drywatersclaude
andauthored
feat: full-width mobile edit buttons and add Air live-reload (#46)
* feat: full-width mobile edit buttons and add Air live-reload Make edit page action buttons stretch to fill row width on mobile (two per row) while keeping natural sizing on desktop. Also add Air config and `make dev` target for live-reload during development. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR review - air.toml improvements and cancel button flex Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add items-center to cancel button and use npx tailwindcss Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: absolutely position spinner in submit buttons to prevent text shift The htmx-indicator spinner was occupying layout space inside the flex button, nudging the button text off-center when visible. Changed the spinner to absolute positioning (opacity-based toggle) and added left padding to the button to reserve space for the spinner overlay. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: separate spinner positioning and rotation onto different elements Move animate-spin from the .htmx-indicator span to an inner wrapper so that the translateY(-50%) centering on the outer element is not overridden by the spin keyframes' transform: rotate(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 98a4ace commit feb78f2

8 files changed

Lines changed: 55 additions & 23 deletions

File tree

.air.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = "."
2+
tmp_dir = "tmp"
3+
4+
[build]
5+
# Run templ generate and tailwind before building
6+
pre_cmd = ["templ generate", "npx tailwindcss -i ./tailwind/styles.css -o ./static/styles.css"]
7+
cmd = "go build -o ./tmp/main ./cmd/learnd"
8+
entrypoint = ["./tmp/main"]
9+
delay = 500
10+
include_ext = ["go", "templ", "css"]
11+
include_dir = ["cmd", "internal", "tailwind"]
12+
exclude_dir = ["tmp", "bin", "static", "migrations", "node_modules"]
13+
exclude_regex = ["_templ\\.go$"]
14+
kill_delay = "1s"
15+
16+
[log]
17+
main_only = false
18+
19+
[misc]
20+
clean_on_exit = true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Binaries
22
bin/
3+
tmp/
34
*.exe
45
*.exe~
56
*.dll

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.DEFAULT_GOAL := help
2-
.PHONY: help run build test docker-buildx tail-watch tail-prod migrate migrate-down migrate-status templ templ-watch
2+
.PHONY: help run dev build test docker-buildx tail-watch tail-prod migrate migrate-down migrate-status templ templ-watch
33

44
# Include local.mk for local environment variables (API keys, DATABASE_URL, etc.)
55
-include local.mk
@@ -15,6 +15,9 @@ templ-watch: ## Watch templ files and regenerate on change
1515
run: templ tail-prod ## Generate templ, build Tailwind, and run the app
1616
go run ./cmd/learnd
1717

18+
dev: ## Live-reload dev server (watches .go, .templ, .css files)
19+
air
20+
1821
build: templ tail-prod ## Generate templ, build Tailwind, and build production binary
1922
go build -o bin/learnd ./cmd/learnd
2023

internal/ui/pages/capture.templ

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ templ CapturePage(entries []ui.EntryView, prefillURL string) {
106106

107107
<!-- Submit Button -->
108108
<div class="flex justify-end">
109-
<button type="submit" class="btn-primary flex items-center gap-2">
110-
<span class="htmx-indicator animate-spin">
111-
@components.SpinnerIcon()
109+
<button type="submit" class="btn-primary relative flex items-center justify-center pl-6">
110+
<span class="htmx-indicator">
111+
<span class="animate-spin inline-block">
112+
@components.SpinnerIcon()
113+
</span>
112114
</span>
113115
<span>Save Entry</span>
114116
</button>

internal/ui/pages/capture_templ.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/ui/pages/edit.templ

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ templ EditPage(entry ui.EntryView) {
199199
</div>
200200

201201
<!-- Actions -->
202-
<div class="flex flex-col items-start sm:flex-row sm:items-center gap-3 pt-6 border-t" style="border-color: var(--color-warm-gray);">
202+
<div class="flex flex-col sm:flex-row sm:items-center gap-3 pt-6 border-t" style="border-color: var(--color-warm-gray);">
203203
<!-- Re-sync actions (left side) -->
204-
<div class="flex items-center gap-2">
204+
<div class="flex items-center gap-2 w-full sm:w-auto">
205205
<button
206206
type="button"
207207
hx-post={ fmt.Sprintf("/api/entries/%s/refresh-enrichment", entry.ID) }
208208
hx-swap="none"
209-
class="btn-secondary flex items-center gap-1.5"
209+
class="btn-secondary flex-1 sm:flex-initial flex items-center justify-center gap-1.5"
210210
title="Re-fetch metadata from source"
211211
>
212212
@components.RefreshIcon()
@@ -216,7 +216,7 @@ templ EditPage(entry ui.EntryView) {
216216
type="button"
217217
hx-post={ fmt.Sprintf("/api/entries/%s/refresh-summary", entry.ID) }
218218
hx-swap="none"
219-
class="btn-secondary flex items-center gap-1.5"
219+
class="btn-secondary flex-1 sm:flex-initial flex items-center justify-center gap-1.5"
220220
title="Regenerate AI summary"
221221
>
222222
@components.RefreshIcon()
@@ -225,16 +225,18 @@ templ EditPage(entry ui.EntryView) {
225225
</div>
226226

227227
<!-- Main actions (right side) -->
228-
<div class="flex items-center gap-3 sm:ml-auto">
228+
<div class="flex items-center gap-3 w-full sm:w-auto sm:ml-auto">
229229
<a
230230
href="/"
231-
class="btn-secondary"
231+
class="btn-secondary flex-1 sm:flex-initial flex items-center justify-center"
232232
>
233233
Cancel
234234
</a>
235-
<button type="submit" class="btn-primary flex items-center gap-2">
236-
<span class="htmx-indicator animate-spin">
237-
@components.SpinnerIcon()
235+
<button type="submit" class="btn-primary flex-1 sm:flex-initial relative flex items-center justify-center pl-6">
236+
<span class="htmx-indicator">
237+
<span class="animate-spin inline-block">
238+
@components.SpinnerIcon()
239+
</span>
238240
</span>
239241
<span>Save Changes</span>
240242
</button>

internal/ui/pages/edit_templ.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tailwind/styles.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,15 @@
262262

263263
/* HTMX loading states */
264264
.htmx-request .htmx-indicator {
265-
display: inline-block;
265+
opacity: 1;
266266
}
267267

268268
.htmx-indicator {
269-
display: none;
269+
opacity: 0;
270+
position: absolute;
271+
left: 0.75rem;
272+
top: 50%;
273+
transform: translateY(-50%);
270274
}
271275

272276
/* Toast notifications */

0 commit comments

Comments
 (0)