<template>
  <div
    class="o-card has-padding u-pointer"
    @click="go"
  >
    <div class="l-flex--row center c-sibling-item--v">
      <i
        class="l-flex__none c-sibling-item o-icon medium has-bg"
        :class="type"
      />
      <div class="c-sibling-item far o-card__main u-bold u-relative">
        <auto-text
          class="u-text-center"
          :text="title"
        />
        <i
          v-if="count"
          class="o-card__count"
        >
          {{ count }}
        </i>
      </div>
    </div>
    <auto-text
      v-if="tip"
      class="c-sibling-item--v o-card__tip u-bold u-text-center"
      :text="tip"
    />
    <auto-text
      v-if="desc"
      class="c-sibling-item--v o-card__desc u-text-center"
      :text="desc"
    />
  </div>
</template>

<script>
export default {
  name: 'Card',
  props: {
    type: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    tip: {
      type: String,
      default: ''
    },
    desc: {
      type: String,
      default: ''
    },
    count: {
      type: [String, Number],
      default: null
    }
  },
  methods: {
    go () {
      // todo
    }
  }
}
</script>

<style lang="scss" scoped>
.o-card {
  display: inline-flex;
  flex-direction: column;
  height: 100px;
  color: $black;
  font-size: 16px;
  border-radius: $radius;
  background-color: #fff;

  &__main {
    min-width: 0;
  }

  &__count {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 20px;
    padding: 2px 4px;
    color: #fff;
    font-size: 12px;
    font-style: normal;
    line-height: 1;
    border: 2px solid #fff;
    border-radius: 10px;
    background-color: $error--dark;
    transform: translate(50%, -50%);
  }

  &__tip {
    padding-left: 48px;
  }

  &__desc {
    color: $gray;
    font-size: 12px;
  }
}

.o-icon {
  &.info {
    background-image: url("~@/assets/icon_info.png");
  }

  &.safety {
    background-image: url("~@/assets/icon_safety.png");
  }

  &.performance {
    background-image: url("~@/assets/icon_performance.png");
  }

  &.log {
    background-image: url("~@/assets/icon_log.png");
  }

  &.date {
    background-image: url("~@/assets/icon_date.png");
  }
}
</style>
