You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.1 KiB
Vue
64 lines
1.1 KiB
Vue
|
8 months ago
|
<template>
|
||
|
|
<div>
|
||
|
|
<div class="dot" v-if="dot" :style="customStyle"></div>
|
||
|
|
<div class="badge" v-else-if="text" :style="customStyle">{{ text }}</div>
|
||
|
|
<div class="hidden">{{ props.num }}</div>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script lang="ts" setup>
|
||
|
|
import {
|
||
|
|
StyleValue,
|
||
|
|
computed,
|
||
|
|
defineProps,
|
||
|
|
withDefaults,
|
||
|
|
} from '../utils/transformVue'
|
||
|
|
|
||
|
|
const props = withDefaults(
|
||
|
|
defineProps<{
|
||
|
|
num: number
|
||
|
|
max?: number
|
||
|
|
dot?: boolean
|
||
|
|
customStyle?: StyleValue
|
||
|
|
}>(),
|
||
|
|
{
|
||
|
|
max: 99,
|
||
|
|
dot: false,
|
||
|
|
}
|
||
|
|
)
|
||
|
|
const max = props.max || 99
|
||
|
|
const text = computed(() => {
|
||
|
|
return props.num > 0 ? (props.num > max ? `${max}+` : props.num + '') : ''
|
||
|
|
})
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped lang="scss">
|
||
|
|
.dot {
|
||
|
|
background-color: #ff4d4f;
|
||
|
|
color: #fff;
|
||
|
|
width: 10px;
|
||
|
|
height: 10px;
|
||
|
|
border-radius: 5px;
|
||
|
|
box-sizing: border-box;
|
||
|
|
z-index: 99;
|
||
|
|
}
|
||
|
|
|
||
|
|
.badge {
|
||
|
|
background-color: #ff4d4f;
|
||
|
|
color: #fff;
|
||
|
|
font-size: 12px;
|
||
|
|
min-width: 20px;
|
||
|
|
height: 20px;
|
||
|
|
line-height: 19px;
|
||
|
|
border-radius: 10px;
|
||
|
|
padding: 0 5px;
|
||
|
|
box-sizing: border-box;
|
||
|
|
text-align: center;
|
||
|
|
z-index: 99;
|
||
|
|
position: relative;
|
||
|
|
}
|
||
|
|
.hidden {
|
||
|
|
display: none;
|
||
|
|
}
|
||
|
|
</style>
|