D3vugu-components/components/navigation/sidebar-entry.go

32 lines
719 B
Go
Raw Normal View History

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
IconSlot 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-button-highlight"
} else {
c.classes = ""
}
}