From 5b07f46c2c592aad55898e14966285ac2625c5c2 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 4 Jan 2024 12:05:48 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Make=20the=20Alert=20component?= =?UTF-8?q?=20anonymous?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/View/Components/Alert.php | 57 ---------------------- resources/views/components/alert.blade.php | 14 +++++- 2 files changed, 13 insertions(+), 58 deletions(-) delete mode 100644 app/View/Components/Alert.php diff --git a/app/View/Components/Alert.php b/app/View/Components/Alert.php deleted file mode 100644 index fa860df66b..0000000000 --- a/app/View/Components/Alert.php +++ /dev/null @@ -1,57 +0,0 @@ - 'text-indigo-50 bg-indigo-400', - 'success' => 'text-green-50 bg-green-400', - 'caution' => 'text-yellow-50 bg-yellow-400', - 'warning' => 'text-red-50 bg-red-400', - ]; - - /** - * Create the component instance. - * - * @param string $type - * @param string $message - * @return void - */ - public function __construct($type = 'default', $message = null) - { - $this->type = $this->types[$type] ?? $this->types['default']; - $this->message = $message; - } - - /** - * Get the view / contents that represent the component. - * - * @return \Illuminate\View\View|string - */ - public function render() - { - return $this->view('components.alert'); - } -} diff --git a/resources/views/components/alert.blade.php b/resources/views/components/alert.blade.php index a2aa5a4a9c..dbb5539a19 100644 --- a/resources/views/components/alert.blade.php +++ b/resources/views/components/alert.blade.php @@ -1,3 +1,15 @@ -
merge(['class' => $type]) }}> +@props([ + 'type' => null, + 'message' => null, +]) + +@php($class = match ($type) { + 'success' => 'text-green-50 bg-green-400', + 'caution' => 'text-yellow-50 bg-yellow-400', + 'warning' => 'text-red-50 bg-red-400', + default => 'text-indigo-50 bg-indigo-400', +}) + +
merge(['class' => "px-2 py-1 {$class}"]) }}> {!! $message ?? $slot !!}