Item.vue 2.9 KB

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