Item.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <SmartLink
  3. :to="`${/^\/(?!\/).*$/.test(to) ? localePath(to) : to}`"
  4. :exact="exact"
  5. :blank="blank"
  6. class="rounded flex-shrink-0 py-2 px-4 transition inline-flex items-center hover:bg-primaryDark hover:text-secondaryDark focus:outline-none focus-visible:bg-primaryDark focus-visible:text-secondaryDark"
  7. :class="[
  8. { 'opacity-75 cursor-not-allowed': disabled },
  9. { 'pointer-events-none': loading },
  10. { 'flex-1': label },
  11. { 'flex-row-reverse justify-end': reverse },
  12. {
  13. 'border border-divider hover:border-dividerDark focus-visible:border-dividerDark':
  14. outline,
  15. },
  16. ]"
  17. :disabled="disabled"
  18. :tabindex="loading ? '-1' : '0'"
  19. >
  20. <span
  21. v-if="!loading"
  22. class="inline-flex items-center"
  23. :class="{ 'self-start': infoIcon }"
  24. >
  25. <i
  26. v-if="icon"
  27. :class="[
  28. label ? (reverse ? 'ml-4 opacity-75' : 'mr-4 opacity-75') : '',
  29. { 'text-accent': active },
  30. ]"
  31. class="material-icons"
  32. >
  33. {{ icon }}
  34. </i>
  35. <SmartIcon
  36. v-if="svg"
  37. :name="svg"
  38. :class="[
  39. label ? (reverse ? 'ml-4 opacity-75' : 'mr-4 opacity-75') : '',
  40. { 'text-accent': active },
  41. ]"
  42. class="svg-icons"
  43. />
  44. </span>
  45. <SmartSpinner v-else class="mr-4 text-secondaryDark" />
  46. <div
  47. class="flex-1 inline-flex items-start truncate"
  48. :class="{ 'flex-col': description }"
  49. >
  50. <div class="font-semibold truncate">
  51. {{ label }}
  52. </div>
  53. <p
  54. v-if="description"
  55. class="font-medium my-2 text-left text-secondaryLight"
  56. >
  57. {{ description }}
  58. </p>
  59. </div>
  60. <i
  61. v-if="infoIcon"
  62. class="ml-6 items-center self-center material-icons"
  63. :class="{ 'text-accent': activeInfoIcon }"
  64. >
  65. {{ infoIcon }}
  66. </i>
  67. </SmartLink>
  68. </template>
  69. <script>
  70. import { defineComponent } from "@nuxtjs/composition-api"
  71. export default defineComponent({
  72. props: {
  73. to: {
  74. type: String,
  75. default: "",
  76. },
  77. exact: {
  78. type: Boolean,
  79. default: true,
  80. },
  81. blank: {
  82. type: Boolean,
  83. default: false,
  84. },
  85. label: {
  86. type: String,
  87. default: "",
  88. },
  89. description: {
  90. type: String,
  91. default: "",
  92. },
  93. icon: {
  94. type: String,
  95. default: "",
  96. },
  97. svg: {
  98. type: String,
  99. default: "",
  100. },
  101. disabled: {
  102. type: Boolean,
  103. default: false,
  104. },
  105. loading: {
  106. type: Boolean,
  107. default: false,
  108. },
  109. reverse: {
  110. type: Boolean,
  111. default: false,
  112. },
  113. outline: {
  114. type: Boolean,
  115. default: false,
  116. },
  117. active: {
  118. type: Boolean,
  119. default: false,
  120. },
  121. activeInfoIcon: {
  122. type: Boolean,
  123. default: false,
  124. },
  125. infoIcon: {
  126. type: String,
  127. default: "",
  128. },
  129. },
  130. })
  131. </script>