PopUpToken.svelte 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <script>
  2. import { goto } from '$app/navigation';
  3. export let visible = false;
  4. export let title = 'Seu sessão expirou';
  5. export let confirmText = 'Retornar';
  6. function onConfirm() {
  7. goto('/');
  8. }
  9. </script>
  10. {#if visible}
  11. <div
  12. class="fixed inset-0 z-50 flex items-center justify-center"
  13. role="dialog"
  14. aria-modal="true"
  15. aria-label={title}
  16. >
  17. <div
  18. class="absolute inset-0 bg-black/50"
  19. role="button"
  20. tabindex="0"
  21. aria-label="Fechar aviso"
  22. on:click={onConfirm}
  23. on:keydown={(event) => {
  24. if (event.key === 'Enter' || event.key === ' ') {
  25. event.preventDefault();
  26. onConfirm();
  27. }
  28. }}
  29. ></div>
  30. <div class="relative bg-white dark:bg-gray-800 w-full max-w-sm rounded-lg shadow-lg">
  31. <div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between">
  32. <h3 class="text-base font-semibold text-gray-800 dark:text-gray-100">{title}</h3>
  33. <button type="button" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200" aria-label="Fechar" on:click={onConfirm}>✕</button>
  34. </div>
  35. <div class="p-6 text-sm text-gray-700 dark:text-gray-300">
  36. <slot>
  37. Seu sessão expirou, retorne para a tela de login e faça login novamente.
  38. </slot>
  39. </div>
  40. <div class="px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-center gap-3">
  41. <button type="button" class="px-4 py-2 rounded-md bg-blue-600 hover:bg-blue-700 text-white" on:click={onConfirm}>{confirmText}</button>
  42. </div>
  43. </div>
  44. </div>
  45. {/if}