From 1a79a3bfceb5db08e6f1fcb9244fbe37a4114675 Mon Sep 17 00:00:00 2001 From: Anders Bilfeldt Date: Fri, 16 Dec 2022 01:20:30 +0100 Subject: [PATCH] Add individual blade components --- src/FlashMessageServiceProvider.php | 12 +++++++++++- src/View/Components/AbstractAlert.php | 21 +++++++++++++++++++++ src/View/Components/AlertError.php | 11 +++++++++++ src/View/Components/AlertInfo.php | 11 +++++++++++ src/View/Components/AlertMessage.php | 11 +++++++++++ src/View/Components/AlertSuccess.php | 11 +++++++++++ src/View/Components/AlertWarning.php | 11 +++++++++++ 7 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src/View/Components/AbstractAlert.php create mode 100644 src/View/Components/AlertError.php create mode 100644 src/View/Components/AlertInfo.php create mode 100644 src/View/Components/AlertMessage.php create mode 100644 src/View/Components/AlertSuccess.php create mode 100644 src/View/Components/AlertWarning.php diff --git a/src/FlashMessageServiceProvider.php b/src/FlashMessageServiceProvider.php index 27c8261..77605b0 100644 --- a/src/FlashMessageServiceProvider.php +++ b/src/FlashMessageServiceProvider.php @@ -3,7 +3,12 @@ namespace Bilfeldt\LaravelFlashMessage; use Bilfeldt\LaravelFlashMessage\View\Components\Alert; +use Bilfeldt\LaravelFlashMessage\View\Components\AlertError; +use Bilfeldt\LaravelFlashMessage\View\Components\AlertInfo; +use Bilfeldt\LaravelFlashMessage\View\Components\AlertMessage; use Bilfeldt\LaravelFlashMessage\View\Components\AlertMessages; +use Bilfeldt\LaravelFlashMessage\View\Components\AlertSuccess; +use Bilfeldt\LaravelFlashMessage\View\Components\AlertWarning; use Illuminate\Http\RedirectResponse; use Illuminate\View\Factory; use Illuminate\View\View; @@ -27,8 +32,13 @@ public function configurePackage(Package $package): void ->hasViews() // required for the view component blade files to be registered ->hasViewComponents( self::VIEW_COMPONENT_NAMESPACE, + AlertMessages::class, Alert::class, - AlertMessages::class + AlertError::class, + AlertInfo::class, + AlertMessage::class, + AlertSuccess::class, + AlertWarning::class ); } diff --git a/src/View/Components/AbstractAlert.php b/src/View/Components/AbstractAlert.php new file mode 100644 index 0000000..d12b71c --- /dev/null +++ b/src/View/Components/AbstractAlert.php @@ -0,0 +1,21 @@ +text = $text; + $this->title = $title; + $this->messages = $messages; + $this->links = $links; + } +} diff --git a/src/View/Components/AlertError.php b/src/View/Components/AlertError.php new file mode 100644 index 0000000..261a6bd --- /dev/null +++ b/src/View/Components/AlertError.php @@ -0,0 +1,11 @@ +