Primary.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <SmartLink
  3. :to="`${/^\/(?!\/).*$/.test(to) ? localePath(to) : to}`"
  4. :exact="exact"
  5. :blank="blank"
  6. class="font-bold py-2 transition inline-flex items-center justify-center 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. >
  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">
  56. <kbd
  57. v-for="(key, index) in shortcut"
  58. :key="`key-${index}`"
  59. class="bg-accentLight rounded ml-1 px-1 inline-flex"
  60. >
  61. {{ key }}
  62. </kbd>
  63. </div>
  64. </span>
  65. <SmartSpinner v-else />
  66. </SmartLink>
  67. </template>
  68. <script lang="ts">
  69. import { defineComponent } from "@nuxtjs/composition-api"
  70. export default defineComponent({
  71. props: {
  72. to: {
  73. type: String,
  74. default: "",
  75. },
  76. exact: {
  77. type: Boolean,
  78. default: true,
  79. },
  80. blank: {
  81. type: Boolean,
  82. default: false,
  83. },
  84. label: {
  85. type: String,
  86. default: "",
  87. },
  88. icon: {
  89. type: String,
  90. default: "",
  91. },
  92. svg: {
  93. type: String,
  94. default: "",
  95. },
  96. color: {
  97. type: String,
  98. default: "",
  99. },
  100. disabled: {
  101. type: Boolean,
  102. default: false,
  103. },
  104. loading: {
  105. type: Boolean,
  106. default: false,
  107. },
  108. large: {
  109. type: Boolean,
  110. default: false,
  111. },
  112. shadow: {
  113. type: Boolean,
  114. default: false,
  115. },
  116. reverse: {
  117. type: Boolean,
  118. default: false,
  119. },
  120. rounded: {
  121. type: Boolean,
  122. default: false,
  123. },
  124. gradient: {
  125. type: Boolean,
  126. default: false,
  127. },
  128. outline: {
  129. type: Boolean,
  130. default: false,
  131. },
  132. shortcut: {
  133. type: Array,
  134. default: () => [],
  135. },
  136. type: {
  137. type: String,
  138. default: "button",
  139. },
  140. },
  141. })
  142. </script>