item.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <a class="card-item" :href="href" :target="target" rel="noopener noreferrer">
  3. <div class="icon-group" :class="{ 'has-fill': !icon }">
  4. <img v-if="icon" :src="withBase(icon)" :alt="title">
  5. <span v-else>{{fill}}</span>
  6. </div>
  7. <div class="info-group">
  8. <strong>{{title}}</strong>
  9. <br>
  10. <p>{{desc}}</p>
  11. </div>
  12. </a>
  13. </template>
  14. <script setup>
  15. import { withBase } from 'vitepress';
  16. defineProps({
  17. href: {
  18. type: String,
  19. default: '#'
  20. },
  21. target: {
  22. type: String,
  23. default: '_blank'
  24. },
  25. icon: {
  26. type: String,
  27. default: ''
  28. },
  29. fill: {
  30. type: String,
  31. default: ''
  32. },
  33. title: {
  34. type: String,
  35. default: ''
  36. },
  37. desc: {
  38. type: String,
  39. default: ''
  40. }
  41. })
  42. </script>
  43. <style scoped lang="scss">
  44. .card-item {
  45. color: var(--vp-c-indigo);
  46. margin: 4px;
  47. cursor: pointer;
  48. width: 16em;
  49. height: 120px;
  50. vertical-align: middle;
  51. overflow: hidden;
  52. display: inline-flex;
  53. flex-direction: row;
  54. border-radius: 8px;
  55. box-shadow: 0 8px 16px -4px #2c2d300c;
  56. background: var(--vp-c-indigo-lighter);
  57. padding: 8px 12px 8px 8px;
  58. &:hover {
  59. background: var(--vp-c-indigo-light);
  60. .icon-group {
  61. width: 0;
  62. opacity: 0;
  63. }
  64. .info-group {
  65. color: var(--vp-c-gray-dark-1);
  66. }
  67. }
  68. .info-group {
  69. strong {
  70. font-size: 20px;
  71. }
  72. p {
  73. opacity: 0.66;
  74. }
  75. }
  76. .icon-group {
  77. flex-shrink: 0;
  78. display: flex;
  79. align-items: center;
  80. justify-content: center;
  81. width: 60px;
  82. height: 60px;
  83. transition: all 0.3s;
  84. margin-right: 12px;
  85. &.has-fill {
  86. background: rgba(41, 190, 209, 0.22);
  87. border: 1px solid rgb(225, 225, 225);
  88. border-radius: 12px;
  89. }
  90. img {
  91. max-width: 100%;
  92. max-height: 100%;
  93. width: 40px;
  94. object-fit: contain;
  95. }
  96. }
  97. }
  98. </style>