Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | <template> <Teleport to="body"> <div class="toast-container"> <TransitionGroup name="toast"> <div v-for="toast in toasts" :key="toast.id" :class="['toast', `toast-${toast.type}`]" @click="removeToast(toast.id)" > <div class="toast-icon"> <svg v-if="toast.type === 'success'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" /> </svg> <svg v-else-if="toast.type === 'error'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" /> </svg> <svg v-else-if="toast.type === 'warning'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> <path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd" /> </svg> <svg v-else xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" /> </svg> </div> <div class="toast-content"> <p class="toast-message">{{ toast.message }}</p> </div> <button class="toast-close" @click.stop="removeToast(toast.id)"> <svg xmlns="http://www.w3.org/2000/svg" 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> </TransitionGroup> </div> </Teleport> </template> <script setup lang="ts"> import { useToastStore } from '@/stores/toast.store' import { storeToRefs } from 'pinia' const toastStore = useToastStore() const { toasts } = storeToRefs(toastStore) const { removeToast } = toastStore </script> <style scoped> .toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.75rem; max-width: 24rem; pointer-events: none; } .toast { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1rem; background: white; border-radius: 0.5rem; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); border-left: 4px solid; pointer-events: auto; cursor: pointer; transition: all 0.3s ease; } .toast:hover { transform: translateX(-4px); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); } .toast-success { border-left-color: #10b981; } .toast-error { border-left-color: #ef4444; } .toast-warning { border-left-color: #f59e0b; } .toast-info { border-left-color: #3b82f6; } .toast-icon { flex-shrink: 0; width: 1.5rem; height: 1.5rem; } .toast-success .toast-icon { color: #10b981; } .toast-error .toast-icon { color: #ef4444; } .toast-warning .toast-icon { color: #f59e0b; } .toast-info .toast-icon { color: #3b82f6; } .toast-content { flex: 1; min-width: 0; } .toast-message { margin: 0; color: #1f2937; font-size: 0.875rem; line-height: 1.25rem; word-break: break-word; } .toast-close { flex-shrink: 0; width: 1.25rem; height: 1.25rem; color: #6b7280; background: none; border: none; padding: 0; cursor: pointer; transition: color 0.2s; } .toast-close:hover { color: #1f2937; } .toast-close svg { width: 100%; height: 100%; } /* Transitions */ .toast-enter-active, .toast-leave-active { transition: all 0.3s ease; } .toast-enter-from { opacity: 0; transform: translateX(100%); } .toast-leave-to { opacity: 0; transform: translateX(100%) scale(0.95); } </style> |