35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
{{-- Peringatan satu blok: ikon + teks (bukan warna saja). Slot = isi. Tutup hanya bila JS aktif. --}}
|
|
@props(['tone' => 'info', 'title' => null, 'dismissible' => false])
|
|
|
|
@php
|
|
$tone = in_array($tone, ['info', 'success', 'warning', 'danger'], true) ? $tone : 'info';
|
|
$icon = ['info' => 'information-circle', 'success' => 'check-circle', 'warning' => 'exclamation-triangle', 'danger' => 'exclamation-circle'][$tone];
|
|
$name = ['info' => 'Informasi', 'success' => 'Berhasil', 'warning' => 'Peringatan', 'danger' => 'Galat'][$tone];
|
|
$role = in_array($tone, ['warning', 'danger'], true) ? 'alert' : 'status';
|
|
@endphp
|
|
|
|
<div
|
|
{{ $attributes->class(['alert', "alert--{$tone}"]) }}
|
|
role="{{ $role }}"
|
|
@if ($dismissible) x-data="{ open: true }" x-show="open" x-transition.opacity @endif
|
|
>
|
|
<x-dynamic-component :component="'heroicon-m-'.$icon" class="alert__icon" aria-hidden="true" />
|
|
|
|
<div class="alert__body">
|
|
<span class="visually-hidden">{{ $name }}:</span>
|
|
@if ($title) <p class="alert__title">{{ $title }}</p> @endif
|
|
<div class="alert__text">{{ $slot }}</div>
|
|
</div>
|
|
|
|
@if ($dismissible)
|
|
<x-ui.button
|
|
variant="ghost"
|
|
icon="x-mark"
|
|
:icon-only="true"
|
|
class="alert__close"
|
|
aria-label="Tutup peringatan"
|
|
x-on:click="open = false"
|
|
/>
|
|
@endif
|
|
</div>
|