LinkButton.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <a
  3. :class="[
  4. 'flex',
  5. 'justify-center',
  6. 'items-center',
  7. 'rounded-6px',
  8. primary ? 'link-primary' : 'link',
  9. disabled && 'cursor-not-allowed',
  10. underline && !disabled && 'underline',
  11. type === 'plain' && 'lg:hover:bg-[#548CF9] <lg:active:bg-[#548CF9]',
  12. type === 'border' && 'lg:hover:bg-brand-0 lg:hover:text-white <lg:active:bg-brand-0 <lg:active:text-white',
  13. type === 'borderBgWhite' && 'lg:hover:border-1px lg:hover:border-solid lg:hover:border-[#397DFF] lg:hover:text-brand-0 <lg:active:border-1px <lg:active:border-solid <lg:active:border-[#397DFF] <lg:active:text-brand-0',
  14. type === 'bgWhite' && 'bg-white lg:hover:bg-white/80 <lg:active:bg-white/80',
  15. type === 'borderWhite' && 'border border-white text-white lg:hover:bg-white lg:hover:text-brand-0 <lg:active:bg-white <lg:active:text-brand-0'
  16. ]"
  17. :href="disabled ? null : href"
  18. >
  19. <template v-if="$slots.icon"><slot v-if="$slots.icon" name="icon" /></template>
  20. <span
  21. v-if="$slots.default"
  22. :class="[
  23. 'block',
  24. bold && 'lg:font-bold'
  25. ]"
  26. >
  27. <slot />
  28. </span>
  29. <slot name="dynamic"></slot>
  30. </a>
  31. </template>
  32. <script>
  33. export default {
  34. props: {
  35. type: {
  36. type: String,
  37. default: 'default'
  38. },
  39. primary: {
  40. type: Boolean,
  41. default: false
  42. },
  43. underline: {
  44. type: Boolean,
  45. default: false
  46. },
  47. bold: {
  48. type: Boolean,
  49. default: false
  50. },
  51. disabled: Boolean,
  52. href: String
  53. }
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .link-primary {
  58. width: 100%;
  59. max-width: 138px;
  60. height: 42px;
  61. }
  62. .link {
  63. width: 100%;
  64. height: 54px;
  65. }
  66. .dynamic {
  67. span {
  68. font-weight: bold;
  69. }
  70. .dynamic-icon {
  71. position: relative;
  72. width: 16px;
  73. height: 16px;
  74. margin-left: 8px;
  75. &::after,
  76. &::before {
  77. position: absolute;
  78. transition: all 0.25s ease-out;
  79. box-sizing: border-box;
  80. border-top: 2px solid #FFFFFF;
  81. }
  82. &::before {
  83. content: '';
  84. width: 8px;
  85. height: 8px;
  86. border-left: 2px solid #FFFFFF;
  87. right: 1px;
  88. top: 50%;
  89. transform: translateY(-50%) rotate(135deg);
  90. }
  91. &::after {
  92. content: '';
  93. width: 11px;
  94. height: 2px;
  95. left: -1px;
  96. top: 50%;
  97. transform: translateY(-50%) rotate(-65deg);
  98. }
  99. }
  100. &:hover {
  101. .dynamic-icon {
  102. &::after {
  103. transform: translateY(-50%);
  104. left: 3px;
  105. }
  106. }
  107. }
  108. }
  109. .dynamic-text .dynamic-icon {
  110. &::before, &::after {
  111. border-color: #1460F3;
  112. }
  113. }
  114. </style>