mirror of
https://github.com/YunoHost/yunohost-portal.git
synced 2024-09-03 20:06:23 +02:00
add BaseAlert component
This commit is contained in:
parent
4275efe402
commit
7c513154eb
1 changed files with 38 additions and 0 deletions
38
components/BaseAlert.vue
Normal file
38
components/BaseAlert.vue
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<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"
|
||||||
|
:class="'mt-10 alert ' + classVariant"
|
||||||
|
>
|
||||||
|
<Icon v-if="icon" :name="icon" size="2em" aria-hidden="true" />
|
||||||
|
<slot name="default">
|
||||||
|
{{ message }}
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
Add table
Reference in a new issue