diff --git a/app/View/Components/Alert.php b/app/View/Components/Alert.php new file mode 100644 index 000000000..eba2d61af --- /dev/null +++ b/app/View/Components/Alert.php @@ -0,0 +1,96 @@ +rounded = $rounded; + $this->border = $border; + + $this->color = $this->getColor($color); + $this->icon = $this->getIcon($icon); + + $this->title = $title; + $this->description = $description; + + $this->list = $list; + $this->actions = $actions; + + $this->dismiss = $dismiss; + } + + /** + * Get the view / contents that represent the component. + * + * @return \Illuminate\Contracts\View\View|string + */ + public function render() + { + return view('components.alert.index'); + } + + protected function getColor($color) + { + if (! empty($color)) { + return $color; + } + + $color = 'green'; + + return $color; + } + + protected function getIcon($icon) + { + if (! empty($icon)) { + return $icon; + } + + $icon = 'check_circle'; + + return $icon; + } +} diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index 07819fa41..849f76b98 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -228,6 +228,7 @@ return [ 'preview_mode' => 'Preview Mode', 'go_back' => 'Go back to :type', 'validation_error' => 'Validation error', + 'dismiss' => 'Dismiss', 'card' => [ 'cards' => 'Card|Cards', diff --git a/resources/views/components/alert/index.blade.php b/resources/views/components/alert/index.blade.php new file mode 100644 index 000000000..85b70dc39 --- /dev/null +++ b/resources/views/components/alert/index.blade.php @@ -0,0 +1,104 @@ +
$rounded, + 'border-l-4 border-' . $color . '-400' => $border, + 'bg-' . $color . '-50', + 'p-4', + ]) + x-data +> +
+
+ +
+ +
+

+ {{ $title }} +

+ +
+

{{ $description }}

+ + @if ($list) +
    + @foreach ($list as $message) +
  • {{ $message }}
  • + @endforeach +
+ @endif +
+ + @if ($actions) +
+
+ @foreach ($actions as $action) + @if ($action['type'] == 'button') + + @else + ! $loop->first, + 'rounded-md', + 'bg-' . $color . '-50', + 'px-2 py-1.5', + 'text-sm font-medium', + 'text-' . $color . '-800 hover:bg-' . $color . '-100', + 'focus:outline-none focus:ring-2', + 'focus:ring-' . $color . '-600', + 'focus:ring-offset-2', + 'focus:ring-offset-' . $color . '-50', + ]) + > + {{ $action['text'] }} + + @endif + @endforeach +
+
+ @endif +
+ + @if ($dismiss) +
+
+ +
+
+ @endif +
+