yunohost-portal/components/BaseAlert.vue

39 lines
762 B
Vue
Raw Normal View History

2023-08-28 14:44:39 +02:00
<script setup lang="ts">
const props = withDefaults(
defineProps<{
message?: string
variant?: 'info' | 'success' | 'warning' | 'error'
icon?: string
assertive?: boolean
}>(),
{
message: '',
variant: 'info',
icon: undefined,
assertive: false,
},
)
const classVariant = computed(() => {
return {
info: 'alert-info',
success: 'alert-success',
warning: 'alert-warning',
error: 'alert-error',
}[props.variant]
})
</script>
<template>
<div
:aria-live="assertive ? 'assertive' : 'polite'"
aria-atomic="true"
2023-11-30 15:58:10 +01:00
:class="'alert ' + classVariant"
2023-08-28 14:44:39 +02:00
>
2023-11-08 19:04:55 +01:00
<YIcon v-if="icon" :name="icon" size="2em" aria-hidden="true" />
2023-08-28 14:44:39 +02:00
<slot name="default">
{{ message }}
</slot>
</div>
</template>