- Changed modal close event from `@click.away` to `@click.self` for better control over closing modals. - Updated various modal button styles for consistency and improved accessibility. - Adjusted transition durations for modal animations to enhance user experience. - Added aria-labels to close buttons for better screen reader support.
116 lines
4.9 KiB
PHP
116 lines
4.9 KiB
PHP
@props([
|
|
'title' => null,
|
|
'subtitle' => null,
|
|
'icon' => null,
|
|
'iconClass' => 'size-5',
|
|
'helpIcon' => false,
|
|
'helpTitle' => null,
|
|
'helpContent' => null,
|
|
'border' => false,
|
|
])
|
|
|
|
@php
|
|
$containerClasses = 'flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4';
|
|
if ($border) {
|
|
$containerClasses .= ' pb-4 border-b border-neutral/10';
|
|
}
|
|
@endphp
|
|
|
|
<div {{ $attributes->merge(['class' => $containerClasses]) }}>
|
|
<div class="flex flex-col gap-1">
|
|
<div class="flex items-center gap-2">
|
|
@if($icon)
|
|
<div class="flex items-center justify-center w-8 h-8 rounded-lg bg-primary/10">
|
|
<x-dynamic-component :component="$icon" class="{{ $iconClass }} text-primary" />
|
|
</div>
|
|
@endif
|
|
|
|
@if($title)
|
|
<h2 class="text-xl font-semibold text-base/90">{{ $title }}</h2>
|
|
@endif
|
|
|
|
{{-- Help modal trigger --}}
|
|
@if($helpIcon || $helpContent)
|
|
<div class="relative" x-data="{ open: false }" x-cloak>
|
|
<button
|
|
type="button"
|
|
@click="open = true"
|
|
class="text-base/50 hover:text-base/70 transition-colors"
|
|
title="Learn more"
|
|
>
|
|
<x-ri-question-line class="size-5" />
|
|
</button>
|
|
|
|
{{-- Modal Backdrop --}}
|
|
<div
|
|
x-show="open"
|
|
x-transition:enter="transition ease-out duration-300"
|
|
x-transition:enter-start="opacity-0"
|
|
x-transition:enter-end="opacity-100"
|
|
x-transition:leave="transition ease-in duration-200"
|
|
x-transition:leave-start="opacity-100"
|
|
x-transition:leave-end="opacity-0"
|
|
@click="open = false"
|
|
@keydown.escape.window="open = false"
|
|
class="fixed inset-0 z-50 bg-black/50 backdrop-blur-sm"
|
|
style="display: none;"
|
|
></div>
|
|
|
|
{{-- Modal --}}
|
|
<div
|
|
x-show="open"
|
|
x-transition:enter="transition ease-out duration-300"
|
|
x-transition:enter-start="opacity-0 scale-95"
|
|
x-transition:enter-end="opacity-100 scale-100"
|
|
x-transition:leave="transition ease-in duration-200"
|
|
x-transition:leave-start="opacity-100 scale-100"
|
|
x-transition:leave-end="opacity-0 scale-95"
|
|
@click.self="open = false"
|
|
@keydown.escape.window="open = false"
|
|
class="fixed inset-0 z-50 flex items-center justify-center p-4"
|
|
style="display: none;"
|
|
>
|
|
<div class="relative w-full max-w-2xl max-h-[90vh] overflow-y-auto bg-background-secondary rounded-xl border border-neutral/20 shadow-2xl p-6">
|
|
<button @click="open = false" class="absolute top-4 right-4 text-base/50 hover:text-base transition-colors">
|
|
<x-ri-close-line class="size-5" />
|
|
</button>
|
|
|
|
<div class="flex items-center gap-3 mb-4 pr-8">
|
|
@if($icon)
|
|
<div class="flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10">
|
|
<x-dynamic-component :component="$icon" class="size-5 text-primary" />
|
|
</div>
|
|
@endif
|
|
<h6 class="font-sans text-lg font-semibold leading-tight">
|
|
{{ $helpTitle ?? $title }}
|
|
</h6>
|
|
</div>
|
|
|
|
@if($helpContent)
|
|
<div class="prose prose-sm text-base/80 max-w-none">
|
|
{!! $helpContent !!}
|
|
</div>
|
|
@endif
|
|
|
|
@if(isset($help))
|
|
{{ $help }}
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
@if($subtitle)
|
|
<p class="text-base/70 text-sm">{{ $subtitle }}</p>
|
|
@endif
|
|
</div>
|
|
|
|
{{-- Actions slot --}}
|
|
@if(isset($actions))
|
|
<div class="flex items-center gap-2 flex-shrink-0">
|
|
{{ $actions }}
|
|
</div>
|
|
@endif
|
|
</div>
|