|
| 1 | +<script setup> |
| 2 | +const props = defineProps({ |
| 3 | + title: { type: String, required: true }, |
| 4 | + href: { type: String, required: true }, |
| 5 | + text: { type: String, default: '' }, |
| 6 | + src: { type: String, default: '' }, |
| 7 | +}) |
| 8 | +
|
| 9 | +const isExternal = /^https?:\/\//.test(props.href) |
| 10 | +</script> |
| 11 | + |
| 12 | +<template> |
| 13 | + <a |
| 14 | + class="link-card no-icon" |
| 15 | + :href="props.href" |
| 16 | + :target="isExternal ? '_blank' : null" |
| 17 | + :rel="isExternal ? 'noopener noreferrer' : null" |
| 18 | + > |
| 19 | + <div class="link-card-content"> |
| 20 | + <img class="link-card-logo" v-if="props.src" :src="props.src" :alt="props.title" /> |
| 21 | + <div class="link-card-text"> |
| 22 | + <div class="link-card-title">{{ title }}</div> |
| 23 | + <div class="link-card-desc">{{ text || href }}</div> |
| 24 | + </div> |
| 25 | + </div> |
| 26 | + </a> |
| 27 | +</template> |
| 28 | + |
| 29 | +<style scoped> |
| 30 | +.link-card { |
| 31 | + display: block; |
| 32 | + background-color: var(--vp-c-bg-soft); |
| 33 | + border-radius: 12px; |
| 34 | + padding: 1em; |
| 35 | + margin-top: 20px; |
| 36 | + margin-bottom: 1em; |
| 37 | + text-decoration: none; |
| 38 | + border: 2px solid transparent; |
| 39 | + transition: border-color 0.25s ease; |
| 40 | + color: inherit; |
| 41 | +} |
| 42 | +
|
| 43 | +.link-card:hover { |
| 44 | + border-color: var(--vp-c-brand-1); |
| 45 | +} |
| 46 | +
|
| 47 | +.link-card-content { |
| 48 | + display: flex; |
| 49 | + align-items: center; |
| 50 | + gap: 1em; |
| 51 | +} |
| 52 | +
|
| 53 | +.link-card-logo { |
| 54 | + color: var(--vp-c-text-1); |
| 55 | + width: 3em; |
| 56 | + height: 3em; |
| 57 | + flex-shrink: 0; |
| 58 | + border-radius: 10px; |
| 59 | +} |
| 60 | +
|
| 61 | +.link-card-text { |
| 62 | + flex: 1; |
| 63 | + min-width: 0; |
| 64 | +} |
| 65 | +
|
| 66 | +.link-card-title { |
| 67 | + color: var(--vp-c-text-1); |
| 68 | + font-weight: bold; |
| 69 | + font-size: 1em; |
| 70 | + white-space: nowrap; |
| 71 | + overflow: hidden; |
| 72 | + text-overflow: ellipsis; |
| 73 | +} |
| 74 | +
|
| 75 | +.link-card-desc { |
| 76 | + color: var(--vp-c-text-2); |
| 77 | + font-size: 0.9em; |
| 78 | + white-space: nowrap; |
| 79 | + overflow: hidden; |
| 80 | + text-overflow: ellipsis; |
| 81 | +} |
| 82 | +
|
| 83 | +@media (max-width: 639px) { |
| 84 | + .link-card-title { |
| 85 | + font-size: 0.95em; |
| 86 | + } |
| 87 | +
|
| 88 | + .link-card-desc { |
| 89 | + font-size: 0.85em; |
| 90 | + max-width: 90%; |
| 91 | + } |
| 92 | +
|
| 93 | + .link-card { |
| 94 | + padding: 0.75em; |
| 95 | + } |
| 96 | +
|
| 97 | + .link-card-logo { |
| 98 | + width: 2.5em; |
| 99 | + height: 2.5em; |
| 100 | + } |
| 101 | +} |
| 102 | +</style> |
0 commit comments