Primary.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-bold transition focus:outline-none focus-visible:bg-accentDark"
  7. :class="[
  8. color
  9. ? `text-${color}-800 bg-${color}-200 hover:(text-${color}-900 bg-${color}-300) focus-visible:(text-${color}-900 bg-${color}-300)`
  10. : `text-accentContrast bg-accent hover:bg-accentDark focus-visible:bg-accentDark`,
  11. label ? 'px-4' : 'px-2',
  12. rounded ? 'rounded-full' : 'rounded',
  13. { 'opacity-75 cursor-not-allowed': disabled },
  14. { 'pointer-events-none': loading },
  15. { 'px-6 py-4 text-lg': large },
  16. { 'shadow-lg hover:shadow-xl': shadow },
  17. {
  18. 'text-white bg-gradient-to-tr from-gradientFrom via-gradientVia to-gradientTo':
  19. gradient,
  20. },
  21. {
  22. 'border border-accent hover:border-accentDark focus-visible:border-accentDark':
  23. outline,
  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 !bg-accentLight"
  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. large: boolean
  80. shadow: boolean
  81. reverse: boolean
  82. rounded: boolean
  83. gradient: boolean
  84. outline: boolean
  85. shortcut: string[]
  86. }
  87. withDefaults(defineProps<Props>(), {
  88. to: "",
  89. exact: true,
  90. blank: false,
  91. label: "",
  92. icon: "",
  93. svg: "",
  94. color: "",
  95. disabled: false,
  96. loading: false,
  97. large: false,
  98. shadow: false,
  99. reverse: false,
  100. rounded: false,
  101. gradient: false,
  102. outline: false,
  103. shortcut: () => [],
  104. })
  105. </script>