Primary.vue 3.1 KB

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