Files
server/resources/views/partials/toast.php
2025-12-06 08:47:48 -03:00

55 lines
3.2 KiB
PHP

<div x-data='{
show: <?= (isset($_SESSION['flash_success']) || isset($_SESSION['flash_error'])) ? 'true' : 'false' ?>,
type: <?= json_encode(isset($_SESSION['flash_error']) ? 'error' : 'success') ?>,
title: <?= json_encode(isset($_SESSION['flash_error']) ? 'Erro' : 'Sucesso') ?>,
message: <?= json_encode($_SESSION['flash_success'] ?? $_SESSION['flash_error'] ?? '') ?>
}' @notify.window="
show = true;
type = $event.detail.type;
title = $event.detail.title;
message = $event.detail.message;
setTimeout(() => show = false, 5000)
" x-init="
if (show) setTimeout(() => show = false, 5000);
window.notify = (type, title, message) => {
$dispatch('notify', { type, title, message });
}
" class="fixed bottom-4 right-4 z-50 max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden"
x-show="show" x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 transform translate-y-2"
x-transition:enter-end="opacity-100 transform translate-y-0" x-transition:leave="transition ease-in duration-200"
x-transition:leave-start="opacity-100 transform translate-y-0"
x-transition:leave-end="opacity-0 transform translate-y-2" style="display: none;">
<div class="p-4">
<div class="flex items-start">
<div class="flex-shrink-0">
<svg x-show="type === 'success'" class="h-6 w-6 text-green-400" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<svg x-show="type === 'error'" class="h-6 w-6 text-red-400" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<div class="ml-3 w-0 flex-1 pt-0.5">
<p class="text-sm font-medium text-gray-900" x-text="title"></p>
<p class="mt-1 text-sm text-gray-500" x-text="message"></p>
</div>
<div class="ml-4 flex-shrink-0 flex">
<button @click="show = false"
class="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<span class="sr-only">Fechar</span>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd" />
</svg>
</button>
</div>
</div>
</div>
</div>
<?php unset($_SESSION['flash_success'], $_SESSION['flash_error']); ?>