|
1 | 1 | <template>
|
2 |
| - <div aria-live="assertive" class="pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6"> |
3 |
| - <div class="flex w-full flex-col items-center space-y-4 sm:items-end"> |
4 |
| - <!-- Notification panel, dynamically insert this into the live region when it needs to be displayed --> |
5 |
| - <TransitionGroup enter-active-class="transform ease-out duration-300 transition" |
6 |
| - enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2" |
7 |
| - enter-to-class="translate-y-0 opacity-100 sm:translate-x-0" |
8 |
| - leave-active-class="transition transform ease-in duration-100" |
9 |
| - leave-from-class="translate-y-0 opacity-100 sm:translate-x-0" |
10 |
| - leave-to-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"> |
11 |
| - <div v-for="notification in notifications" :key="notification.id" |
12 |
| - class="pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-dark-500 shadow-lg ring-1 ring-white/10"> |
13 |
| - <div class="p-4"> |
14 |
| - <div class="flex items-start"> |
15 |
| - <div class="shrink-0 h-6 w-6"> |
16 |
| - <iconify-icon v-if="notification.type === 'success'" icon="tabler:check" height="none" |
17 |
| - class="h-6 w-6 text-green-400" aria-hidden="true" /> |
18 |
| - <iconify-icon v-else-if="notification.type === 'error'" icon="tabler:alert-triangle" |
19 |
| - height="none" class="h-6 w-6 text-red-400" aria-hidden="true" /> |
20 |
| - <iconify-icon v-else-if="notification.type === 'progress'" icon="tabler:loader" |
21 |
| - height="none" class="h-6 w-6 text-pink-500 animate-spin" aria-hidden="true" /> |
22 |
| - </div> |
23 |
| - <div class="ml-3 w-0 flex-1 pt-0.5"> |
24 |
| - <p class="text-sm font-semibold text-gray-50">{{ notification.title }}</p> |
25 |
| - <p class="mt-1 text-sm text-gray-400" v-if="notification.message">{{ |
26 |
| - notification.message }}</p> |
27 |
| - </div> |
28 |
| - <div class="ml-4 flex flex-shrink-0"> |
29 |
| - <button type="button" title="Close this notification" |
30 |
| - @click="notifications.splice(notifications.indexOf(notification), 1); notification.onDismiss?.()" |
31 |
| - class="inline-flex rounded-md text-gray-400 hover:text-gray-300 duration-200"> |
32 |
| - <iconify-icon icon="tabler:x" class="h-5 w-5" aria-hidden="true" /> |
33 |
| - </button> |
| 2 | + <Teleport to="body"> |
| 3 | + <div aria-live="assertive" |
| 4 | + class="pointer-events-none fixed inset-0 flex items-end px-4 pt-6 pb-24 sm:pb-6 sm:items-start sm:p-6 z-50"> |
| 5 | + <div class="flex w-full flex-col items-center space-y-4 sm:items-end"> |
| 6 | + <!-- Notification panel, dynamically insert this into the live region when it needs to be displayed --> |
| 7 | + <TransitionGroup enter-active-class="transform ease-out duration-300 transition" |
| 8 | + enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2" |
| 9 | + enter-to-class="translate-y-0 opacity-100 sm:translate-x-0" |
| 10 | + leave-active-class="transition transform ease-in duration-100" |
| 11 | + leave-from-class="translate-y-0 opacity-100 sm:translate-x-0" |
| 12 | + leave-to-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"> |
| 13 | + <div v-for="notification in notifications" :key="notification.id" |
| 14 | + class="pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-dark-500 shadow-lg ring-1 ring-white/10"> |
| 15 | + <div class="p-4"> |
| 16 | + <div class="flex items-start"> |
| 17 | + <div class="shrink-0 h-6 w-6"> |
| 18 | + <iconify-icon v-if="notification.type === 'success'" icon="tabler:check" |
| 19 | + height="none" class="h-6 w-6 text-green-400" aria-hidden="true" /> |
| 20 | + <iconify-icon v-else-if="notification.type === 'error'" icon="tabler:alert-triangle" |
| 21 | + height="none" class="h-6 w-6 text-red-400" aria-hidden="true" /> |
| 22 | + <iconify-icon v-else-if="notification.type === 'progress'" icon="tabler:loader" |
| 23 | + height="none" class="h-6 w-6 text-pink-500 animate-spin" aria-hidden="true" /> |
| 24 | + </div> |
| 25 | + <div class="ml-3 w-0 flex-1 pt-0.5"> |
| 26 | + <p class="text-sm font-semibold text-gray-50">{{ notification.title }}</p> |
| 27 | + <p class="mt-1 text-sm text-gray-400" v-if="notification.message">{{ |
| 28 | + notification.message }}</p> |
| 29 | + </div> |
| 30 | + <div class="ml-4 flex flex-shrink-0"> |
| 31 | + <button type="button" title="Close this notification" |
| 32 | + @click="notifications.splice(notifications.indexOf(notification), 1); notification.onDismiss?.()" |
| 33 | + class="inline-flex rounded-md text-gray-400 hover:text-gray-300 duration-200"> |
| 34 | + <iconify-icon icon="tabler:x" class="h-5 w-5" aria-hidden="true" /> |
| 35 | + </button> |
| 36 | + </div> |
34 | 37 | </div>
|
35 | 38 | </div>
|
36 | 39 | </div>
|
37 |
| - </div> |
38 |
| - </TransitionGroup> |
| 40 | + </TransitionGroup> |
| 41 | + </div> |
39 | 42 | </div>
|
40 |
| - </div> |
| 43 | + </Teleport> |
41 | 44 | </template>
|
42 | 45 |
|
43 | 46 | <script lang="ts" setup>
|
|
0 commit comments