UnisKB/ui/src/components/card-box/index.vue

75 lines
1.5 KiB
Vue
Raw Normal View History

2023-10-25 10:35:28 +00:00
<template>
<el-card shadow="hover" class="card-box" @mouseenter="cardEnter()" @mouseleave="cardLeave()">
<div class="card-header">
<slot name="header">
<div class="title flex">
<AppAvatar class="mr-10">
<el-icon><Document /></el-icon>
</AppAvatar>
<h3>{{ title }}</h3>
</div>
</slot>
</div>
<div class="description mt-10">
<slot name="description">
{{ description }}
</slot>
</div>
<slot />
<slot name="mouseEnter" v-if="$slots.mouseEnter && show" />
<div class="card-footer" v-if="$slots.footer">
<slot name="footer" />
</div>
</el-card>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
defineOptions({ name: 'CardBox' })
const props = defineProps({
title: {
type: String,
default: '标题'
},
description: {
type: String,
default: ''
}
})
const show = ref(false)
function cardEnter() {
show.value = true
}
function cardLeave() {
show.value = false
}
</script>
<style lang="scss" scoped>
.card-box {
font-size: 14px;
position: relative;
min-height: 150px;
.card-header {
.title {
align-items: center;
h3 {
font-size: 15px;
}
}
}
.description {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
height: 40px;
}
.card-footer {
position: absolute;
bottom: 0;
min-height: 30px;
}
}
</style>