mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-16 04:57:46 +02:00
feat: replace form helper functions with components in admin template
This commit is contained in:
parent
6536729546
commit
e64548b982
70 changed files with 1461 additions and 2571 deletions
39
app/Views/Components/Alert.php
Normal file
39
app/Views/Components/Alert.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Views\Components;
|
||||
|
||||
use ViewComponents\Component;
|
||||
|
||||
class Alert extends Component
|
||||
{
|
||||
protected ?string $glyph = null;
|
||||
|
||||
protected ?string $title = null;
|
||||
|
||||
/**
|
||||
* @var 'default'|'success'|'danger'|'warning'
|
||||
*/
|
||||
protected string $variant = 'default';
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
$variantClasses = [
|
||||
'default' => 'text-gray-800 bg-gray-100 border-gray-300',
|
||||
'success' => 'text-pine-900 bg-pine-100 border-pine-300',
|
||||
'danger' => 'text-red-900 bg-red-100 border-red-300',
|
||||
'warning' => 'text-yellow-900 bg-yellow-100 border-yellow-300',
|
||||
];
|
||||
|
||||
$glyph = $this->glyph === null ? '' : '<Icon glyph="' . $this->glyph . '" class="flex-shrink-0 mr-2 text-lg" />';
|
||||
$title = $this->title === null ? '' : '<div class="font-semibold">' . $this->title . '</div>';
|
||||
$class = 'inline-flex w-full p-2 text-sm border rounded ' . $variantClasses[$this->variant] . ' ' . $this->class;
|
||||
|
||||
$attributes = stringify_attributes($this->attributes);
|
||||
|
||||
return <<<HTML
|
||||
<div class="{$class}" role="alert" {$attributes}>{$glyph}<div>{$title}{$this->slot}</div></div>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue