D3vugu-components/page-overlays.go
David Vogel 518c47ab47 Improve overlay package
- Add toast overlays
- Add a way to color overlay containers and menus
- Add d3c-button-transparent CSS class
- Update overlay example page
2023-05-19 23:45:39 +02:00

42 lines
1.5 KiB
Go

package main
import (
"time"
"git.d3nexus.de/Dadido3/D3vugu-components/components/input"
"git.d3nexus.de/Dadido3/D3vugu-components/components/overlay"
"git.d3nexus.de/Dadido3/D3vugu-components/icons"
"github.com/vugu/vugu"
)
type PageOverlays struct {
overlay.OverlayContainerRef
}
func (c *PageOverlays) handleSimpleModalButton(event vugu.DOMEvent) {
c.SetModal(&overlay.ModalRequester{
SymbolSlot: &icons.LInfoCircle{AttrMap: vugu.AttrMap{"style": "font-size: 2em;"}},
Title: "Simple requester",
Message: "This is a simple modal requester, are you happy with it?\nIt also supports multi line text!",
SignalColor: "d3c-color-accent",
ClickAbort: input.ClickFunc(func(event input.ClickEvent) {}),
ClickYes: input.ClickFunc(func(event input.ClickEvent) {}),
})
}
func (c *PageOverlays) handleSimpleToastButton(event vugu.DOMEvent) {
c.AddToast(&overlay.ToastSimple{
SymbolSlot: &icons.LInfoCircle{AttrMap: vugu.AttrMap{"style": "font-size: 2em;"}},
Message: "This is a simple toast!\nIt supports multiple lines and has an icon slot.\nThere also can be multiple of it at the same time, this one was opened at " + time.Now().Format(time.TimeOnly) + ".",
SignalColor: "d3c-color-accent",
})
}
func (c *PageOverlays) handleWarningToastButton(event vugu.DOMEvent) {
c.AddToast(&overlay.ToastSimple{
SymbolSlot: &icons.LWarning{AttrMap: vugu.AttrMap{"style": "font-size: 2em;", "class": "d3c-color-caution d3c-icon-use-color"}},
Message: "This is a warning, be careful!",
SignalColor: "d3c-color-caution",
})
}