2026-08-20 06:20:16 +07:00
|
|
|
|
<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':
|
2026-08-20 21:34:45 +07:00
|
|
|
|
return 'alert-error'
|
2026-08-20 06:20:16 +07:00
|
|
|
|
case 'success':
|
2026-08-20 21:34:45 +07:00
|
|
|
|
return 'alert-success'
|
2026-08-20 06:20:16 +07:00
|
|
|
|
default:
|
2026-08-20 21:34:45 +07:00
|
|
|
|
return 'alert-info'
|
2026-08-20 06:20:16 +07:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const icon = computed(() => (props.type === 'error' ? '⚠️' : props.type === 'success' ? '✅' : 'ℹ️'))
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-08-20 21:34:45 +07:00
|
|
|
|
<div role="alert" class="alert" :class="styles">
|
2026-08-20 06:20:16 +07:00
|
|
|
|
<span class="mr-2" aria-hidden="true">{{ icon }}</span>
|
|
|
|
|
|
<slot />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|