feat(15-03): restyle tablos.templ with AppLayout, TabloProjectCard, and EmptyState

- Updated TablosDashboard signature to accept activePath and tablos for AppLayout
- Replaced old @Layout call with @AppLayout (sidebar-based shell)
- Added TabloProjectCard component with project-card grid, colored avatar, tablo-title-zone, edit/delete icon buttons
- Replaced TablosEmptyState raw HTML with @ui.EmptyState component (ui-empty-state class)
- Updated TabloDetailPage signature with activePath and sidebarTablos params
- Updated TabloNotFoundPage signature with activePath and sidebarTablos params
- Both detail pages switch from @Layout to @AppLayout
This commit is contained in:
Arthur Belleville 2026-05-16 21:49:10 +02:00
parent ae0ab0ca5b
commit 9c7b080f67
No known key found for this signature in database

View file

@ -6,61 +6,114 @@ import (
"backend/internal/web/ui" "backend/internal/web/ui"
) )
// TablosDashboard renders the root authenticated dashboard: heading, "New tablo" // TablosDashboard renders the root authenticated dashboard with sidebar AppLayout.
// button, create-form slot, and the list of tablo cards (or empty state). // Shows a project-card grid (or empty state) for the user's tablos.
// UI-SPEC §1 Interaction Contract — GET /. // UI-SPEC §1 Interaction Contract — GET /.
templ TablosDashboard(user *auth.User, csrfToken string, tablos []TabloCardView) { templ TablosDashboard(user *auth.User, csrfToken string, activePath string, tablos []sqlc.Tablo, cards []TabloCardView) {
@Layout("Tablos — Xtablo", user, csrfToken) { @AppLayout("Tablos — Xtablo", user, csrfToken, activePath, tablos) {
<div class="flex items-center justify-between mb-6"> <section class="overview-section">
<h1 class="text-[28px] font-semibold leading-tight">Your Tablos</h1> <div class="overview-section-heading">
@ui.Button(ui.ButtonProps{ <h3>Your Tablos</h3>
Label: "New tablo", @ui.Button(ui.ButtonProps{
Variant: ui.ButtonVariantDefault, Label: "New tablo",
Tone: ui.ButtonToneSolid, Variant: ui.ButtonVariantDefault,
Size: ui.SizeMD, Tone: ui.ButtonToneSolid,
Type: "button", Size: ui.SizeMD,
Attrs: templ.Attributes{ Type: "button",
"hx-get": "/tablos/new", Attrs: templ.Attributes{
"hx-target": "#create-form-slot", "hx-get": "/tablos/new",
"hx-swap": "innerHTML", "hx-target": "#create-form-slot",
}, "hx-swap": "innerHTML",
}) },
</div> })
<div id="create-form-slot"></div> </div>
<div id="tablos-list"> <div id="create-form-slot"></div>
if len(tablos) == 0 { <div id="tablos-list" class="project-grid">
@TablosEmptyState() if len(cards) == 0 {
} else { @TablosEmptyState()
for _, tablo := range tablos { } else {
@TabloCard(tablo, csrfToken) for _, card := range cards {
@TabloProjectCard(card, csrfToken)
}
} }
} </div>
</div> </section>
} }
} }
// TablosEmptyState renders the empty-state copy when a user has no tablos. // TablosEmptyState renders the empty-state copy when a user has no tablos.
// Copy strings are locked by UI-SPEC Copywriting Contract. // Copy strings are locked by UI-SPEC Copywriting Contract.
// Uses ui.EmptyState for consistent styling across the app (Phase 13).
templ TablosEmptyState() { templ TablosEmptyState() {
<div class="text-center py-16"> @ui.EmptyState(ui.EmptyStateProps{
<h2 class="text-xl font-semibold leading-snug text-slate-800">No tablos yet</h2> Title: "No tablos yet",
<p class="mt-2 text-base text-slate-600">Create your first tablo to get started.</p> Description: "Create your first tablo to get started.",
<div class="mt-6"> Action: ui.Button(ui.ButtonProps{
@ui.Button(ui.ButtonProps{ Label: "New tablo",
Label: "New tablo", Variant: ui.ButtonVariantDefault,
Variant: ui.ButtonVariantDefault, Tone: ui.ButtonToneSolid,
Tone: ui.ButtonToneSolid, Size: ui.SizeMD,
Size: ui.SizeMD, Type: "button",
Type: "button", Attrs: templ.Attributes{
Attrs: templ.Attributes{ "hx-get": "/tablos/new",
"hx-get": "/tablos/new", "hx-target": "#create-form-slot",
"hx-target": "#create-form-slot", "hx-swap": "innerHTML",
"hx-swap": "innerHTML", },
"aria-label": "Create your first tablo", }),
}, })
}) }
// TabloProjectCard renders a single tablo as a project-card in the dashboard grid.
// Follows D-C02 design: colored avatar circle, title zone (with inline-edit support),
// creation date, and edit/delete icon buttons.
// Guards color rendering against null pgtype.Text values (Pitfall 6).
// Uses .Time accessor on pgtype.Timestamptz (Pitfall 6).
templ TabloProjectCard(card TabloCardView, csrfToken string) {
<article id={ "tablo-" + card.Tablo.ID.String() } class="project-card">
<div class="project-card-top">
<div class="flex items-center gap-2">
@ui.IconButton(ui.IconButtonProps{
Label: "Edit title",
Icon: "pencil",
Variant: ui.IconButtonVariantNeutral,
Tone: ui.IconButtonToneGhost,
Type: "button",
Attrs: templ.Attributes{
"hx-get": "/tablos/" + card.Tablo.ID.String() + "/edit-title",
"hx-target": "closest .tablo-title-zone",
"hx-swap": "outerHTML",
},
})
<div class="tablo-delete-zone">
@ui.IconButton(ui.IconButtonProps{
Label: "Delete tablo",
Icon: "trash",
Variant: ui.IconButtonVariantDanger,
Tone: ui.IconButtonToneGhost,
Type: "button",
Attrs: templ.Attributes{
"hx-get": "/tablos/" + card.Tablo.ID.String() + "/delete-confirm",
"hx-target": "closest .tablo-delete-zone",
"hx-swap": "outerHTML",
},
})
</div>
</div>
</div> </div>
</div> <div class="project-card-title-row">
if card.Tablo.Color.Valid && card.Tablo.Color.String != "" {
<span class="project-avatar" style={ "background-color: " + card.Tablo.Color.String }></span>
} else {
<span class="project-avatar"></span>
}
<div class="tablo-title-zone">
<h4>{ card.Tablo.Title }</h4>
</div>
</div>
<div class="project-date-row">
{ card.Tablo.CreatedAt.Time.Format("Jan 2, 2006") }
</div>
</article>
} }
// TabloCard renders a single tablo as a ui.Card on the dashboard. // TabloCard renders a single tablo as a ui.Card on the dashboard.
@ -182,10 +235,11 @@ templ TabloCardWithOOBFormClear(tablo sqlc.Tablo, csrfToken string) {
// TabloDetailPage renders the full detail page for a single tablo with a 3-tab layout. // TabloDetailPage renders the full detail page for a single tablo with a 3-tab layout.
// Tabs: Overview / Tasks / Files. activeTab selects the initially rendered tab content. // Tabs: Overview / Tasks / Files. activeTab selects the initially rendered tab content.
// files and tasks are pre-fetched slices for the active tab (may be nil for inactive tabs). // files and tasks are pre-fetched slices for the active tab (may be nil for inactive tabs).
// activePath and sidebarTablos drive the AppLayout sidebar.
// UI-SPEC §3 Interaction Contract — GET /tablos/{id}. // UI-SPEC §3 Interaction Contract — GET /tablos/{id}.
// D-07: signature includes activeTab string param; D-08: tab bar links carry hx-push-url. // D-07: signature includes activeTab string param; D-08: tab bar links carry hx-push-url.
templ TabloDetailPage(user *auth.User, csrfToken string, tablo sqlc.Tablo, tasks []sqlc.Task, etapes []sqlc.Etape, counts EtapeTaskCounts, filter EtapeFilter, files []sqlc.TabloFile, events EventsCalendar, discussion DiscussionTabData, activeTab string) { templ TabloDetailPage(user *auth.User, csrfToken string, activePath string, sidebarTablos []sqlc.Tablo, tablo sqlc.Tablo, tasks []sqlc.Task, etapes []sqlc.Etape, counts EtapeTaskCounts, filter EtapeFilter, files []sqlc.TabloFile, events EventsCalendar, discussion DiscussionTabData, activeTab string) {
@Layout("Tablos — Xtablo", user, csrfToken) { @AppLayout("Tablos — Xtablo", user, csrfToken, activePath, sidebarTablos) {
<div class="mb-4"> <div class="mb-4">
<a href="/" class="text-sm text-slate-600 hover:underline">&larr; Back to tablos</a> <a href="/" class="text-sm text-slate-600 hover:underline">&larr; Back to tablos</a>
</div> </div>
@ -510,10 +564,10 @@ templ TabloDeleteConfirmFragment(tablo sqlc.Tablo, csrfToken string) {
// TabloNotFoundPage renders a 404 page for tablos that don't exist or are not // TabloNotFoundPage renders a 404 page for tablos that don't exist or are not
// accessible by the current user (D-04: 404 not 403 to avoid existence leakage). // accessible by the current user (D-04: 404 not 403 to avoid existence leakage).
// user may be nil when called from an unauthenticated context — Layout handles nil. // activePath and sidebarTablos drive the AppLayout sidebar (pass "" and empty slice for not-found).
// UI-SPEC Copywriting Contract: "Not found" + "This tablo doesn't exist or you don't have access." // UI-SPEC Copywriting Contract: "Not found" + "This tablo doesn't exist or you don't have access."
templ TabloNotFoundPage(user *auth.User, csrfToken string) { templ TabloNotFoundPage(user *auth.User, csrfToken string, activePath string, sidebarTablos []sqlc.Tablo) {
@Layout("Not found", user, csrfToken) { @AppLayout("Not found", user, csrfToken, activePath, sidebarTablos) {
<div class="py-16 text-center"> <div class="py-16 text-center">
<h1 class="text-2xl font-semibold leading-snug text-slate-800">Not found</h1> <h1 class="text-2xl font-semibold leading-snug text-slate-800">Not found</h1>
<p class="mt-2 text-base text-slate-600">This tablo doesn&#39;t exist or you don&#39;t have access.</p> <p class="mt-2 text-base text-slate-600">This tablo doesn&#39;t exist or you don&#39;t have access.</p>