<template>
    <div :class="bem()">
        <div v-if="loading" :class="bem('loading')" :style="{'min-height': minHeight + 'px'}">
            <div>
                <i :class="bem('load-icon')"/>加载中...
            </div>
        </div>
        <div v-else-if="errMsg" :class="bem('err')">{{errMsg}}</div>
    </div>
</template>

<script>
import { createComponentName, componentMixin } from '../../_utils/component';

export default {
    name: createComponentName('loading-mask'),
    mixins: [componentMixin],
    props: {
        minHeight: {
            type: Number,
            default: 200
        },
        loading: {
            type: Boolean,
            default: false
        },
        errMsg: {
            type: String,
            default: ''
        }
    }
};
</script>

<style lang="less" scoped>
@import '../../_styles/base.less';

@b: gd-loading-mask;

@keyframes run {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.@{b} {
    position: absolute;
    top: 0;
    height: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    &__loading {
        justify-content: center;
        display: flex;
        align-items: center;
        font-size: @font-size-base;
        color: #999;
    }

    &__load-icon {
        display: inline-block;
        width: 14px;
        height: 14px;
        background-image: svg-load('../../../assets/icons/loading-new.svg');
        background-size: cover;
    }

    &__load-icon {
        animation: run 1s linear infinite;
        vertical-align: middle;
        margin-top: -3px;
        margin-right: 4px;
    }

    &__err {
        text-align: center;
    }
}
</style>
