ColorPicker.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <div class="car--list--wrap" :class="titleOption ? 'title--type' : ''">
  3. <h3 v-if="titleOption" class="title--exterior">Exterior Colors</h3>
  4. <div class="thumb">
  5. <img :src="colors[selectedIndex].image" :alt="colors[selectedIndex].title" />
  6. </div>
  7. <div class="color--pick--contents">
  8. <div class="color--pick">
  9. <div
  10. v-for="(color, index) in colors"
  11. :key="index"
  12. :style="{ backgroundColor: color.colorValue , borderColor : color.colorValue }"
  13. :class="{ actv: selectedIndex === index }"
  14. @click="selectedIndex = index"
  15. >
  16. <div :style="{ backgroundColor: color.colorValue}"></div>
  17. </div>
  18. </div>
  19. <div class="color--info">
  20. <h1>Paint Color : </h1>
  21. <span>{{ colors[selectedIndex].title }}</span>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script setup>
  27. const props = defineProps({
  28. titleOption: {
  29. type: Boolean,
  30. default: false
  31. },
  32. colors: {
  33. type: Array,
  34. required: true
  35. },
  36. })
  37. const selectedIndex = ref(0)
  38. </script>