2023-05-08 18:43:07 +00:00
|
|
|
package navigation
|
|
|
|
|
|
|
|
import "github.com/vugu/vugu"
|
|
|
|
|
|
|
|
type Sidebar struct {
|
|
|
|
AttrMap vugu.AttrMap
|
|
|
|
|
2023-05-16 16:10:24 +00:00
|
|
|
MenuEntries vugu.Builder `vugu:"data"` // Menu content at the top. Either embedded into the sidebar or at the top edge.
|
|
|
|
Entries vugu.Builder `vugu:"data"` // Main content of the sidebar.
|
|
|
|
BottomEntries vugu.Builder `vugu:"data"` // Static bottom part of the sidebar.
|
|
|
|
Body vugu.Builder `vugu:"data"` // The body contains the content that is right to or behind the sidebar.
|
2023-05-08 18:43:07 +00:00
|
|
|
|
2023-05-18 15:46:33 +00:00
|
|
|
Minimized bool `vugu:"data"` // If true, the sidebar is reduced to icons.
|
|
|
|
sidebarClasses string
|
|
|
|
showBodyOverlay bool
|
2023-05-12 10:57:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Sidebar) Init(ctx vugu.InitCtx) {
|
|
|
|
c.Minimized = true // Sidebar defaults to minimized.
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Sidebar) Compute(ctx vugu.ComputeCtx) {
|
|
|
|
if c.Minimized {
|
2023-05-25 13:59:13 +00:00
|
|
|
c.sidebarClasses = "d3c-1633357633-sidebar-minimized d3c-button-only-icon"
|
2023-05-18 15:46:33 +00:00
|
|
|
c.showBodyOverlay = false
|
2023-05-12 10:57:42 +00:00
|
|
|
} else {
|
|
|
|
c.sidebarClasses = ""
|
2023-05-18 15:46:33 +00:00
|
|
|
c.showBodyOverlay = true
|
2023-05-12 10:57:42 +00:00
|
|
|
}
|
2023-05-08 18:43:07 +00:00
|
|
|
}
|
|
|
|
|
2023-05-12 10:57:42 +00:00
|
|
|
func (c *Sidebar) handleMenuButton(event vugu.DOMEvent) {
|
|
|
|
c.Minimized = !c.Minimized
|
2023-05-08 18:43:07 +00:00
|
|
|
}
|
2023-05-18 13:48:19 +00:00
|
|
|
|
|
|
|
func (c *Sidebar) handleOverlayClick(event vugu.DOMEvent) {
|
|
|
|
c.Minimized = true
|
|
|
|
}
|