<script setup lang="ts">
import { ref, defineProps, defineEmits } from 'vue'
import { ElIcon } from 'element-plus'
import { Search } from '@element-plus/icons-vue'
import TOP_IMAGE from '../../../assets/image/background-top-threat.png'

interface QuickSearchProps {
  placeholder?: string
}
const { placeholder = '请输入' } = defineProps<QuickSearchProps>()

const emits = defineEmits<{
  (event: 'search', input: string): void
}>()

const inputValue = ref('')

const search = () => {
  emits('search', inputValue.value)
}
</script>

<template>
  <div class="custom-quick-search">
    <img :src="TOP_IMAGE" class="custom-quick-search-img" alt="" />
    <div class="custom-quick-search-input">
      <div class="search-icon">
        <ElIcon>
          <Search />
        </ElIcon>
      </div>
      <div class="search-input">
        <input type="text" v-model="inputValue" :placeholder="placeholder" class="search-input-content">
      </div>
      <div class="search-button">
        <YaButton type="primary" title="快速搜索" @click="search"></YaButton>
      </div>
    </div>

  </div>
</template>

<style lang="scss" scoped>
.custom-quick-search {
  width: 100%;
  height: 80px;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  background: transparent;
  align-items: center;
  display: flex;
  padding-left: 24px;
  box-sizing: border-box;
  position: relative;

  .custom-quick-search-img {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
  }

  .custom-quick-search-input {
    width: 680px;
    height: 32px;
    display: flex;
    background: #FFFFFF;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.2000);
    align-items: center;
    z-index: 1;

    .search-icon {
      width: 36px;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      color: rgba(0, 0, 0, 0.3000);
    }

    .search-input {
      flex: 1;
      height: 100%;
    }

    .search-input-content {
      width: 100%;
      display: flex;
      padding: 0;
      height: 100%;
      border: none;
      outline: none;
      border-radius: 0;
      font-size: 14px;
      align-items: center;
    }

    .search-input-content:focus {
      border: none;
    }

    .search-input-content::placeholder {
      color: rgba(0, 0, 0, 0.3000);
      font-size: 14px;
    }

    .search-button {
      width: 92px;
      height: 100%;
      display: flex;
      align-items: center;

      .el-button {
        height: 28px;
      }
    }
  }
}
</style>
