lyrics

lyrics
git clone git://brookjeynes.dev/bjeynes/lyrics.git
Log | Files | Refs

toast.go (345B)


      1 package toast
      2 
      3 import "encoding/json"
      4 
      5 type ToastType = string
      6 
      7 const (
      8 	ToastTypeError ToastType = "error"
      9 )
     10 
     11 type Toast struct {
     12 	Type ToastType
     13 	Body string
     14 }
     15 
     16 func (t *Toast) Marshal() ([]byte, error) {
     17 	trigger := map[string]any{
     18 		"HXToast": map[string]string{
     19 			"type": t.Type,
     20 			"body": t.Body,
     21 		},
     22 	}
     23 	return json.Marshal(trigger)
     24 }