eCourt-Doc-Edit/web/app/components/AlertBox.vue
2026-08-20 21:34:45 +07:00

28 lines
722 B
Vue
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
/** กล่องข้อความ (error/success/info) ใช้ร่วมทุกหน้า */
const props = withDefaults(
defineProps<{
type?: 'error' | 'success' | 'info'
}>(),
{ type: 'info' },
)
const styles = computed(() => {
switch (props.type) {
case 'error':
return 'alert-error'
case 'success':
return 'alert-success'
default:
return 'alert-info'
}
})
const icon = computed(() => (props.type === 'error' ? '⚠️' : props.type === 'success' ? '✅' : 'ℹ️'))
</script>
<template>
<div role="alert" class="alert" :class="styles">
<span class="mr-2" aria-hidden="true">{{ icon }}</span>
<slot />
</div>
</template>