From 36c3fc08849848ad1488da190b60c0937d0ada15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Fri, 6 Dec 2024 19:26:17 +0200 Subject: [PATCH] fix: banner (#157) --- app/Filament/Admin/Resources/ElectionResource.php | 6 ++++-- app/View/Components/Election/Alert.php | 8 ++++++-- resources/views/components/alert.blade.php | 4 +--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Filament/Admin/Resources/ElectionResource.php b/app/Filament/Admin/Resources/ElectionResource.php index 16ac91c..ea9c675 100644 --- a/app/Filament/Admin/Resources/ElectionResource.php +++ b/app/Filament/Admin/Resources/ElectionResource.php @@ -17,6 +17,7 @@ use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\Fieldset; use Filament\Forms\Components\KeyValue; +use Filament\Forms\Components\RichEditor; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; @@ -160,7 +161,7 @@ public static function form(Form $form): Form ->columnSpanFull() ->nullable(), - TextInput::make('properties.alert') + RichEditor::make('properties.alert') ->label(__('app.field.alert')) ->columnSpanFull() ->nullable(), @@ -224,7 +225,8 @@ public static function infolist(Infolist $infolist): Infolist TextEntry::make('properties.alert') ->label(__('app.field.alert')) - ->columnSpanFull(), + ->columnSpanFull() + ->html(), ]), Infolists\Components\Section::make() diff --git a/app/View/Components/Election/Alert.php b/app/View/Components/Election/Alert.php index 01c073d..128fae5 100644 --- a/app/View/Components/Election/Alert.php +++ b/app/View/Components/Election/Alert.php @@ -6,15 +6,19 @@ use App\Models\Election; use Illuminate\Contracts\View\View; +use Illuminate\Support\HtmlString; +use Illuminate\Support\Str; use Illuminate\View\Component; class Alert extends Component { - public ?string $alert = null; + public ?HtmlString $alert = null; public function __construct(Election $election) { - $this->alert = data_get($election, 'properties.alert'); + $this->alert = Str::of(data_get($election, 'properties.alert')) + ->sanitizeHtml() + ->toHtmlString(); } public function shouldRender(): bool diff --git a/resources/views/components/alert.blade.php b/resources/views/components/alert.blade.php index 18ca971..78919bd 100644 --- a/resources/views/components/alert.blade.php +++ b/resources/views/components/alert.blade.php @@ -1,5 +1,3 @@
class('p-4 rounded-md') }}> -
- {{ $slot }} -
+ {{ $slot }}