Secondary.vue 2.9 KB

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