Documentation
¶
Overview ¶
Package notificationtoast renders a stack of dismissible, level-aware notifications. Each toast carries a level, an optional title, and a message. Toasts auto-expire after a per-toast TTL or stay until the consumer explicitly dismisses them.
The tray is render-only: pump time forward by calling Tick(now) on a timer in your Update function and the tray drops expired toasts. Push adds a new toast; Dismiss removes one by ID.
Index ¶
- type Level
- type Toast
- type Tray
- func (tr Tray) Dismiss(id string) Tray
- func (tr Tray) DismissAll() Tray
- func (tr Tray) Init() tea.Cmd
- func (tr Tray) Push(t Toast) Tray
- func (tr Tray) Tick(now time.Time) Tray
- func (tr Tray) Toasts() []Toast
- func (tr Tray) Update(_ tea.Msg) (Tray, tea.Cmd)
- func (tr Tray) View() string
- func (tr Tray) WithMaxItems(n int) Tray
- func (tr Tray) WithWidth(w int) Tray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Toast ¶
type Toast struct {
ID string
Level Level
Title string
Message string
ExpiresAt time.Time // zero value means no auto-dismiss
}
Toast is a single notification.
type Tray ¶
type Tray struct {
// contains filtered or unexported fields
}
Tray holds the active toasts and renders them as a vertical stack.
func (Tray) Update ¶
Update is a no-op. The tray is driven by external Push/Dismiss/Tick. It is implemented so the type satisfies tea.Model for composition.
func (Tray) View ¶
View renders the tray as a vertical stack of cards separated by a blank line. Empty tray renders to empty string.
func (Tray) WithMaxItems ¶
WithMaxItems caps the number of toasts shown at once. Older toasts drop first when capacity is exceeded.
