From 1f95f868291924aa51014dc867aaad7c6474996b Mon Sep 17 00:00:00 2001 From: JACS Date: Sun, 3 May 2026 00:06:23 -0500 Subject: [PATCH] alerts, toast amd breadcrum --- controllers/tablerbase.go | 25 ++ controllers/tablerdata.go | 97 ++++++++ controllers/tablertypes.go | 50 ++++ routes.go | 3 +- storage/templates/tabler/includes/alert.html | 40 ++++ .../templates/tabler/includes/breadcrumb.html | 22 ++ .../tabler/includes/components_content.html | 36 +++ storage/templates/tabler/includes/toast.html | 23 ++ storage/templates/tabler/layouts/default.html | 2 + storage/templates/tabler_components.html | 1 + storage/templates/tabler_homepage.html | 1 + template-helpers.md | 226 ++++++++++++++++++ 12 files changed, 525 insertions(+), 1 deletion(-) create mode 100644 storage/templates/tabler/includes/alert.html create mode 100644 storage/templates/tabler/includes/breadcrumb.html create mode 100644 storage/templates/tabler/includes/components_content.html create mode 100644 storage/templates/tabler/includes/toast.html create mode 100644 storage/templates/tabler_components.html create mode 100644 storage/templates/tabler_homepage.html create mode 100644 template-helpers.md diff --git a/controllers/tablerbase.go b/controllers/tablerbase.go index d5aad5d..2197445 100644 --- a/controllers/tablerbase.go +++ b/controllers/tablerbase.go @@ -69,6 +69,31 @@ func TablerNavbar(c *core.Context) *core.Response { return c.Response.Template("tabler_default.html", data) } +// TablerComponents renders a page with alerts, breadcrumbs, and toasts. +// Uses the composition pattern: embeds TablerPageData and adds Components. +func TablerComponents(c *core.Context) *core.Response { + type componentsPageData struct { + TablerPageData + Components FormtablerComponentsPage + } + data := componentsPageData{ + TablerPageData: TablerPageData{ + PageTitle: "UI Components", + PageDescription: "Alerts, breadcrumbs and toasts demo", + ShowTopbar: true, + Sidebar: false, + PageHeader: "Components", + PagePretitle: "UI Elements", + UserName: "Jane Doe", + UserRole: "Administrator", + NavbarMenu: SampleNavbarMenu(), + Content: template.HTML(""), + }, + Components: SampleComponents(), + } + return c.Response.Template("tabler_components.html", data) +} + // TablerCards renders a page with card component demos. // Uses the composition pattern: embeds TablerPageData and adds Cards. func TablerCards(c *core.Context) *core.Response { diff --git a/controllers/tablerdata.go b/controllers/tablerdata.go index 9e72e53..0c7b12d 100644 --- a/controllers/tablerdata.go +++ b/controllers/tablerdata.go @@ -44,6 +44,103 @@ func SampleNavbarMenu() TablerMenu { } } +// SampleComponents returns sample data for alerts, breadcrumbs, and toasts. +func SampleComponents() FormtablerComponentsPage { + return FormtablerComponentsPage{ + Alerts: []FormtablerAlert{ + { + Type: "success", + Title: "Success alert!", + ShowClose: true, + }, + { + Type: "warning", + Title: "Warning alert with description", + Description: "This is a warning alert with additional description text to provide more context to the user.", + List: []string{"Item one is important", "Item two requires attention", "Item three is optional"}, + }, + { + Type: "danger", + Title: "Danger alert", + Action: "Undo", + Buttons: true, + }, + { + Type: "info", + Title: "Info alert with link", + Link: "Learn more", + ShowClose: true, + }, + { + Type: "success", + Title: "Important alert", + Important: true, + ShowClose: true, + }, + { + Type: "warning", + Title: "Minor alert variant", + Minor: true, + }, + }, + Breadcrumbs: []FormtablerBreadcrumb{ + { + Items: []FormtablerBreadcrumbItem{ + {Title: "Home", Link: "/", HomeIcon: true}, + {Title: "Library", Link: "/library"}, + {Title: "Data"}, + }, + }, + { + Separator: "arrows", + Items: []FormtablerBreadcrumbItem{ + {Title: "Dashboard", Link: "/"}, + {Title: "Components", Link: "/components"}, + {Title: "Alerts"}, + }, + }, + { + Separator: "dots", + Items: []FormtablerBreadcrumbItem{ + {Title: "Home", Link: "/", HomeIcon: true}, + {Title: "Settings", Link: "/settings"}, + {Title: "Profile"}, + }, + }, + }, + Toasts: []FormtablerToast{ + { + ID: "simple", + Show: true, + PersonName: "Paweł Kuna", + PersonSrc: "/static/avatars/000m.jpg", + Date: "2 mins ago", + Text: "Hello, world! This is a toast message.", + }, + { + ID: "avatar-toast", + Show: true, + PersonName: "Jeffie Lewzey", + PersonSrc: "/static/avatars/052f.jpg", + Date: "5 mins ago", + Text: "Your report has been generated successfully.", + }, + { + ID: "cookies", + Show: true, + Date: "just now", + Cookies: true, + }, + { + ID: "no-header", + Show: true, + HideHeader: true, + Text: "This toast has no header — just a plain message body.", + }, + }, + } +} + // SampleCards returns 6 sample cards showing different variants. func SampleCards() []FormtablerCard { defaultBody := &FormtablerCardBody{ diff --git a/controllers/tablertypes.go b/controllers/tablertypes.go index dbac532..f076f7b 100644 --- a/controllers/tablertypes.go +++ b/controllers/tablertypes.go @@ -369,6 +369,48 @@ type FormtablerCardBody struct { ButtonLink string } +// FormtablerAlert represents a single alert component. +type FormtablerAlert struct { + Type string // "success", "warning", "danger", "info" + Title string + Description string + List []string // if set, renders as