<template>
  <ui-dropdown
    class="ui-more-dropdown"
    :class="['ui-more-dropdown--' + size, { 'is-wisp': wisp }]"
    @command="handleCommandChange"
  >
    <template slot="reference" slot-scope="{ visible }">
      <div class="ui-more-dropdown__handle" :class="{'is-active': visible}" @click.stop.prevent>
        <span class="ui-more-dropdown__handle-icon" />
      </div>
    </template>
    <slot />
  </ui-dropdown>
</template>
<script>
import { Dropdown } from '@huntianning/components/packages/dropdown'

export default {
  name: 'UiMoreDropdown',
  props: {
    size: {
      type: String,
      default: 'medium',
      validator(value) {
        return ['medium', 'small', 'mini'].includes(value)
      }
    },
    wisp: {
      type: Boolean,
      default: false
    }
  },
  components: {
    UiDropdown: Dropdown
  },
  methods: {
    handleCommandChange(evt) {
      this.$emit('command', evt)
    }
  }
}
</script>
<style lang="less">
.ui-more-dropdown{
  &.is-wisp {
    .ui-more-dropdown__handle{
      padding-left: 0;
      padding-right: 0;
      &:hover, &.is-active {
        &:after {
          background-color: #333;
        }
        .ui-more-dropdown__handle-icon{
          &:after, &:before{
            background-color: #333;
          }
        }
      }
    }
  }
  &:not(.is-wisp) {
    .ui-more-dropdown__handle{
      &:hover, &.is-active {
        background-color: rgba(0,0,0,.1);
      }
    }
  }
}
.ui-more-dropdown__handle{
  height: 3px;
  padding: 14px 9px 15px;
  border-radius: 3px;
  cursor: pointer;
  &:after {
    content: '';
    display: inline-block;
    vertical-align: top;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background-color: #999;
    margin: 0 1px;
  }
}
.ui-more-dropdown__handle-icon{
  position: relative;
  &:after, &:before{
    content: '';
    display: inline-block;
    vertical-align: top;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background-color: #999;
    margin: 0 1px;
  }
}
.ui-more-dropdown--medium {
  .ui-more-dropdown__handle{
    padding-top: 18px;
    padding-bottom: 19px;
    padding-left: 12px;
    padding-right: 12px;
  }
}
.ui-more-dropdown--small {
  .ui-more-dropdown__handle{
    padding-top: 14px;
    padding-bottom: 15px;
  }
}
.ui-more-dropdown--mini {
  .ui-more-dropdown__handle{
    padding-top: 12px;
    padding-bottom: 13px;
  }
}
</style>
