Secondary.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 setup lang="ts">
  69. interface Props {
  70. to: string
  71. exact: boolean
  72. blank: boolean
  73. label: string
  74. icon: string
  75. svg: string
  76. color: string
  77. disabled: boolean
  78. loading: boolean
  79. reverse: boolean
  80. rounded: boolean
  81. large: boolean
  82. outline: boolean
  83. shortcut: string[]
  84. filled: boolean
  85. }
  86. withDefaults(defineProps<Props>(), {
  87. to: "",
  88. exact: true,
  89. blank: false,
  90. label: "",
  91. icon: "",
  92. svg: "",
  93. color: "",
  94. disabled: false,
  95. loading: false,
  96. reverse: false,
  97. rounded: false,
  98. large: false,
  99. outline: false,
  100. shortcut: () => [],
  101. filled: false,
  102. })
  103. </script>