Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyPreset(style lipgloss.Style, presetName string) lipgloss.Style
- func CalculateMaxToasts(screenHeight int) int
- func CalculateToastWidth(screenWidth int) int
- func CriticalError(message string) tea.Cmd
- func DeleteNotification(itemName string, undoCmd tea.Cmd) tea.Cmd
- func DismissAllToasts() tea.Cmd
- func DismissToast(id string) tea.Cmd
- func GetActionStyle() lipgloss.Style
- func GetDefaultIcon(toastType ToastType) string
- func GetDismissStyle() lipgloss.Style
- func GetIconStyle(toastType ToastType) lipgloss.Style
- func GetSpinnerFrame(progress float64, style string) string
- func GetTitleStyle(toastType ToastType) lipgloss.Style
- func GetToastStyle(toastType ToastType, width int) lipgloss.Style
- func LongWarning(message string) tea.Cmd
- func NetworkErrorNotification(retryCmd tea.Cmd) tea.Cmd
- func QuickInfo(message string) tea.Cmd
- func QuickSuccess(message string) tea.Cmd
- func SaveNotification(filename string, undoCmd tea.Cmd) tea.Cmd
- func ShowCustomToast(config ToastConfig) tea.Cmd
- func ShowError(message string) tea.Cmd
- func ShowErrorWithTitle(title, message string) tea.Cmd
- func ShowInfo(message string) tea.Cmd
- func ShowInfoWithTitle(title, message string) tea.Cmd
- func ShowLoading(message string) tea.Cmd
- func ShowLoadingWithTitle(title, message string) tea.Cmd
- func ShowPersistentToast(toastType ToastType, message string) tea.Cmd
- func ShowProgressToast(message string) tea.Cmd
- func ShowSuccess(message string) tea.Cmd
- func ShowSuccessWithTitle(title, message string) tea.Cmd
- func ShowTemporaryToast(toastType ToastType, message string, duration time.Duration) tea.Cmd
- func ShowToastWithAction(toastType ToastType, message string, actionLabel string, actionCmd tea.Cmd) tea.Cmd
- func ShowUndoableToast(message string, undoCmd tea.Cmd) tea.Cmd
- func ShowWarning(message string) tea.Cmd
- func ShowWarningWithTitle(title, message string) tea.Cmd
- type DismissAllToastsMsg
- type DismissToastMsg
- type ShowToastMsg
- type Toast
- func (t *Toast) Config() ToastConfig
- func (t *Toast) Dismiss() tea.Cmd
- func (t *Toast) GetHeight() int
- func (t *Toast) GetOpacity() float64
- func (t *Toast) GetWidth() int
- func (t *Toast) ID() string
- func (t *Toast) Init() tea.Cmd
- func (t *Toast) IsDismissed() bool
- func (t *Toast) IsExpired() bool
- func (t *Toast) IsFadingOut() bool
- func (t *Toast) SetValue(value float64)
- func (t *Toast) SetWidth(width int)
- func (t *Toast) StartFadeIn() tea.Cmd
- func (t *Toast) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (t *Toast) View() string
- type ToastAction
- type ToastActionMsg
- type ToastBuilder
- func (b *ToastBuilder) Build() tea.Cmd
- func (b *ToastBuilder) Dismissible(dismissible bool) *ToastBuilder
- func (b *ToastBuilder) Persistent() *ToastBuilder
- func (b *ToastBuilder) WithAction(label string, cmd tea.Cmd) *ToastBuilder
- func (b *ToastBuilder) WithDuration(duration time.Duration) *ToastBuilder
- func (b *ToastBuilder) WithIcon(icon string) *ToastBuilder
- func (b *ToastBuilder) WithMessage(message string) *ToastBuilder
- func (b *ToastBuilder) WithPosition(position ToastPosition) *ToastBuilder
- func (b *ToastBuilder) WithTitle(title string) *ToastBuilder
- type ToastConfig
- type ToastExpiredMsg
- type ToastManager
- func (m *ToastManager) ClearQueue()
- func (m *ToastManager) DismissAll() tea.Cmd
- func (m *ToastManager) DismissToast(id string) tea.Cmd
- func (m *ToastManager) GetMaxToasts() int
- func (m *ToastManager) GetPosition() ToastPosition
- func (m *ToastManager) GetQueueLength() int
- func (m *ToastManager) GetToasts() []*Toast
- func (m *ToastManager) HasToasts() bool
- func (m *ToastManager) Init() tea.Cmd
- func (m *ToastManager) IsEnabled() bool
- func (m *ToastManager) RemoveToast(id string)
- func (m *ToastManager) SetEnabled(enabled bool)
- func (m *ToastManager) SetMaxToasts(max int)
- func (m *ToastManager) SetPosition(pos ToastPosition)
- func (m *ToastManager) SetSize(width, height int)
- func (m *ToastManager) ShowError(message string) tea.Cmd
- func (m *ToastManager) ShowInfo(message string) tea.Cmd
- func (m *ToastManager) ShowLoading(message string) tea.Cmd
- func (m *ToastManager) ShowSuccess(message string) tea.Cmd
- func (m *ToastManager) ShowToast(config ToastConfig) tea.Cmd
- func (m *ToastManager) ShowWarning(message string) tea.Cmd
- func (m *ToastManager) Stats() string
- func (m *ToastManager) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *ToastManager) View() string
- type ToastPosition
- type ToastStylePreset
- type ToastTickMsg
- type ToastType
Constants ¶
const ( // Info colors (blue) InfoBorderColor = "63" // Blue InfoBackgroundColor = "235" // Dark gray InfoTextColor = "255" // White // Success colors (green) SuccessBorderColor = "10" // Green SuccessBackgroundColor = "235" // Dark gray SuccessTextColor = "255" // White // Warning colors (yellow/orange) WarningBorderColor = "11" // Yellow WarningBackgroundColor = "235" // Dark gray WarningTextColor = "255" // White // Error colors (red) ErrorBorderColor = "9" // Red ErrorBackgroundColor = "235" // Dark gray ErrorTextColor = "255" // White // Loading colors (purple/magenta) LoadingBorderColor = "13" // Magenta LoadingBackgroundColor = "235" // Dark gray LoadingTextColor = "255" // White )
Color constants for toast types
Variables ¶
var AlternativeSpinnerFrames = []string{
"◐", "◓", "◑", "◒",
}
AlternativeSpinnerFrames provides an alternative spinner style
var DotsSpinnerFrames = []string{
"⠋", "⠙", "⠚", "⠞", "⠖", "⠦", "⠴", "⠲", "⠳", "⠓",
}
DotsSpinnerFrames provides a dots-based spinner
var SpinnerFrames = []string{
"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏",
}
SpinnerFrames contains the animation frames for loading spinners
var StylePresets = map[string]ToastStylePreset{ "default": { Name: "Default", BorderStyle: lipgloss.RoundedBorder(), BorderColor: "63", BackgroundColor: "235", TextColor: "255", }, "minimal": { Name: "Minimal", BorderStyle: lipgloss.NormalBorder(), BorderColor: "241", BackgroundColor: "235", TextColor: "255", }, "bold": { Name: "Bold", BorderStyle: lipgloss.ThickBorder(), BorderColor: "255", BackgroundColor: "235", TextColor: "255", }, "double": { Name: "Double", BorderStyle: lipgloss.DoubleBorder(), BorderColor: "63", BackgroundColor: "235", TextColor: "255", }, }
StylePresets contains various toast style presets
var ToastIcons = map[ToastType]string{
ToastInfo: "ℹ",
ToastSuccess: "✓",
ToastWarning: "⚠",
ToastError: "✗",
ToastLoading: "⟳",
}
ToastIcons maps toast types to their default icons
Functions ¶
func ApplyPreset ¶
ApplyPreset applies a style preset to a toast style
func CalculateMaxToasts ¶
CalculateMaxToasts calculates the maximum number of toasts based on screen height
func CalculateToastWidth ¶
CalculateToastWidth calculates the appropriate toast width based on screen size
func CriticalError ¶
CriticalError shows a persistent error that must be dismissed manually
func DeleteNotification ¶
DeleteNotification shows a delete confirmation with undo option
func DismissAllToasts ¶
DismissAllToasts creates a command to dismiss all toasts
func DismissToast ¶
DismissToast creates a command to dismiss a specific toast
func GetActionStyle ¶
GetActionStyle returns the style for action buttons
func GetDefaultIcon ¶
GetDefaultIcon returns the default icon for a toast type
func GetDismissStyle ¶
GetDismissStyle returns the style for the dismiss button
func GetIconStyle ¶
GetIconStyle returns the style for toast icons
func GetSpinnerFrame ¶
GetSpinnerFrame returns the appropriate spinner frame for the given progress
func GetTitleStyle ¶
GetTitleStyle returns the style for toast titles
func GetToastStyle ¶
GetToastStyle returns themed style for toast type
func LongWarning ¶
LongWarning shows a warning that stays for 7 seconds
func NetworkErrorNotification ¶
NetworkErrorNotification shows a network error toast
func QuickSuccess ¶
QuickSuccess shows a quick success message (2 seconds)
func SaveNotification ¶
SaveNotification shows a save confirmation with undo option
func ShowCustomToast ¶
func ShowCustomToast(config ToastConfig) tea.Cmd
ShowCustomToast creates a command to show a custom toast with full configuration
func ShowErrorWithTitle ¶
ShowErrorWithTitle creates a command to show an error toast with a title
func ShowInfoWithTitle ¶
ShowInfoWithTitle creates a command to show an info toast with a title
func ShowLoading ¶
ShowLoading creates a command to show a loading toast
func ShowLoadingWithTitle ¶
ShowLoadingWithTitle creates a command to show a loading toast with a title
func ShowPersistentToast ¶
ShowPersistentToast creates a toast that requires manual dismissal
func ShowProgressToast ¶
ShowProgressToast creates a loading toast for tracking progress
func ShowSuccess ¶
ShowSuccess creates a command to show a success toast
func ShowSuccessWithTitle ¶
ShowSuccessWithTitle creates a command to show a success toast with a title
func ShowTemporaryToast ¶
ShowTemporaryToast creates a toast that auto-dismisses after the specified duration
func ShowToastWithAction ¶
func ShowToastWithAction(toastType ToastType, message string, actionLabel string, actionCmd tea.Cmd) tea.Cmd
ShowToastWithAction creates a toast with an action button
func ShowUndoableToast ¶
ShowUndoableToast creates a toast with an undo action
func ShowWarning ¶
ShowWarning creates a command to show a warning toast
func ShowWarningWithTitle ¶
ShowWarningWithTitle creates a command to show a warning toast with a title
Types ¶
type DismissAllToastsMsg ¶
type DismissAllToastsMsg struct{}
DismissAllToastsMsg dismisses all visible toasts
type DismissToastMsg ¶
type DismissToastMsg struct {
ID string
}
DismissToastMsg dismisses a specific toast by ID
type ShowToastMsg ¶
type ShowToastMsg struct {
Config ToastConfig
}
ShowToastMsg triggers a new toast notification
type Toast ¶
type Toast struct {
// contains filtered or unexported fields
}
Toast is a single notification
func (*Toast) Config ¶
func (t *Toast) Config() ToastConfig
Config returns the toast's configuration
func (*Toast) GetOpacity ¶
GetOpacity returns the current opacity value
func (*Toast) IsDismissed ¶
IsDismissed returns true if the toast has been dismissed
func (*Toast) IsFadingOut ¶
IsFadingOut returns true if the toast is fading out
func (*Toast) StartFadeIn ¶
StartFadeIn starts the fade in animation
type ToastAction ¶
ToastAction is an optional button in toast
type ToastActionMsg ¶
type ToastActionMsg struct {
ToastID string
Action *ToastAction
}
ToastActionMsg is fired when an action button is clicked
type ToastBuilder ¶
type ToastBuilder struct {
// contains filtered or unexported fields
}
ToastBuilder helps build complex toast configurations
func NewToastBuilder ¶
func NewToastBuilder(toastType ToastType) *ToastBuilder
NewToastBuilder creates a new toast builder
func (*ToastBuilder) Build ¶
func (b *ToastBuilder) Build() tea.Cmd
Build returns the configured toast command
func (*ToastBuilder) Dismissible ¶
func (b *ToastBuilder) Dismissible(dismissible bool) *ToastBuilder
Dismissible sets whether the toast can be manually dismissed
func (*ToastBuilder) Persistent ¶
func (b *ToastBuilder) Persistent() *ToastBuilder
Persistent makes the toast require manual dismissal
func (*ToastBuilder) WithAction ¶
func (b *ToastBuilder) WithAction(label string, cmd tea.Cmd) *ToastBuilder
WithAction adds an action button
func (*ToastBuilder) WithDuration ¶
func (b *ToastBuilder) WithDuration(duration time.Duration) *ToastBuilder
WithDuration sets the auto-dismiss duration
func (*ToastBuilder) WithIcon ¶
func (b *ToastBuilder) WithIcon(icon string) *ToastBuilder
WithIcon sets a custom icon
func (*ToastBuilder) WithMessage ¶
func (b *ToastBuilder) WithMessage(message string) *ToastBuilder
WithMessage sets the toast message
func (*ToastBuilder) WithPosition ¶
func (b *ToastBuilder) WithPosition(position ToastPosition) *ToastBuilder
WithPosition sets the toast position
func (*ToastBuilder) WithTitle ¶
func (b *ToastBuilder) WithTitle(title string) *ToastBuilder
WithTitle sets the toast title
type ToastConfig ¶
type ToastConfig struct {
Type ToastType
Message string
Title string // Optional
Duration time.Duration // Auto-dismiss time (0 = manual dismiss)
Dismissible bool // Can be dismissed with X button
Position ToastPosition
Icon string // Optional icon
Action *ToastAction // Optional action button
}
ToastConfig configures toast behavior
func DefaultToastConfig ¶
func DefaultToastConfig(toastType ToastType) ToastConfig
DefaultToastConfig returns sensible defaults for a toast
type ToastExpiredMsg ¶
type ToastExpiredMsg struct {
ID string
}
ToastExpiredMsg is fired when a toast auto-dismisses
type ToastManager ¶
type ToastManager struct {
// contains filtered or unexported fields
}
ToastManager manages multiple toasts with queue
func NewToastManager ¶
func NewToastManager() *ToastManager
NewToastManager creates a new toast manager
func (*ToastManager) ClearQueue ¶
func (m *ToastManager) ClearQueue()
ClearQueue clears all queued toasts
func (*ToastManager) DismissAll ¶
func (m *ToastManager) DismissAll() tea.Cmd
DismissAll dismisses all visible toasts
func (*ToastManager) DismissToast ¶
func (m *ToastManager) DismissToast(id string) tea.Cmd
DismissToast dismisses a specific toast by ID
func (*ToastManager) GetMaxToasts ¶
func (m *ToastManager) GetMaxToasts() int
GetMaxToasts returns the maximum number of visible toasts
func (*ToastManager) GetPosition ¶
func (m *ToastManager) GetPosition() ToastPosition
GetPosition returns the default toast position
func (*ToastManager) GetQueueLength ¶
func (m *ToastManager) GetQueueLength() int
GetQueueLength returns the number of queued toasts
func (*ToastManager) GetToasts ¶
func (m *ToastManager) GetToasts() []*Toast
GetToasts returns the list of visible toasts
func (*ToastManager) HasToasts ¶
func (m *ToastManager) HasToasts() bool
HasToasts returns true if there are visible toasts
func (*ToastManager) Init ¶
func (m *ToastManager) Init() tea.Cmd
Init initializes the toast manager
func (*ToastManager) IsEnabled ¶
func (m *ToastManager) IsEnabled() bool
IsEnabled returns whether toast notifications are enabled
func (*ToastManager) RemoveToast ¶
func (m *ToastManager) RemoveToast(id string)
RemoveToast removes a toast from the visible list
func (*ToastManager) SetEnabled ¶
func (m *ToastManager) SetEnabled(enabled bool)
SetEnabled enables or disables toast notifications
func (*ToastManager) SetMaxToasts ¶
func (m *ToastManager) SetMaxToasts(max int)
SetMaxToasts sets the maximum number of visible toasts
func (*ToastManager) SetPosition ¶
func (m *ToastManager) SetPosition(pos ToastPosition)
SetPosition sets the default toast position
func (*ToastManager) SetSize ¶
func (m *ToastManager) SetSize(width, height int)
SetSize sets the manager's dimensions
func (*ToastManager) ShowError ¶
func (m *ToastManager) ShowError(message string) tea.Cmd
ShowError displays an error toast
func (*ToastManager) ShowInfo ¶
func (m *ToastManager) ShowInfo(message string) tea.Cmd
ShowInfo displays an info toast
func (*ToastManager) ShowLoading ¶
func (m *ToastManager) ShowLoading(message string) tea.Cmd
ShowLoading displays a loading toast
func (*ToastManager) ShowSuccess ¶
func (m *ToastManager) ShowSuccess(message string) tea.Cmd
ShowSuccess displays a success toast
func (*ToastManager) ShowToast ¶
func (m *ToastManager) ShowToast(config ToastConfig) tea.Cmd
ShowToast displays a new toast notification
func (*ToastManager) ShowWarning ¶
func (m *ToastManager) ShowWarning(message string) tea.Cmd
ShowWarning displays a warning toast
func (*ToastManager) Stats ¶
func (m *ToastManager) Stats() string
Stats returns statistics about the toast manager
type ToastPosition ¶
type ToastPosition int
ToastPosition defines where toast appears
const ( TopRight ToastPosition = iota TopCenter TopLeft BottomRight BottomCenter BottomLeft )
func (ToastPosition) String ¶
func (p ToastPosition) String() string
String returns the string representation of a ToastPosition
type ToastStylePreset ¶
type ToastStylePreset struct {
Name string
BorderStyle lipgloss.Border
BorderColor string
BackgroundColor string
TextColor string
}
ToastStylePresets provides pre-configured style combinations
type ToastTickMsg ¶
type ToastTickMsg struct {
ID string
}
ToastTickMsg is sent periodically to update toast state