Files
bookhoard/templates/custom_section.templ
T
john-okeefe a075a5061f feat(ui): refresh auth, entry, admin, and secondary pages
Apply the new design-system primitives across the remaining pages so the
whole app shares one visual language:

- Auth/entry: redesigned index, login, register (centered card layout,
  SVG icons, semantic tokens)
- Admin: sidebar nav with icons, cohesive admin dashboard/users/library/
  processing-issues/settings (tables use border-line + hover states;
  scan/websocket attributes preserved)
- Secondary: analytics (stat cards), devices, progress, conflicts, queue,
  profile + form/modal all migrated to .card/.btn/.input primitives and
  SVG action icons
- Docs + API explorer + setup wizard + collection/rules/modals +
  unlinked books + book-detail modals: consistent chrome, modal scrims
  use --surface-overlay, close buttons use icon-btn
- reader.templ and error.templ intentionally left unchanged
2026-08-05 16:01:22 -04:00

185 lines
5.9 KiB
Templ

package templates
templ CustomSectionBuilder(user User, libraries []LibraryData, errorMessage string) {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Create Custom Section - Bookhoard</title>
<script src="/static/htmx.min.js"></script>
<link href="/static/style.css" rel="stylesheet"/>
</head>
<body class="theme-{ user.Theme }">
@Header(user, "/custom-section")
<main class="max-w-4xl mx-auto px-4 py-8">
<h1 class="text-2xl font-bold tracking-tight text-content mb-2">Create Custom Section</h1>
<p class="mb-6 text-content-muted">Build a custom dashboard section by defining filter rules or manually selecting books.</p>
<form id="custom-section-form" class="space-y-6">
<!-- Section Details -->
<div class="p-4 rounded-lg bg-surface-raised">
<h2 class="text-xl font-semibold mb-4 text-content">Section Details</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-semibold uppercase tracking-wide text-content-muted mb-2">Name *</label>
<input
type="text"
id="section-name"
name="name"
required
class="input"
/>
</div>
<div>
<label class="block text-xs font-semibold uppercase tracking-wide text-content-muted mb-2">Icon (emoji)</label>
<input
type="text"
id="section-icon"
name="icon"
maxlength="4"
class="input"
placeholder="📚"
/>
</div>
</div>
<div class="mt-4">
<label class="block text-xs font-semibold uppercase tracking-wide text-content-muted mb-2">Description</label>
<textarea
id="section-description"
name="description"
rows="2"
class="input"
></textarea>
</div>
<div class="mt-4">
<label class="block text-xs font-semibold uppercase tracking-wide text-content-muted mb-2">Library *</label>
<select
id="section-library"
name="library_id"
required
class="input"
>
<option value="">Select a library...</option>
for _, lib := range libraries {
<option value={ lib.ID }>{ lib.Name }</option>
}
</select>
</div>
</div>
<!-- Filter Rules -->
<div class="p-4 rounded-lg bg-surface-raised">
<div class="flex items-center justify-between mb-4">
<h2 class="text-xl font-semibold text-content">Filter Rules</h2>
<button
type="button"
id="add-rule-btn"
class="btn btn-primary text-sm"
>
@Icon("plus", "h-4 w-4")
Add Rule
</button>
</div>
<p class="text-sm mb-4 text-content-muted">
Books matching these rules will be automatically added to your section. Use AND for all rules, OR for any rule.
</p>
<div id="rules-container" class="space-y-3"></div>
<div class="mt-4 flex items-center gap-2">
<label class="text-sm font-medium text-content-muted">Match:</label>
<select
id="match-type"
name="match_type"
class="input w-auto"
>
<option value="all">ALL rules (AND)</option>
<option value="any">ANY rule (OR)</option>
</select>
</div>
</div>
<!-- Manual Book Selection -->
<div class="p-4 rounded-lg bg-surface-raised">
<h2 class="text-xl font-semibold mb-4 text-content">Manual Book Selection</h2>
<p class="text-sm mb-4 text-content-muted">
Add specific books to this section. Use the search to find and select multiple books.
</p>
<div class="mb-4">
<label class="block text-xs font-semibold uppercase tracking-wide text-content-muted mb-2">Search Books</label>
<div class="flex gap-2">
<input
type="text"
id="book-search"
name="book_search"
class="input flex-1"
placeholder="Search by title or author..."
autocomplete="off"
/>
<button
type="button"
id="search-books-btn"
class="btn btn-primary"
>
@Icon("search", "h-4 w-4")
Search
</button>
</div>
</div>
<div
id="search-results"
class="hidden mb-4 p-3 rounded-lg max-h-60 overflow-y-auto bg-surface"
></div>
<div class="mb-4">
<label class="block text-xs font-semibold uppercase tracking-wide text-content-muted mb-2">Selected Books</label>
<div
id="selected-books"
class="min-h-[60px] p-3 rounded-lg border-2 border-dashed border-line bg-surface"
>
<p class="text-sm text-center text-content-muted">No books selected</p>
</div>
</div>
</div>
<!-- Live Preview -->
<div class="p-4 rounded-lg bg-surface-raised">
<div class="flex items-center justify-between mb-4">
<h2 class="text-xl font-semibold text-content">Live Preview</h2>
<button
type="button"
id="preview-btn"
class="btn btn-primary"
>
@Icon("refresh", "h-4 w-4")
Refresh Preview
</button>
</div>
<div
id="preview-container"
class="p-4 rounded-lg bg-surface min-h-[200px]"
>
<p class="text-center text-content-muted">
Add filter rules or select books to see a preview of your custom section.
</p>
</div>
</div>
<!-- Form Actions -->
<div class="flex justify-end gap-3">
<button
type="button"
id="cancel-btn"
class="btn btn-secondary"
>
Cancel
</button>
<button
type="submit"
id="save-section-btn"
class="btn btn-primary"
>
@Icon("save", "h-4 w-4")
Save Section
</button>
</div>
</form>
</main>
@ErrorToast(errorMessage)
</body>
</html>
}