David Vogel
69160e02c4
- Rename overlay-classes.go to interfaces.go - Add event parameter to AddToast method - Update overlay example page
38 lines
853 B
Go
38 lines
853 B
Go
package overlay
|
|
|
|
import "time"
|
|
|
|
type ToastMessageType int
|
|
|
|
const (
|
|
ToastMessageTypeSuccess ToastMessageType = iota
|
|
ToastMessageTypeAttention
|
|
ToastMessageTypeCaution
|
|
ToastMessageTypeCritical
|
|
)
|
|
|
|
type ToastMessage struct {
|
|
MessageType ToastMessageType `vugu:"data"`
|
|
Message string `vugu:"data"`
|
|
Duration time.Duration // Auto close toast after this duration.
|
|
}
|
|
|
|
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 "", ""
|
|
}
|
|
|
|
func (c *ToastMessage) ToastDuration() time.Duration {
|
|
return c.Duration
|
|
}
|