From a47cb80a448429f9f1767056440ab727bd5c9009 Mon Sep 17 00:00:00 2001 From: gqrdev Date: Mon, 6 May 2024 00:21:41 -0300 Subject: [PATCH 1/4] Update banner styling and add warning banner functionality --- src/InteractsWithBanner.php | 14 ++++++++++++++ src/JetstreamServiceProvider.php | 8 ++++++++ .../resources/views/components/banner.blade.php | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/InteractsWithBanner.php b/src/InteractsWithBanner.php index b2bec9b1b..543f9082e 100644 --- a/src/InteractsWithBanner.php +++ b/src/InteractsWithBanner.php @@ -31,4 +31,18 @@ protected function dangerBanner($message) message: $message, ); } + + /** + * Update the banner message with an warning message. + * + * @param string $message + * @return void + */ + protected function warningBanner($message) + { + $this->dispatch('banner-message', + style: 'warning', + message: $message, + ); + } } diff --git a/src/JetstreamServiceProvider.php b/src/JetstreamServiceProvider.php index d81c26beb..78dffc0e3 100644 --- a/src/JetstreamServiceProvider.php +++ b/src/JetstreamServiceProvider.php @@ -69,6 +69,14 @@ public function boot() ]); }); + RedirectResponse::macro('warningBanner', function ($message) { + /** @var \Illuminate\Http\RedirectResponse $this */ + return $this->with('flash', [ + 'bannerStyle' => 'warning', + 'banner' => $message, + ]); + }); + if (config('jetstream.stack') === 'inertia' && class_exists(Inertia::class)) { $this->bootInertia(); } diff --git a/stubs/livewire/resources/views/components/banner.blade.php b/stubs/livewire/resources/views/components/banner.blade.php index ffd33f9e8..9020d9b1e 100644 --- a/stubs/livewire/resources/views/components/banner.blade.php +++ b/stubs/livewire/resources/views/components/banner.blade.php @@ -1,7 +1,7 @@ @props(['style' => session('flash.bannerStyle', 'success'), 'message' => session('flash.banner')])