diff --git a/components/navigation/sidebar.go b/components/navigation/sidebar.go index 3325a6a..e8d6e7a 100644 --- a/components/navigation/sidebar.go +++ b/components/navigation/sidebar.go @@ -10,8 +10,9 @@ type Sidebar struct { 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. - Minimized bool `vugu:"data"` // If true, the sidebar is reduced to icons. - sidebarClasses string `vugu:"data"` + Minimized bool `vugu:"data"` // If true, the sidebar is reduced to icons. + sidebarClasses string + bodyOverlayStyle string } func (c *Sidebar) Init(ctx vugu.InitCtx) { @@ -21,11 +22,17 @@ func (c *Sidebar) Init(ctx vugu.InitCtx) { func (c *Sidebar) Compute(ctx vugu.ComputeCtx) { if c.Minimized { c.sidebarClasses = "d3c-1633357633-sidebar-minimized" + c.bodyOverlayStyle = "display: none;" } else { c.sidebarClasses = "" + c.bodyOverlayStyle = "" } } func (c *Sidebar) handleMenuButton(event vugu.DOMEvent) { c.Minimized = !c.Minimized } + +func (c *Sidebar) handleOverlayClick(event vugu.DOMEvent) { + c.Minimized = true +} diff --git a/components/navigation/sidebar.vugu b/components/navigation/sidebar.vugu index 55d1706..8f51a39 100644 --- a/components/navigation/sidebar.vugu +++ b/components/navigation/sidebar.vugu @@ -16,6 +16,8 @@