rezaulhreza / flash-toast
A fluent toast manager built with TALL stack.
Requires
- php: ^7.4|^8.1
- illuminate/contracts: ^9.0
- livewire/livewire: ^2.10
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- livewire/livewire: ^2.10
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-11-09 10:40:19 UTC
README
Demo Project
Installation
You can install the package via composer:
composer require rezaulhreza/flash-toast
then publish the config file
php artisan vendor:publish --tag="flash-toast-config"
publish the view files
php artisan vendor:publish --tag="flash-toast-views"
Once you publish the file, move the files from
resources\views\vendor\flash-toast\components
to
resources\views\components
.
now you can place the file anywhere you want such as .
alterantively, just do:
@include('vendor.flash-toast.components.flash-toast')
Usage
Runs with the TALL stack: Laravel, TailwindCSS, Livewire, AlpineJS.
Guide:
Available methods: success- info - warning - danger. title, html, level, duration.
use FlashToast
in the component class.
In the component class: Example:
$this->toastInfo('this is a info toast'); $this->toastSuccess('this is a successful toast');
Of course the above are customisable.
To add a html code or title or duration even custom level(level is the type of toast e.g. - success, info etc). Example:
use FlashToast; // don't forget to import it!!! $this->toastSuccess('This is a string message');
p.s: to showcase the usage in the readme, a space was left intentionally otherwise it would compile the markdown preview with h1. Use actual markup when using within the applciation scenario.
Blade component:
component/toast.blade.php
Styles are inside a blade file, however, you can customize it
An example is given below
<?php namespace Rezaulhreza\FlashToast\Example; use Livewire\Component; use Rezaulhreza\FlashToast\FlashToast; class FlashToastExample extends Component { public function stringMessage() { $this->toastSuccess('This is a string message'); } public function text() { $this->flashToast((new \Rezaulhreza\FlashToast\Manager\ToastManager)->text('Some text')); } public function html() { $this->flashToast((new \Rezaulhreza\FlashToast\Manager\ToastManager)->title('My title')->level('warning')->html('<h2 class="text-2xl">Sub title</h2> <b>Warning</b>')); } public function duration() { $this->flashToast((new \Rezaulhreza\FlashToast\Manager\ToastManager)->text('Showing for 200 ms')->showForMilliseconds(200)); } public function render() { return view('flash-toast-example'); } }
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email emailrezahere@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.