Secondary.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <SmartLink
  3. :to="`${/^\/(?!\/).*$/.test(to) ? localePath(to) : to}`"
  4. :exact="exact"
  5. :blank="blank"
  6. class="font-semibold py-2 transition inline-flex items-center justify-center whitespace-nowrap focus:outline-none"
  7. :class="[
  8. color
  9. ? `text-${color}-500 hover:text-${color}-600 focus-visible:text-${color}-600`
  10. : 'text-secondary hover:text-secondaryDark focus-visible:text-secondaryDark',
  11. label ? 'rounded px-4' : 'px-2',
  12. { 'rounded-full': rounded },
  13. { 'opacity-75 cursor-not-allowed': disabled },
  14. { 'flex-row-reverse': reverse },
  15. { 'px-6 py-4 text-lg': large },
  16. {
  17. 'border border-divider hover:border-dividerDark focus-visible:border-dividerDark':
  18. outline,
  19. },
  20. {
  21. 'bg-primaryLight hover:bg-primaryDark focus-visible:bg-primaryDark':
  22. filled,
  23. },
  24. ]"
  25. :disabled="disabled"
  26. >
  27. <i
  28. v-if="icon"
  29. class="material-icons"
  30. :class="[
  31. { '!text-2xl': large },
  32. label ? (reverse ? 'ml-2' : 'mr-2') : '',
  33. ]"
  34. >
  35. {{ icon }}
  36. </i>
  37. <SmartIcon
  38. v-if="svg"
  39. :name="svg"
  40. class="svg-icons"
  41. :class="[
  42. { '!h-6 !w-6': large },
  43. label ? (reverse ? 'ml-2' : 'mr-2') : '',
  44. ]"
  45. />
  46. {{ label }}
  47. <div v-if="shortcut.length" class="ml-2">
  48. <kbd
  49. v-for="(key, index) in shortcut"
  50. :key="`key-${index}`"
  51. class="bg-dividerLight rounded text-secondaryLight ml-1 px-1 inline-flex"
  52. >
  53. {{ key }}
  54. </kbd>
  55. </div>
  56. </SmartLink>
  57. </template>
  58. <script lang="ts">
  59. import { defineComponent } from "@nuxtjs/composition-api"
  60. export default defineComponent({
  61. props: {
  62. to: {
  63. type: String,
  64. default: "",
  65. },
  66. exact: {
  67. type: Boolean,
  68. default: true,
  69. },
  70. blank: {
  71. type: Boolean,
  72. default: false,
  73. },
  74. label: {
  75. type: String,
  76. default: "",
  77. },
  78. icon: {
  79. type: String,
  80. default: "",
  81. },
  82. svg: {
  83. type: String,
  84. default: "",
  85. },
  86. color: {
  87. type: String,
  88. default: "",
  89. },
  90. disabled: {
  91. type: Boolean,
  92. default: false,
  93. },
  94. reverse: {
  95. type: Boolean,
  96. default: false,
  97. },
  98. rounded: {
  99. type: Boolean,
  100. default: false,
  101. },
  102. large: {
  103. type: Boolean,
  104. default: false,
  105. },
  106. outline: {
  107. type: Boolean,
  108. default: false,
  109. },
  110. shortcut: {
  111. type: Array,
  112. default: () => [],
  113. },
  114. filled: {
  115. type: Boolean,
  116. default: false,
  117. },
  118. },
  119. })
  120. </script>