lasthourcloud/resources/views/components/modal-confirmation.blade.php

117 lines
6.0 KiB
PHP
Raw Normal View History

2024-01-31 13:18:59 +00:00
@props([
'title' => 'Are you sure?',
'buttonTitle' => 'Open Modal',
'isErrorButton' => false,
2024-03-22 10:34:15 +00:00
'buttonFullWidth' => false,
2024-01-31 13:18:59 +00:00
'disabled' => false,
'action' => 'delete',
'content' => null,
2024-01-31 13:18:59 +00:00
])
<div x-data="{ modalOpen: false }" @keydown.escape.window="modalOpen = false" :class="{ 'z-40': modalOpen }"
class="relative w-auto h-auto">
@if ($content)
<div @click="modalOpen=true">
{{ $content }}
</div>
2024-01-31 13:18:59 +00:00
@else
@if ($disabled)
2024-03-22 10:34:15 +00:00
@if ($buttonFullWidth)
2024-03-25 10:33:38 +00:00
<x-forms.button class="w-full" isError disabled wire:target>
2024-03-22 10:34:15 +00:00
{{ $buttonTitle }}
</x-forms.button>
@else
2024-03-25 10:33:38 +00:00
<x-forms.button isError disabled wire:target>
2024-03-22 10:34:15 +00:00
{{ $buttonTitle }}
</x-forms.button>
@endif
@elseif ($isErrorButton)
2024-03-22 10:34:15 +00:00
@if ($buttonFullWidth)
<x-forms.button class="w-full" isError @click="modalOpen=true">
{{ $buttonTitle }}
</x-forms.button>
@else
<x-forms.button isError @click="modalOpen=true">
{{ $buttonTitle }}
</x-forms.button>
@endif
@else
2024-03-22 10:34:15 +00:00
@if ($buttonFullWidth)
2024-03-25 10:33:38 +00:00
<x-forms.button @click="modalOpen=true" class="flex w-full gap-2" wire:target>
2024-03-22 10:34:15 +00:00
{{ $buttonTitle }}
</x-forms.button>
@else
2024-03-25 10:33:38 +00:00
<x-forms.button @click="modalOpen=true" class="flex gap-2" wire:target>
2024-03-22 10:34:15 +00:00
{{ $buttonTitle }}
</x-forms.button>
@endif
@endif
2024-01-31 13:18:59 +00:00
@endif
<template x-teleport="body">
2024-03-25 09:41:44 +00:00
<div x-show="modalOpen"
class="fixed top-0 lg:pt-10 left-0 z-[99] flex items-start justify-center w-screen h-screen" x-cloak>
2024-01-31 15:14:12 +00:00
<div x-show="modalOpen" x-transition:enter="ease-out duration-100" x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100" x-transition:leave="ease-in duration-100"
2024-01-31 13:18:59 +00:00
x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" @click="modalOpen=false"
2024-01-31 15:14:12 +00:00
class="absolute inset-0 w-full h-full bg-black bg-opacity-20 backdrop-blur-sm"></div>
<div x-show="modalOpen" x-trap.inert.noscroll="modalOpen" x-transition:enter="ease-out duration-100"
2024-01-31 13:18:59 +00:00
x-transition:enter-start="opacity-0 -translate-y-2 sm:scale-95"
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
2024-01-31 15:14:12 +00:00
x-transition:leave="ease-in duration-100"
2024-01-31 13:18:59 +00:00
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave-end="opacity-0 -translate-y-2 sm:scale-95"
2024-03-24 15:00:25 +00:00
class="relative w-full py-6 border rounded min-w-full lg:min-w-[36rem] max-w-fit bg-neutral-100 border-neutral-400 dark:bg-base px-7 dark:border-coolgray-300">
2024-01-31 13:18:59 +00:00
<div class="flex items-center justify-between pb-3">
2024-01-31 15:14:12 +00:00
<h3 class="text-2xl font-bold">{{ $title }}</h3>
{{-- <button @click="modalOpen=false"
2024-03-24 15:00:25 +00:00
class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 rounded-full dark:text-white hover:bg-coolgray-300">
2024-01-31 13:18:59 +00:00
<svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
</button> --}}
2024-01-31 13:18:59 +00:00
</div>
<div class="relative w-auto pb-8">
{{ $slot }}
</div>
2024-03-21 14:00:14 +00:00
<div class="flex flex-row justify-end space-x-2">
2024-03-25 09:41:44 +00:00
<x-forms.button @click="modalOpen=false"
class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300">Cancel
2024-01-31 13:18:59 +00:00
</x-forms.button>
<div class="flex-1"></div>
2024-03-21 11:44:32 +00:00
@if ($attributes->whereStartsWith('wire:click')->first())
@if ($isErrorButton)
<x-forms.button @click="modalOpen=false" class="w-24" isError type="button"
wire:click.prevent="{{ $attributes->get('wire:click') }}">Continue
</x-forms.button>
@else
<x-forms.button @click="modalOpen=false" class="w-24" isHighlighted type="button"
wire:click.prevent="{{ $attributes->get('wire:click') }}">Continue
</x-forms.button>
@endif
@elseif ($attributes->whereStartsWith('@click')->first())
@if ($isErrorButton)
<x-forms.button class="w-24" isError type="button"
@click="modalOpen=false;{{ $attributes->get('@click') }}">Continue
</x-forms.button>
@else
<x-forms.button class="w-24" isHighlighted type="button"
@click="modalOpen=false;{{ $attributes->get('@click') }}">Continue
</x-forms.button>
@endif
@elseif ($action)
@if ($isErrorButton)
<x-forms.button @click="modalOpen=false" class="w-24" isError type="button"
wire:click.prevent="{{ $action }}">Continue
</x-forms.button>
@else
<x-forms.button @click="modalOpen=false" class="w-24" isHighlighted type="button"
wire:click.prevent="{{ $action }}">Continue
</x-forms.button>
@endif
2024-02-02 10:50:28 +00:00
@endif
2024-01-31 13:18:59 +00:00
</div>
</div>
</div>
</template>
</div>