layui/src/module/badge/index.vue

38 lines
740 B
Vue
Raw Normal View History

2021-11-17 15:37:54 +00:00
<script lang="ts">
export default {
name: "LayBadge",
};
</script>
2021-09-27 08:42:13 +00:00
2021-11-17 15:37:54 +00:00
<script setup lang="ts">
import { computed, defineProps } from "vue";
import "./index.less";
2021-09-27 08:42:13 +00:00
2021-11-17 15:37:54 +00:00
export interface LayBadgeProps {
type?: "dot" | "rim";
theme?: string;
color?: string;
}
const props = defineProps<LayBadgeProps>();
2021-09-27 08:42:13 +00:00
2021-11-17 15:37:54 +00:00
const classes = computed(() => {
return [
{
"layui-badge": !props.type,
"layui-badge-dot": props.type == "dot",
"layui-badge-rim": props.type == "rim",
},
`layui-bg-${props.theme}`,
];
});
2021-09-27 08:42:13 +00:00
2021-11-17 15:37:54 +00:00
const styles = computed(() => {
props.color ? `background-color: ${props.color}` : "";
});
</script>
2021-11-17 15:37:54 +00:00
<template>
<span :class="classes" :style="styles">
<slot v-if="type != 'dot'" />
</span>
</template>