Primary.vue 3.2 KB

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