2023-05-28 11:39:43 +00:00
|
|
|
package overlay
|
|
|
|
|
2023-05-28 13:04:18 +00:00
|
|
|
import "time"
|
|
|
|
|
2023-05-28 11:39:43 +00:00
|
|
|
type ToastMessageType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
ToastMessageTypeSuccess ToastMessageType = iota
|
|
|
|
ToastMessageTypeAttention
|
|
|
|
ToastMessageTypeCaution
|
|
|
|
ToastMessageTypeCritical
|
|
|
|
)
|
|
|
|
|
|
|
|
type ToastMessage struct {
|
|
|
|
MessageType ToastMessageType `vugu:"data"`
|
|
|
|
Message string `vugu:"data"`
|
2023-05-28 13:04:18 +00:00
|
|
|
Duration time.Duration // Auto close toast after this duration.
|
2023-05-28 11:39:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 "", ""
|
|
|
|
}
|
2023-05-28 13:04:18 +00:00
|
|
|
|
|
|
|
func (c *ToastMessage) ToastDuration() time.Duration {
|
|
|
|
return c.Duration
|
|
|
|
}
|