Add ToastMessage
- Remove OverlayContainerRef from toast components - Update overlay example pagemaster
parent
852fd54082
commit
9b07b21ab5
@ -0,0 +1,30 @@
|
||||
package overlay
|
||||
|
||||
type ToastMessageType int
|
||||
|
||||
const (
|
||||
ToastMessageTypeSuccess ToastMessageType = iota
|
||||
ToastMessageTypeAttention
|
||||
ToastMessageTypeCaution
|
||||
ToastMessageTypeCritical
|
||||
)
|
||||
|
||||
type ToastMessage struct {
|
||||
MessageType ToastMessageType `vugu:"data"`
|
||||
Message string `vugu:"data"`
|
||||
}
|
||||
|
||||
func (c *ToastMessage) OverlayClasses() (signalClasses, containerClasses string) {
|
||||
switch c.MessageType {
|
||||
case ToastMessageTypeSuccess:
|
||||
return "d3c-color-success", ""
|
||||
case ToastMessageTypeAttention:
|
||||
return "d3c-color-attention", ""
|
||||
case ToastMessageTypeCaution:
|
||||
return "d3c-color-caution", ""
|
||||
case ToastMessageTypeCritical:
|
||||
return "d3c-color-critical", ""
|
||||
}
|
||||
|
||||
return "", ""
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<div>
|
||||
<layout:Container>
|
||||
<div class="d3c-1685271365-flex">
|
||||
<icons:LInfoCircle vg-if="c.MessageType == ToastMessageTypeAttention" style="font-size: 2em;"></icons:LInfoCircle>
|
||||
<icons:LWarning vg-if="c.MessageType == ToastMessageTypeCaution" style="font-size: 2em;"></icons:LWarning>
|
||||
<icons:LWarning vg-if="c.MessageType == ToastMessageTypeCritical" style="font-size: 2em;"></icons:LWarning>
|
||||
<span vg-content="c.Message" style="white-space: pre-wrap;"></span>
|
||||
</div>
|
||||
</layout:Container>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.d3c-1685271365-flex {
|
||||
margin: 0.5em 0;
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="application/x-go">
|
||||
import (
|
||||
"git.d3nexus.de/Dadido3/D3vugu-components/components/layout"
|
||||
"git.d3nexus.de/Dadido3/D3vugu-components/icons"
|
||||
)
|
||||
</script>
|
@ -0,0 +1,145 @@
|
||||
package overlay
|
||||
|
||||
// Code generated by vugu via vugugen. Please regenerate instead of editing or add additional code in a separate file. DO NOT EDIT.
|
||||
|
||||
import "fmt"
|
||||
import "reflect"
|
||||
import "github.com/vugu/vjson"
|
||||
import "github.com/vugu/vugu"
|
||||
import js "github.com/vugu/vugu/js"
|
||||
|
||||
import (
|
||||
"git.d3nexus.de/Dadido3/D3vugu-components/components/layout"
|
||||
"git.d3nexus.de/Dadido3/D3vugu-components/icons"
|
||||
)
|
||||
|
||||
func (c *ToastMessage) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
|
||||
vgout = &vugu.BuildOut{}
|
||||
|
||||
var vgiterkey interface{}
|
||||
_ = vgiterkey
|
||||
var vgn *vugu.VGNode
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(3), Namespace: "", Data: "div", Attr: []vugu.VGAttribute(nil)}
|
||||
vgout.Out = append(vgout.Out, vgn) // root for output
|
||||
{
|
||||
vgparent := vgn
|
||||
_ = vgparent
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xFE91A85B84F1D501^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*layout.Container)
|
||||
if vgcomp == nil {
|
||||
// create new one if needed
|
||||
vgcomp = new(layout.Container)
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.DefaultSlot = vugu.NewBuilderFunc(func(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn := &vugu.VGNode{Type: vugu.VGNodeType(3)}
|
||||
vgout = &vugu.BuildOut{}
|
||||
vgout.Out = append(vgout.Out, vgn)
|
||||
vgparent := vgn
|
||||
_ = vgparent
|
||||
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(3), Namespace: "", Data: "div", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "d3c-1685271365-flex"}}}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgparent := vgn
|
||||
_ = vgparent
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
if c.MessageType == ToastMessageTypeAttention {
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xDF2F2876D736456A^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*icons.LInfoCircle)
|
||||
if vgcomp == nil {
|
||||
// create new one if needed
|
||||
vgcomp = new(icons.LInfoCircle)
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.AttrMap = make(map[string]interface{}, 8)
|
||||
vgcomp.AttrMap["style"] = "font-size: 2em;"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
vgparent.AppendChild(vgn)
|
||||
}
|
||||
}
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
if c.MessageType == ToastMessageTypeCaution {
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xA70DD6C2A5BD0087^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*icons.LWarning)
|
||||
if vgcomp == nil {
|
||||
// create new one if needed
|
||||
vgcomp = new(icons.LWarning)
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.AttrMap = make(map[string]interface{}, 8)
|
||||
vgcomp.AttrMap["style"] = "font-size: 2em;"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
vgparent.AppendChild(vgn)
|
||||
}
|
||||
}
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
if c.MessageType == ToastMessageTypeCritical {
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xA3F6AC7E68746E21^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*icons.LWarning)
|
||||
if vgcomp == nil {
|
||||
// create new one if needed
|
||||
vgcomp = new(icons.LWarning)
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.AttrMap = make(map[string]interface{}, 8)
|
||||
vgcomp.AttrMap["style"] = "font-size: 2em;"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
vgparent.AppendChild(vgn)
|
||||
}
|
||||
}
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(3), Namespace: "", Data: "span", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "style", Val: "white-space: pre-wrap;"}}}
|
||||
vgparent.AppendChild(vgn)
|
||||
vgn.SetInnerHTML(c.Message)
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
}
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
return
|
||||
})
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
vgparent.AppendChild(vgn)
|
||||
}
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n"}
|
||||
vgparent.AppendChild(vgn)
|
||||
}
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "style", Attr: []vugu.VGAttribute(nil)}
|
||||
{
|
||||
vgn.AppendChild(&vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t.d3c-1685271365-flex {\n\t\tmargin: 0.5em 0;\n\t\tdisplay: flex;\n\t\tgap: 0.5em;\n\t}\n", Attr: []vugu.VGAttribute(nil)})
|
||||
}
|
||||
vgout.AppendCSS(vgn)
|
||||
return vgout
|
||||
}
|
||||
|
||||
// 'fix' unused imports
|
||||
var _ fmt.Stringer
|
||||
var _ reflect.Type
|
||||
var _ vjson.RawMessage
|
||||
var _ js.Value
|
Loading…
Reference in New Issue