D3vugu-components/components/navigation/sidebar-entry.go
David Vogel 2cce3fc57a Add tag and list container components
- Update example pages
- Move some structures from go into vugu files
- Change sidebar Navigate to MustNavigate
2023-05-17 21:37:24 +02:00

32 lines
722 B
Go

package navigation
import (
"github.com/vugu/vgrouter"
"github.com/vugu/vugu"
)
type SidebarEntry struct {
vgrouter.NavigatorRef
PageInfoRef
AttrMap vugu.AttrMap
classes string `vugu:"data"` // TODO: Use AttrMap to handle classes or something else
SymbolSlot vugu.Builder `vugu:"data"` // Slot for the symbol.
DefaultSlot vugu.Builder `vugu:"data"` // Slot for the text and other stuff. Should be a div element!
URL string `vugu:"data"`
}
func (c *SidebarEntry) handleClick(event vugu.DOMEvent) {
c.MustNavigate(c.URL, nil)
}
func (c *SidebarEntry) Compute(ctx vugu.ComputeCtx) {
if c.PageInfo != nil && c.PageInfo.Path == c.URL {
c.classes = "d3c-1683622560-selected"
} else {
c.classes = ""
}
}