D3vugu-components/components/overlay/toast-message.go

38 lines
853 B
Go
Raw Permalink Normal View History

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
}