NAME

Chandra::Toast - In-app toast notifications

SYNOPSIS

use Chandra::Toast;

# Simple
Chandra::Toast->show($app, 'Settings saved');

# Typed
Chandra::Toast->show($app, 'File uploaded', type => 'success');
Chandra::Toast->show($app, 'Connection lost', type => 'error', duration => 0);

# With action
Chandra::Toast->show($app, 'Item deleted', type => 'info', action => {
    label   => 'Undo',
    handler => sub { undo_delete() },
});

# Or via App convenience method
$app->toast('Saved!', type => 'success');

# Dismiss programmatically
my $id = $app->toast('Processing...', type => 'info', duration => 0);
$app->dismiss_toast($id);

DESCRIPTION

In-app notification toasts with auto-dismiss, action buttons, and stacking. All methods are implemented in XS for performance.

METHODS

show($app, $message, %opts)

Show a toast notification. Options:

type - 'success', 'error', 'warning', 'info' (default)
duration - milliseconds before auto-dismiss (default 3000, 0 = persistent)
action - hashref with label and handler (coderef)

Returns the toast ID string for programmatic dismissal.

dismiss($app, $id)

Dismiss a toast by ID.

reset()

Reset internal state (for testing).

TOAST TYPES

success - green accent with checkmark
error - red accent with X
warning - orange accent with warning sign
info - blue accent with info symbol (default)

SEE ALSO

Chandra::App, Chandra::Theme