alerts, toast amd breadcrum
This commit is contained in:
parent
aa651083cd
commit
1f95f86829
12 changed files with 525 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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 <ul class="alert-list">
|
||||
Important bool
|
||||
Minor bool
|
||||
ShowClose bool
|
||||
Action string // "Action" button text
|
||||
Link string // "Link" anchor text
|
||||
Buttons bool // "Okay" / "Cancel" buttons
|
||||
Avatar bool
|
||||
Class string
|
||||
}
|
||||
|
||||
// FormtablerBreadcrumbItem represents a single item in the breadcrumb trail.
|
||||
type FormtablerBreadcrumbItem struct {
|
||||
Title string
|
||||
Link string // empty for the last (active) item
|
||||
HomeIcon bool // render home icon instead of text for the first item
|
||||
}
|
||||
|
||||
// FormtablerBreadcrumb represents a breadcrumb navigation component.
|
||||
type FormtablerBreadcrumb struct {
|
||||
Items []FormtablerBreadcrumbItem
|
||||
Separator string // optional: "dots", "arrows", "bullets"
|
||||
Class string
|
||||
}
|
||||
|
||||
// FormtablerToast represents a toast notification component.
|
||||
type FormtablerToast struct {
|
||||
ID string
|
||||
Show bool
|
||||
HideHeader bool
|
||||
PersonName string
|
||||
PersonSrc string
|
||||
Date string
|
||||
Text string
|
||||
Cookies bool // renders cookie consent variant
|
||||
}
|
||||
|
||||
// FormtablerCardProgress represents a progress bar in the card.
|
||||
type FormtablerCardProgress struct {
|
||||
Percent int
|
||||
|
|
@ -431,6 +473,14 @@ type FormtablerFormElementsPage struct {
|
|||
ValidationStates FormtablerValidationStates
|
||||
}
|
||||
|
||||
// FormtablerComponentsPage is the page-specific struct for the combined demo
|
||||
// showing alerts, toasts, and breadcrumbs.
|
||||
type FormtablerComponentsPage struct {
|
||||
Alerts []FormtablerAlert
|
||||
Breadcrumbs []FormtablerBreadcrumb
|
||||
Toasts []FormtablerToast
|
||||
}
|
||||
|
||||
// TablerPageData holds the common data for all tabler pages.
|
||||
// It should NOT contain component-specific fields like tables or forms.
|
||||
// Add those by creating a page-specific struct that embeds TablerPageData
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue