Skip to content

sugarcraft/sugar-toast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sugar-toast

CI codecov Packagist Version License PHP

SugarToast

PHP port of DaltonSW/bubbleup — floating alert notification component for terminal UIs. Alerts float to the top of your TUI like bubbles in soda.

Features

  • 6 positions: TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight
  • 4 alert types: Error, Warning, Info, Success — each with distinct styling
  • Dynamic width: fixed or auto-sizing between minWidth and maxWidth
  • Symbol sets: NerdFont (icons), Unicode (boxed), ASCII (plain text)
  • Auto-dismiss: duration-based expiry support
  • Multiple alerts: queue of toasts rendered in order
  • Pure renderer: outputs ANSI strings; works with any TUI framework

Install

composer require sugarcraft/sugar-toast

Quick Start

use SugarCraft\Toast\{Position, Toast, ToastType};

$toast = Toast::new(50)  // max width 50
    ->withPosition(Position::TopRight)
    ->withDuration(10.0);  // seconds

// Add alerts
$toast = $toast->alert(ToastType::Success, 'File saved!');
$toast = $toast->alert(ToastType::Error, 'Connection failed');

// Render into a viewport
$bg = str_repeat("background content\n", 20);
echo $toast->View($bg);

Alert Types

ToastType::Error
ToastType::Warning
ToastType::Info
ToastType::Success

Positions

Position::TopLeft
Position::TopCenter
Position::TopRight
Position::BottomLeft
Position::BottomCenter
Position::BottomRight

License

MIT

About

PHP port of DaltonSW/bubbleup u2014 floating alert notification component for terminal UIs. Supports error/warning/info/success alerts at 6 screen positions, dynamic width, NerdFont/Unicode/ASCII symbols, auto-dismiss timers.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages