primevue-mirror/components/badge/Badge.vue

37 lines
1.0 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
<span :class="badgeClass">
2022-09-14 11:26:01 +00:00
<slot>{{ value }}</slot>
2022-09-06 12:03:37 +00:00
</span>
</template>
<script>
export default {
name: 'Badge',
props: {
value: null,
severity: null,
size: null
},
computed: {
containerClass() {
2022-09-14 11:26:01 +00:00
return this.$slots.default ? 'p-overlay-badge' : this.badgeClass;
2022-09-06 12:03:37 +00:00
},
badgeClass() {
2022-09-14 11:26:01 +00:00
return [
'p-badge p-component',
{
'p-badge-no-gutter': this.value && String(this.value).length === 1,
'p-badge-dot': !this.value && !this.$slots.default,
'p-badge-lg': this.size === 'large',
'p-badge-xl': this.size === 'xlarge',
'p-badge-info': this.severity === 'info',
'p-badge-success': this.severity === 'success',
'p-badge-warning': this.severity === 'warning',
'p-badge-danger': this.severity === 'danger'
}
];
2022-09-06 12:03:37 +00:00
}
}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
</script>