popover.vue 1.44 KB
<template>
    <section class="popover" v-show="props.isVisible">
        <div class="popover-arrow" :style="{ top: `${props.arrowTop}px` }" />
        <span class="popover-header" v-text="props.title" />
        <span class="popover-content">
            <slot name="popover-content" />
        </span>
    </section>
</template>
<script setup>
const props = defineProps({
    title: {
        type: String,
        default: 'Title'
    },
    isVisible: {
        type: Boolean,
        default: false
    },
    arrowTop: {
        type: Number,
        default: -1000
    }
});
</script>
<style lang="less">
.popover {
    display: flex;
    flex-direction: column;
    width: 290px;
    border-radius: 10px;
    box-shadow: rgba(0, 0, 0, 0.1) 1px 1px 2px 0px;
    border: 1px solid #cdd1d5;
    background-color: #ffffff;
    padding: 12px 15px;
    pointer-events: initial;
    .popover-arrow {
        position: absolute;
        background-color: rgb(255, 255, 255);
        width: 14px;
        height: 14px;
        left: 81px;
        transform: rotate(45deg);
        border-bottom: 1px solid rgb(205, 209, 213);
        border-left: 1px solid rgb(205, 209, 213);
        display: none;
    }
    .popover-header {
        display: flex;
        flex-direction: row;
        -webkit-box-pack: justify;
        justify-content: space-between;
        margin: 0px;
        font-size: 16px;
        line-height: 24px;
        font-weight: 700;
    }
}
</style>