Primary.vue 3.2 KB

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