Item.vue 2.9 KB

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