Newer
Older
adminAccountabilityFront / src / views / home / components / Card.vue
liyaguang on 15 Sep 2023 1 KB feat(*): 首页完成
<script lang="ts" setup name="Card">
import { computed } from 'vue'
import svgIcon from '@/components/SvgIcon/index.vue'
const props = defineProps({
  title: {
    type: String,
    default: '标题',
  },
  subtitle: {
    type: String,
    default: '',
  },
  icon: {
    type: String,
    default: '',
  },
  context: {
    type: [String, Number],
    default: '',
  },
  color: {
    type: String,
    default: '#40c9c6',
  },
})
const backgroundColor = computed(() => {
  return {
    // color: this.color,
    'background-color': props.color,
  }
})
</script>

<template>
  <el-card :body-style="{ padding: '0px' }" shadow="always">
    <div :style="backgroundColor" class="card-panel">
      <div class="card-panel-icon-wrapper">
        <el-icon class="card-panel-icon">
          <svg-icon :name="props.icon" />
        </el-icon>
      </div>
      <div class="card-panel-description">
        <div class="card-panel-text">
          {{ props.title }}
        </div>
        <div class="card-panel-num">
          {{ props.context }}
        </div>
      </div>
    </div>
  </el-card>
</template>

<style lang="scss" scoped>
  .card-panel {
    height: 192px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #fff;
    background: #fff;
    box-shadow: 4px 4px 40px rgb(0 0 0 / 5%);
    border-color: rgb(0 0 0 / 5%);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }
    }

    .card-panel-icon-wrapper {
      margin: 16px 0 0;
      padding: 14px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
      text-align: center;
    }

    .card-panel-icon {
      font-size: 58px;
    }

    .card-panel-description {
      font-weight: bold;
      margin: 26px;

      /* margin-left: 10px; */
      text-align: center;

      .card-panel-text {
        line-height: 22px;
        color: #fff;
        font-size: 20px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
</style>