<template>
    <div class="zr-card" :class="[align==='column'?'zr-card--column':'zr-card--row',{'zr-card-border':border},{'radius':radius},{'always':shadow==='always'},{'never':shadow==='never'},{'hover':shadow==='hover'}]" :style="{'backgroundColor':backgroundColor,'color':color}">
        <div class="zr-card-top" v-if="header">
            <div class="zr-card-top-title">
                <el-link type="type" class="icon" :underline="false" v-if="icon"><i :class="icon"></i></el-link>
                {{ title }}
            </div>
            <div class="zr-card-top-slot">
                <slot name="header"></slot>
            </div>
        </div>
        <div class="zr-card-content" :class="{'space':!header}">
            <slot></slot>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        backgroundColor: {
            type: String,
            default: "#FFFFFF",
        },
        color: {
            type: String,
            default: "",
        },
        type: {
            type: String,
            default: "primary",
        },
        title: {
            type: String,
            default: "",
        },
        radius: {
            type: Boolean,
            default: true,
        },
        align: {
            type: String,
            default: 'column',  // row：横向 column：纵向
        },
        header: {
            type: Boolean,
            default: true,
        },
        icon: {
            type: String,
            default: "",
        },
        shadow: {
            type: String,  //always / hover / never
            default: 'always',
        },
        border: {
            type: Boolean,
            default: true,
        },
    },
    data() {
        return {};
    },
    methods: {},
};
</script>

<style lang="less" scoped>
.zr-card {
    width: 100%;
    display: flex;
    height: auto;
    color: #333;
    margin-bottom: 10px;
    .zr-card-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 14px;
        line-height: 40px;
        padding: 10px 20px;
        .zr-card-top-title {
            font-size: 16px;
            font-weight: normal;
            .icon {
                position: relative;
                top: -1px;
                font-size: 18px;
            }
        }
    }
    .zr-card-content {
        padding: 0 20px 20px 20px;
    }
    .space {
        padding: 20px;
    }
}
.zr-card--column {
    flex-direction: column;
}
.zr-card--row {
    flex-direction: row;
}
.radius {
    border-radius: 6px;
    overflow: hidden;
}
.always {
    box-shadow: 0 2px 6px 0 rgba(0,0,0,0.1);
}
.hover.hover {
    box-shadow: 0 2px 6px 0 rgba(0,0,0,0.1);
}
.never {
    box-shadow: none;
}
.zr-card-border {
    border: 1px solid #EBEEF5;
}


</style>