Secondary.vue 2.5 KB

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