<template>
  <div class="tool-tip-btn">
    <el-tooltip
      effect="dark"
      :content="content"
      placement="bottom"
      :disabled="disabled"
    >
      <div
        class="icon-btn"
        @click="clickHandler"
        :class="{ 'disabled-status': disabled }"
      >
        <svg-icon
          :name="name"
          :color="disabled ? '#bfbfbf' : '#595959'"
        ></svg-icon>
      </div>
    </el-tooltip>
  </div>
</template>

<script>
export default {
  name: "ToolTipBtn",
  props: {
    content: {
      type: String,
      default: "",
    },
    name: {
      type: String,
      require: true,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    clickHandler() {
      !this.disabled && this.$emit("click");
    },
  },
};
</script>

<style lang="scss" scoped>
.tool-tip-btn {
  display: inline-block;
  &:not(:first-child) {
    margin-left: 12px;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    &:not(.disabled-status):hover {
      background-color: #f0f0f0;
    }
    &.disabled-status {
      cursor: not-allowed;
    }
  }
}
</style>
