LinkList.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div class="inner--link--contents">
  3. <ul :class="{ 'p--0': pd === false }">
  4. <li v-for="(item, index) in links" :key="index">
  5. <NuxtLink :to="item.url" :target="item.target || '_self'" :class="item.class">
  6. <span v-if="item.frontIcon" v-html="item.frontIcon"></span>
  7. {{ item.text }}
  8. <svg
  9. v-if="item.showIcon !== false"
  10. width="24"
  11. height="24"
  12. aria-label="New Tab"
  13. xmlns="http://www.w3.org/2000/svg"
  14. stroke="#fff"
  15. data-testid="link-icon"
  16. >
  17. <title>New Tab</title>
  18. <path
  19. d="M17.5 11.594V20.5h-15v-15h7.969m4.031-3h6v6m-9 3 9-9-9 9Z"
  20. stroke="#fff"
  21. fill="none"
  22. ></path>
  23. </svg>
  24. <svg
  25. v-else
  26. width="24"
  27. height="24"
  28. aria-label="Same Tab"
  29. xmlns="http://www.w3.org/2000/svg"
  30. stroke="#fff"
  31. data-testid="link-icon"
  32. >
  33. <title>Same Tab</title>
  34. <path d="m10 16.9 5.5-5.4L10 6.1" stroke="#fff" fill="none"></path>
  35. </svg>
  36. </NuxtLink>
  37. </li>
  38. </ul>
  39. </div>
  40. </template>
  41. <script setup>
  42. // Props 정의
  43. const props = defineProps({
  44. links: {
  45. type: Array,
  46. required: true,
  47. default: () => [],
  48. validator: (value) => {
  49. // 각 링크 객체가 필수 속성을 가지고 있는지 확인
  50. return value.every(
  51. (link) => link.hasOwnProperty("text") && link.hasOwnProperty("url")
  52. );
  53. },
  54. },
  55. pd: {
  56. type: Boolean,
  57. default: true, // 기본값은 패딩 있음
  58. },
  59. });
  60. // 링크 데이터 구조 예시:
  61. // [
  62. // {
  63. // text: "Q8 50 TDI quattro exclusive edition 예약금 결제",
  64. // url: "/reservation/q8",
  65. // target: "_blank", // 선택사항, 기본값: "_self"
  66. // showIcon: true, // 선택사항, 기본값: true
  67. // class: "custom-class" // 선택사항
  68. // },
  69. // {
  70. // text: "RS 6 Avant 예약금 결제",
  71. // url: "/reservation/rs6",
  72. // target: "_self",
  73. // showIcon: false
  74. // }
  75. // ]
  76. </script>