mainSection.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <section :class="['img--desc--section', { reverse: reverse }]">
  3. <!-- Video -->
  4. <div v-if="type === 'video'" class="video--wrap">
  5. <video :src="src" autoplay muted loop playsinline></video>
  6. </div>
  7. <!-- Image -->
  8. <div v-else-if="type === 'image'" class="img--wrap">
  9. <img :src="src" :alt="title" />
  10. </div>
  11. <div class="desc--wrap">
  12. <h3>{{ title }}</h3>
  13. <p>{{ desc }}</p>
  14. <div v-if="button1Title || button2Title" class="btn--wrap mt--24">
  15. <NuxtLink
  16. v-if="button1Title"
  17. :target="button1Target"
  18. :to="button1Link"
  19. :class="['btn', `btn--${button1Color}`]"
  20. >
  21. {{ button1Title }}
  22. </NuxtLink>
  23. <NuxtLink
  24. v-if="button2Title"
  25. :target="button2Target"
  26. :to="button2Link"
  27. :class="['btn', `btn--${button2Color}`]"
  28. >
  29. {{ button2Title }}
  30. </NuxtLink>
  31. </div>
  32. </div>
  33. </section>
  34. </template>
  35. <script setup>
  36. defineProps({
  37. type: {
  38. type: String,
  39. default: 'image',
  40. validator: (value) => ['video', 'image'].includes(value)
  41. },
  42. src: {
  43. type: String,
  44. required: true
  45. },
  46. title: {
  47. type: String,
  48. required: true
  49. },
  50. desc: {
  51. type: String,
  52. required: true
  53. },
  54. reverse: {
  55. type: Boolean,
  56. default: false
  57. },
  58. button1Title: {
  59. type: String,
  60. default: ''
  61. },
  62. button1Link: {
  63. type: String,
  64. default: '#'
  65. },
  66. button1Target: {
  67. type: String,
  68. default: '_self',
  69. validator: (value) => ['_self', '_blank'].includes(value)
  70. },
  71. button1Color: {
  72. type: String,
  73. default: 'gray',
  74. validator: (value) => ['black', 'gray'].includes(value)
  75. },
  76. button2Title: {
  77. type: String,
  78. default: ''
  79. },
  80. button2Link: {
  81. type: String,
  82. default: '#'
  83. },
  84. button2Target: {
  85. type: String,
  86. default: '_self',
  87. validator: (value) => ['_self', '_blank'].includes(value)
  88. },
  89. button2Color: {
  90. type: String,
  91. default: 'gray',
  92. validator: (value) => ['black', 'gray'].includes(value)
  93. }
  94. });
  95. </script>