Secondary.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <SmartLink
  3. :to="`${/^\/(?!\/).*$/.test(to) ? localePath(to) : to}`"
  4. :exact="exact"
  5. :blank="blank"
  6. class="font-semibold py-2 transition inline-flex items-center justify-center 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. >
  29. <span
  30. v-if="!loading"
  31. class="inline-flex items-center justify-center whitespace-nowrap"
  32. :class="{ 'flex-row-reverse': reverse }"
  33. >
  34. <i
  35. v-if="icon"
  36. class="material-icons"
  37. :class="[
  38. { '!text-2xl': large },
  39. label ? (reverse ? 'ml-2' : 'mr-2') : '',
  40. ]"
  41. >
  42. {{ icon }}
  43. </i>
  44. <SmartIcon
  45. v-if="svg"
  46. :name="svg"
  47. class="svg-icons"
  48. :class="[
  49. { '!h-6 !w-6': large },
  50. label ? (reverse ? 'ml-2' : 'mr-2') : '',
  51. ]"
  52. />
  53. {{ label }}
  54. <div v-if="shortcut.length" class="ml-2">
  55. <kbd
  56. v-for="(key, index) in shortcut"
  57. :key="`key-${index}`"
  58. class="bg-dividerLight rounded text-secondaryLight ml-1 px-1 inline-flex"
  59. >
  60. {{ key }}
  61. </kbd>
  62. </div>
  63. </span>
  64. <SmartSpinner v-else />
  65. </SmartLink>
  66. </template>
  67. <script lang="ts">
  68. import { defineComponent } from "@nuxtjs/composition-api"
  69. export default defineComponent({
  70. props: {
  71. to: {
  72. type: String,
  73. default: "",
  74. },
  75. exact: {
  76. type: Boolean,
  77. default: true,
  78. },
  79. blank: {
  80. type: Boolean,
  81. default: false,
  82. },
  83. label: {
  84. type: String,
  85. default: "",
  86. },
  87. icon: {
  88. type: String,
  89. default: "",
  90. },
  91. svg: {
  92. type: String,
  93. default: "",
  94. },
  95. color: {
  96. type: String,
  97. default: "",
  98. },
  99. disabled: {
  100. type: Boolean,
  101. default: false,
  102. },
  103. loading: {
  104. type: Boolean,
  105. default: false,
  106. },
  107. reverse: {
  108. type: Boolean,
  109. default: false,
  110. },
  111. rounded: {
  112. type: Boolean,
  113. default: false,
  114. },
  115. large: {
  116. type: Boolean,
  117. default: false,
  118. },
  119. outline: {
  120. type: Boolean,
  121. default: false,
  122. },
  123. shortcut: {
  124. type: Array,
  125. default: () => [],
  126. },
  127. filled: {
  128. type: Boolean,
  129. default: false,
  130. },
  131. },
  132. })
  133. </script>