<template>
  <CollapseItem name="文本样式" :expanded="true">
    <SettingItemBox
      :name="`颜色-${index + 1}`"
      v-for="(item, index) in optionData.textColors"
      :key="index"
    >
      <SettingItem name="颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.textColors[index]"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.textColors[index] = option.textColors[index]"
        >
          恢复默认
        </n-button>
      </SettingItem>
    </SettingItemBox>
    <SettingItemBox
      :name="`大小-${index + 1}`"
      v-for="(item, index) in optionData.textSize"
      :key="index"
    >
      <SettingItem name="">
        <n-input-number
          size="small"
          v-model:value="optionData.textSize[index]"
          :min="10"
        />
      </SettingItem>
    </SettingItemBox>
  </CollapseItem>
  <CollapseItem name="样式" :expanded="true">
    <SettingItemBox name="边框颜色">
      <SettingItem name="">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.borderColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.borderColor = option.borderColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
    </SettingItemBox>
    <SettingItemBox name="背景颜色">
      <SettingItem name="">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.backgroundColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.backgroundColor = option.backgroundColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
    </SettingItemBox>
  </CollapseItem>
  <CollapseItem name="样式" :expanded="true">
    <SettingItemBox
      :name="`颜色-${index + 1}`"
      v-for="(item, index) in optionData.animalColor"
      :key="index"
    >
      <SettingItem name="颜色1">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.animalColor[index].color1"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.animalColor[index].color1 = option.animalColor[index].color1"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="颜色2">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.animalColor[index].color2"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.animalColor[index].color2 = option.animalColor[index].color2"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <n-button ghost @click="optionData.animalColor.splice(index, 1)"> - </n-button>
    </SettingItemBox>
    <SettingItem>
      <n-button size="small" @click="optionData.animalColor.push({ color1: '#215229' ,color2: '#22FCF0' })"> + 新增</n-button>
    </SettingItem>
  </CollapseItem>
</template>

<script setup lang="ts">
import { PropType } from 'vue'
import {
  CollapseItem,
  SettingItemBox,
  SettingItem
} from '@/components/Pages/ChartItemSetting'
import { option } from './config'

const props = defineProps({
  optionData: {
    type: Object as PropType<typeof option>,
    required: true
  }
})
</script>
