<!--
 * @Author: 曹捷
 * @Date: 2021-03-18 09:43:15
 * @LastEditors: 曹捷
 * @LastEditTime: 2021-09-07 16:52:33
 * @Description: 自定义按钮  目前支持四种类型  三种动画
-->
<template>
  <button class="obit-button" :class="classObject">
    <span>
      <slot></slot>
    </span>
  </button>
</template>

<script>
export default {
  props: {
    type: {
      type: String,//default primary danger org
      default: 'default'
    },
    // 动画特效
    animation: {
      //mark-(top right bottom left) 
      // line-left-bottom 反转 reverse
      // line-top-bottom 反转
      type: String,
      default: 'mark-left'
    },
  },
  methods: {
  },
  computed: {
    classObject: function () {
      let obj = {}
      obj['btn-' + this.type] = true
      obj['ani-' + this.animation] = true
      if (this.animation.indexOf('line') !== -1) {
        obj['ani-line'] = true
      } else if (this.animation.indexOf('mark') !== -1) {
        obj['ani-mark'] = true
      }
      return obj
    }
  }
}
</script>

<style lang="less">
.obit-button {
  height: 36px;
  color: #fff;
  border-radius: 5px;
  padding: 0px 25px;
  line-height: 36px;
  font-family: 'Lato', sans-serif;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.5s ease;
  position: relative;
  display: inline-block;
  box-shadow: inset 2px 2px 2px 0px rgba(255, 255, 255, 0.5),
    7px 4px 20px 0px rgba(0, 0, 0, 0.1), 1px 2px 1px 0px rgba(0, 0, 0, 0.1);
  outline: none;
  position: relative;
}
.ani-line {
  padding: 0;
  span {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0px 25px;
  }
}
// 颜色1 默认
.btn-default {
  color: #000;
}
// 颜色2  蓝色
.btn-primary {
  background: rgb(0, 172, 238);
  background: linear-gradient(
    0deg,
    rgba(0, 172, 238, 1) 0%,
    rgba(2, 126, 251, 1) 100%
  );
}
.btn-primary :hover {
  color: rgba(2, 126, 251, 1);
}
// 颜色3 危险红
.btn-danger {
  background: rgb(255, 27, 0);
  background: linear-gradient(
    0deg,
    rgba(255, 27, 0, 1) 0%,
    rgba(251, 75, 2, 1) 100%
  );
}
.btn-danger:hover {
  color: #f0094a;
}
// 颜色4 橘子
.btn-org {
  background: rgb(255, 151, 0);
  background: linear-gradient(
    0deg,
    rgba(255, 151, 0, 1) 0%,
    rgba(255, 100, 2, 1) 100%
  );
}
.btn-org:hover {
  color: rgb(255, 151, 0);
}

// 动效  上下两条线  加反转
.btn-default.ani-line-top-bottom:before,
.btn-default.ani-line-top-bottom:after {
  background: #d9d9d9;
}
.btn-primary.ani-line-top-bottom:before,
.btn-primary.ani-line-top-bottom:after {
  background: rgba(2, 126, 251, 1);
}
.btn-danger.ani-line-top-bottom:before,
.btn-danger.ani-line-top-bottom:after {
  background: #f0094a;
}
.btn-org.ani-line-top-bottom:before,
.btn-org.ani-line-top-bottom:after {
  background: rgb(255, 151, 0);
}
.ani-line-top-bottom:before,
.ani-line-top-bottom:after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  height: 2px;
  width: 0;
  box-shadow: -1px -1px 5px 0px #fff, 7px 7px 20px 0px #0003,
    4px 4px 5px 0px #0002;
  transition: 400ms ease all;
}
.ani-line-top-bottom:after {
  right: inherit;
  top: inherit;
  left: 0;
  bottom: 0;
}
.reverse.ani-line-top-bottom:before {
  left: 0;
  right: inherit;
}
.reverse.ani-line-top-bottom:after {
  left: inherit;
  top: inherit;
  right: 0;
  bottom: 0;
}

.ani-line-top-bottom:hover:before,
.ani-line-top-bottom:hover:after {
  width: 100%;
  transition: 500ms ease all;
}

// 动效 从右上角和左下角出发的四根线形成border
// 反转  从左上角和右下角出发四根border
.btn-default.ani-line-left-bottom:before,
.btn-default.ani-line-left-bottom:after {
  background: #d9d9d9;
}
.btn-default.ani-line-left-bottom {
  span:before,
  span:after {
    background: #d9d9d9;
  }
}
.btn-primary.ani-line-left-bottom:before,
.btn-primary.ani-line-left-bottom:after {
  background: rgba(2, 126, 251, 1);
}
.btn-primary.ani-line-left-bottom {
  span:before,
  span:after {
    background: rgba(2, 126, 251, 1);
  }
}
.btn-danger.ani-line-left-bottom:before,
.btn-danger.ani-line-left-bottom:after {
  background: #f0094a;
}
.btn-danger.ani-line-left-bottom {
  span:before,
  span:after {
    background: #f0094a;
  }
}
.btn-org.ani-line-left-bottom:before,
.btn-org.ani-line-left-bottom:after {
  background: rgb(255, 151, 0);
}
.btn-org.ani-line-left-bottom {
  span:before,
  span:after {
    background: rgb(255, 151, 0);
  }
}
.ani-line-left-bottom:before,
.ani-line-left-bottom:after {
  position: absolute;
  content: '';
  right: 0;
  top: 0;
  transition: all 0.5s ease;
}
.reverse.ani-line-left-bottom:before,
.reverse.ani-line-left-bottom:after {
  left: 0;
  top: 0;
  right: auto;
}

.ani-line-left-bottom:before {
  height: 0%;
  width: 2px;
}
.ani-line-left-bottom:after {
  width: 0%;
  height: 2px;
}
.ani-line:hover {
  background: transparent;
  box-shadow: none;
}

.ani-line-left-bottom {
  span:before,
  span:after {
    position: absolute;
    content: '';
    left: 0;
    bottom: 0;
    transition: all 0.5s ease;
  }
}
.reverse.ani-line-left-bottom {
  span:before,
  span:after {
    right: 0;
    bottom: 0;
    left: auto;
  }
}
.ani-line-left-bottom span:before {
  width: 2px;
  height: 0%;
}
.ani-line-left-bottom span:after {
  width: 0%;
  height: 2px;
}
.ani-line-left-bottom:hover:before {
  height: 100%;
}
.ani-line-left-bottom:hover:after {
  width: 100%;
}
.ani-line-left-bottom span:hover:before {
  height: 100%;
}
.ani-line-left-bottom span:hover:after {
  width: 100%;
}

// 动画效果 遮盖 移动 四个方向 top bottom left right
.ani-mark:after {
  position: absolute;
  content: '';
  width: 0;
  height: 0;
  top: 0;
  left: 0;
  direction: rtl;
  z-index: -1;
  box-shadow: -7px -7px 20px 0px #fff9, -4px -4px 5px 0px #fff9,
    7px 7px 20px 0px #0002, 4px 4px 5px 0px #0001;
  transition: all 0.5s ease;
}
.ani-mark-left:after,
.ani-mark-right:after {
  height: 100%;
}
.ani-mark-top:after,
.ani-mark-bottom:after {
  width: 100%;
}
.ani-mark:hover:after {
  z-index: 1;
}
.ani-mark-left:hover:after {
  width: 100%;
  left: 0;
  right: auto;
}
.ani-mark-right:hover:after {
  width: 100%;
  left: auto;
  right: 0;
}
.ani-mark-top:hover:after {
  height: 100%;
  top: 0;
  bottom: auto;
}
.ani-mark-bottom:hover:after {
  height: 100%;
  bottom: 0;
  top: auto;
}
.ani-mark-left:active,
.ani-mark-right:active {
  top: 2px;
}
</style>
