docs/.vitepress/theme/components/extrepo/SiteCell.vue
110 lines · 2553 bytes
1<script setup lang="ts">
2import { langFlagClass, ratingIcon, ratingTitle } from './helpers'
3import type { RepoSite } from './types'
4
5defineProps<{
6 site: RepoSite & { repoName?: string }
7}>()
8</script>
9
10<template>
11 <component
12 :is="site.url ? 'a' : 'div'"
13 class="ext-site-cell"
14 :class="{ 'ext-site-cell-static': !site.url }"
15 :href="site.url || undefined"
16 :target="site.url ? '_blank' : undefined"
17 :rel="site.url ? 'noopener noreferrer' : undefined"
18 >
19 <div class="ext-site-row">
20 <img v-if="site.icon" class="ext-site-icon" :src="site.icon" :alt="site.name" loading="lazy" />
21 <span v-else class="ext-site-icon ext-site-icon-fallback i-lucide:globe" />
22 <span class="ext-site-name-text">{{ site.name }}</span>
23 <span v-if="site.rating !== 'safe'" class="ext-site-nsfw" :class="ratingIcon(site.rating)" :title="ratingTitle(site.rating)" />
24 <span class="ext-site-lang" :class="langFlagClass(site.lang)" :title="site.lang" />
25 </div>
26 <span v-if="site.repoName" class="ext-site-repo">{{ site.repoName }}</span>
27 </component>
28</template>
29
30<style scoped>
31.ext-site-repo {
32 display: block;
33 padding-left: 24px;
34 font-size: 10.5px;
35 font-weight: 400;
36 line-height: 1.1;
37 color: var(--vp-c-text-2);
38 white-space: nowrap;
39 overflow: hidden;
40 text-overflow: ellipsis;
41}
42
43.ext-site-cell {
44 display: flex;
45 flex-direction: column;
46 gap: 0;
47 padding: 6px 8px;
48 border-radius: 6px;
49 border: 1px solid var(--vp-c-divider);
50 background-color: var(--vp-c-bg-soft);
51 min-width: 0;
52 color: var(--vp-c-text-1) !important;
53 text-decoration: none !important;
54 transition: border-color 0.2s, background-color 0.2s;
55}
56
57.ext-site-row {
58 display: flex;
59 align-items: center;
60 gap: 6px;
61 min-width: 0;
62}
63
64.ext-site-cell:hover {
65 border-color: var(--vp-c-brand-1);
66 background-color: var(--vp-c-bg);
67}
68
69.ext-site-cell-static {
70 cursor: default;
71}
72
73.ext-site-cell-static:hover {
74 border-color: var(--vp-c-divider);
75 background-color: var(--vp-c-bg-soft);
76}
77
78.ext-site-icon {
79 width: 18px;
80 height: 18px;
81 border-radius: 4px;
82 flex-shrink: 0;
83 object-fit: contain;
84}
85
86.ext-site-icon-fallback {
87 display: flex;
88 align-items: center;
89 justify-content: center;
90 color: var(--vp-c-text-3);
91}
92
93.ext-site-name-text {
94 flex: 1;
95 min-width: 0;
96 font-size: 12.5px;
97 font-weight: 600;
98 line-height: 1.2;
99 color: var(--vp-c-text-1);
100 white-space: nowrap;
101 overflow: hidden;
102 text-overflow: ellipsis;
103}
104
105.ext-site-nsfw,
106.ext-site-lang {
107 flex-shrink: 0;
108 font-size: 12px;
109}
110</style>