htmgo/htmgo-site/pages/examples/sidebar.go

49 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-10-28 16:39:46 +00:00
package examples
2024-10-28 15:32:50 +00:00
import (
"github.com/maddalax/htmgo/framework/datastructure/orderedmap"
2024-10-28 15:32:50 +00:00
"github.com/maddalax/htmgo/framework/h"
)
func SnippetSidebar() *h.Element {
grouped := h.GroupByOrdered(examples, func(example Snippet) string {
return example.category
})
2024-10-28 15:32:50 +00:00
return h.Div(
h.Class("px-3 py-2 pr-6 md:min-h-screen pb-4 mb:pb-0 bg-neutral-50 border-r border-r-slate-300 overflow-y-auto"),
h.Div(
h.Div(
h.Class("mb-3"),
h.A(
h.Href("#"),
2024-10-28 15:56:03 +00:00
h.Text("Examples"),
2024-10-28 15:32:50 +00:00
h.Class("md:mt-4 text-xl text-slate-900 font-bold"),
),
),
h.Div(
h.Class("flex flex-col gap-2"),
h.List(grouped.Entries(), func(entry orderedmap.Entry[string, []Snippet], index int) *h.Element {
return h.Div(
h.P(
h.Text(entry.Key),
h.Class("text-slate-800 font-bold"),
),
h.Div(
h.Class("pl-4 flex flex-col"),
h.List(entry.Value, func(entry Snippet, index int) *h.Element {
return h.A(
h.Href(entry.path),
h.Text(entry.sidebarName),
h.Class("text-slate-900 hover:text-rose-400"),
)
}),
),
2024-10-28 15:32:50 +00:00
)
}),
),
),
)
}