1
0
Fork 0
forked from goffee/cup

Examples: href, badge, dropdown, list

This commit is contained in:
Diana 2024-10-15 16:15:47 -05:00
parent d5f7bda021
commit 7de2981810
2 changed files with 157 additions and 11 deletions

View file

@ -134,6 +134,7 @@ func Themeform(c *core.Context) *core.Response {
ID: "email", ID: "email",
Label: "Email", Label: "Email",
Type: "email", Type: "email",
IsRequired: true,
Placeholder: "Enter your email address", Placeholder: "Enter your email address",
}, },
FormButton: components.FormButton{ FormButton: components.FormButton{
@ -182,8 +183,10 @@ func ThemeElements(c *core.Context) *core.Response {
if TemplateEnable { if TemplateEnable {
type templateData struct { type templateData struct {
Buttons []components.FormButton Buttons []components.FormButton
Hrefs []components.FormHref Hrefs []components.ContentHref
Dropdowns []components.FormDropdown Badges []components.ContentBadge
Dropdowns []components.ContentDropdown
Lists []components.ContentList
Menus []components.PageNav Menus []components.PageNav
} }
buttons := []components.FormButton{ buttons := []components.FormButton{
@ -261,7 +264,7 @@ func ThemeElements(c *core.Context) *core.Response {
TypeClass: "outline-dark", TypeClass: "outline-dark",
}, },
} }
hrefs := []components.FormHref{ hrefs := []components.ContentHref{
{ {
Text: "href", Text: "href",
Link: "#", Link: "#",
@ -299,11 +302,65 @@ func ThemeElements(c *core.Context) *core.Response {
IsDisabled: true, IsDisabled: true,
}, },
} }
dropdowns := []components.FormDropdown{ badges := []components.ContentBadge{
{
Text: "primary",
TypeClass: "primary",
},
{
Text: "secondary",
TypeClass: "secondary",
},
{
Text: "success",
TypeClass: "success",
},
{
Text: "danger",
TypeClass: "danger",
},
{
Text: "warning",
TypeClass: "warning",
},
{
Text: "info",
TypeClass: "info",
},
{
Text: "light",
TypeClass: "light",
},
{
Text: "dark",
TypeClass: "dark",
},
{
Text: "outline",
TypeClass: "primary",
IsOutline: true,
},
{
Text: "outline",
TypeClass: "success",
IsOutline: true,
},
{
Text: "outline",
TypeClass: "danger",
IsOutline: true,
},
{
Text: "outline",
TypeClass: "warning",
IsOutline: true,
},
}
dropdowns := []components.ContentDropdown{
// dropdown // dropdown
{ {
Label: "dropdown", Label: "dropdown",
Items: []components.FormDropdownItem{ Items: []components.ContentDropdownItem{
{ {
Text: "item ", Text: "item ",
Link: "#", Link: "#",
@ -319,7 +376,7 @@ func ThemeElements(c *core.Context) *core.Response {
{ {
Label: "primary", Label: "primary",
TypeClass: "primary", TypeClass: "primary",
Items: []components.FormDropdownItem{ Items: []components.ContentDropdownItem{
{ {
Text: "item ", Text: "item ",
Link: "#", Link: "#",
@ -340,7 +397,7 @@ func ThemeElements(c *core.Context) *core.Response {
{ {
Label: "outline", Label: "outline",
TypeClass: "outline-primary", TypeClass: "outline-primary",
Items: []components.FormDropdownItem{ Items: []components.ContentDropdownItem{
{ {
Text: "item ", Text: "item ",
Link: "#", Link: "#",
@ -355,7 +412,59 @@ func ThemeElements(c *core.Context) *core.Response {
// items // items
}, },
} }
list := []components.ContentList{
// basic list
{
Items: []components.ContentListItem{
{
Text: "item 1",
},
{
Text: "item 2",
EndElement: "end text",
},
{
Text: "item disabled",
IsDisabled: true,
},
},
},
// description list
{
Items: []components.ContentListItem{
{
Text: "item 1",
Description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ",
},
{
Text: "item 2",
Description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
},
{
Text: "item disabled",
Description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
IsDisabled: true,
},
},
},
// list with class
{
Items: []components.ContentListItem{
{
Text: "class primary",
TypeClass: "primary",
},
{
Text: "class success",
TypeClass: "success",
},
{
Text: "class danger",
TypeClass: "danger",
},
},
},
}
menus := []components.PageNav{ menus := []components.PageNav{
// nav // nav
{ {
@ -505,7 +614,9 @@ func ThemeElements(c *core.Context) *core.Response {
tmplData := templateData{ tmplData := templateData{
Buttons: buttons, Buttons: buttons,
Hrefs: hrefs, Hrefs: hrefs,
Badges: badges,
Dropdowns: dropdowns, Dropdowns: dropdowns,
Lists: list,
Menus: menus, Menus: menus,
} }
return c.Response.Template("custom_theme_elements.html", tmplData) return c.Response.Template("custom_theme_elements.html", tmplData)
@ -545,6 +656,12 @@ func Themecontent(c *core.Context) *core.Response {
th.ID = "ba" th.ID = "ba"
th.Value = "Column heading 3" th.Value = "Column heading 3"
allTh = append(allTh, th) allTh = append(allTh, th)
th.Value = "Column badge"
th.ValueType = "badge" // column type badge
allTh = append(allTh, th)
th.Value = "Column action"
th.ValueType = "href" // column type href
allTh = append(allTh, th)
// for td items // for td items
var allTd [][]components.ContentTableTD var allTd [][]components.ContentTableTD
@ -552,10 +669,20 @@ func Themecontent(c *core.Context) *core.Response {
// rows // rows
for i := 1; i <= 10; i++ { for i := 1; i <= 10; i++ {
vals := make([]components.ContentTableTD, len(allTh)) vals := make([]components.ContentTableTD, len(allTh))
for b := 0; b < len(allTh); b++ { for b := 0; b < len(allTh)-2; b++ {
vals[b].Value = fmt.Sprintf("%s%d%d", "TD data: ", i, b) vals[b].Value = fmt.Sprintf("%s%d%d", "TD data: ", i, b)
vals[b].ID = fmt.Sprintf("%s%d%d", "idtd_", i, b) vals[b].ID = fmt.Sprintf("%s%d%d", "idtd_", i, b)
} }
// column badge
vals[len(allTh)-2].Value = components.ContentBadge{
Text: "success",
TypeClass: "success",
}
// last column href
vals[len(allTh)-1].Value = components.ContentHref{
Text: "edit",
Link: "#",
}
allTd = append(allTd, vals) allTd = append(allTd, vals)
} }

View file

@ -16,7 +16,16 @@
<legend>Demos href</legend> <legend>Demos href</legend>
<div class="container d-flex justify-content-between border rounded-3 p-2"> <div class="container d-flex justify-content-between border rounded-3 p-2">
{{range .Hrefs}} {{range .Hrefs}}
{{template "form_href" .}} {{template "content_href" .}}
{{end}}
</div>
</fieldset>
<fieldset class="mb-3">
<legend>Demos Badges</legend>
<div class="container d-flex justify-content-between border rounded-3 p-2">
{{range .Badges}}
{{template "content_badge" .}}
{{end}} {{end}}
</div> </div>
</fieldset> </fieldset>
@ -26,7 +35,17 @@
<legend>Demos dropdown</legend> <legend>Demos dropdown</legend>
<div class="container d-flex justify-content-between border rounded-3 p-2"> <div class="container d-flex justify-content-between border rounded-3 p-2">
{{range .Dropdowns}} {{range .Dropdowns}}
{{template "form_dropdown" .}} {{template "content_dropdown" .}}
{{end}}
</div>
</fieldset>
<fieldset class="mb-3">
<legend>Demos List</legend>
<div class="container d-flex justify-content-between border rounded-3 p-2">
{{range .Lists}}
{{template "content_list" .}}
{{end}} {{end}}
</div> </div>
</fieldset> </fieldset>