<template>
  <div class="select-container">
    <div class="select-box" @click="handleShow">
      <div class="text1" :style="{ height: modelValue + 'px' }"></div>
      <div class="icon"></div>
    </div>
    <div v-show="show" class="select-content">
      <div v-for="(item, index) in options" :key="index" :class="modelValue === item.value ? 'item item-active' : 'item'" @click="handleClick(item.value)">
        <div class="text1" :style="{ height: item.value + 'px' }"></div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup name="LineWidthSelect">
interface Props {
  modelValue: boolean;
  options: object[];
}
const props = withDefaults(defineProps<Props>(), {});
const emits = defineEmits(['update:modelValue']);

let show = ref();
const handleShow = () => {
  show.value = true;
};
const handleClick = (value: string) => {
  emits('update:modelValue', value);
  show.value = false;
};
</script>

<style lang="scss" scoped>
.select-container {
  position: relative;
}
.select-box {
  width: 118px;
  height: 22px;
  line-height: 22px;
  background-color: rgba(26, 144, 255, 0.15) !important;
  border: 1px solid rgba(26, 144, 255, 0.15) !important;
  padding: 4px 8px !important;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 6px;
    background: url('@/assets/images/inputIcon1.png') no-repeat;
    background-size: 100% 100%;
  }
  &::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 6px;
    height: 6px;
    background: url('@/assets/images/inputIcon2.png') no-repeat;
    background-size: 100% 100%;
  }
  .text1 {
    flex: 1;
    height: 1px;
    background-color: #9dc2da;
    margin-right: 15px;
  }
  .icon {
    width: 7px;
    height: 13px;
    background: url('@/assets/images/select.png') no-repeat;
    background-size: 100% 100%;
  }
}
.select-content {
  position: absolute;
  left: 0;
  bottom: -65px;
  width: 100%;
  background-color: #113a84;
  border: 1px solid #124b9d;
  box-shadow: inset 0 0 20px #1a90ff80 !important;
  z-index: 9;
  padding: 6px 0;
  .item {
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px !important;
    cursor: pointer;
    &:hover {
      background-color: #1c335f;
    }
  }
  .item-active {
    background-color: #1c335f;
  }
  .text1 {
    flex: 1;
    height: 1px;
    background-color: #9dc2da;
  }
}
</style>
