<template>
  <div class="icons-container">
    <el-tabs type="border-card">
      <el-tab-pane label="Icons">
        <div class="grid">
          <div v-for="item of svgIcons" :key="item" @click="handleClick(item)">
            <el-tooltip placement="top">
              <div slot="content">
                {{ item }}
              </div>
              <div class="icon-item">
                <svg-icon :icon-class="item" class-name="disabled" />
                <!-- <span>{{ item }}</span> -->
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="Element-UI Icons">
        <div class="grid">
          <div v-for="item of elementIcons" :key="item" @click="handleClick(`el-icon-${item}`)">
            <el-tooltip placement="top">
              <div slot="content">
                {{ item }}
              </div>
              <div class="icon-item">
                <i :class="'el-icon-' + item" />
                <!-- <span>{{ item }}</span> -->
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="更多 Icons">
        <div class="grid">
          <div v-for="item of myIcons" :key="item" @click="handleClick(`iconfont ${item}`)">
            <el-tooltip placement="top">
              <div slot="content">
                {{ item }}
              </div>
              <div class="icon-item">
                <i :class="'iconfont ' + item" />
                <!-- <span>{{ item }}</span> -->
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import svgIcons from './svg-icons'
import elementIcons from './element-icons'
import myIcons from './icons'
export default {
  name: 'Icons',
  data() {
    return {
      svgIcons,
      elementIcons,
      myIcons
    }
  },
  methods: {
    handleClick(text) {
      this.$emit('click', text)
    }
  }
}
</script>

<style lang="scss" scoped>
.icons-container {
  overflow: hidden;

  .el-tab-pane{
    max-height: 400px;
    overflow-y: auto;
  }

  .grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  }
  .icon-item {
    padding-top: 4px;
    margin: 8px;
    height: 30px;
    width: 30px;
    text-align: center;
    float: left;
    font-size: 16px;
    color: #24292e;
    cursor: pointer;
    &:hover{
      background: rgba($color: #000000, $alpha: 0.1);
    }
  }
  span {
    display: block;
    font-size: 12px;
    margin-top: 8px;
  }
  .disabled {
    pointer-events: none;
  }
}
</style>
