Commit f93d8411b5
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/extrepo/ExtensionRepos.vue +25
| @@ -7,6 +7,9 @@ import RepoRow from './RepoRow.vue' | |||
| 7 | import SettingsMenu from './SettingsMenu.vue' | 7 | import SettingsMenu from './SettingsMenu.vue' |
| 8 | import SiteGrid from './SiteGrid.vue' | 8 | import SiteGrid from './SiteGrid.vue' |
| 9 | import type { MatchedSite, RatingFilter, Repo } from './types' | 9 | import type { MatchedSite, RatingFilter, Repo } from './types' |
| 10 | import { provideTooltip } from './useTooltip' | ||
| 11 | |||
| 12 | const { tooltip } = provideTooltip() | ||
| 10 | 13 | ||
| 11 | const repoData = data.sites | 14 | const repoData = data.sites |
| 12 | const soraAuthors = data.soraAuthors | 15 | const soraAuthors = data.soraAuthors |
| @@ -138,6 +141,14 @@ const filteredSites = computed(() => { | |||
| 138 | <RepoRow v-for="repo in resolvedRepos" :key="repo.indexUrl" :repo="repo" :scheme="scheme" :show-broken="showBroken" /> | 141 | <RepoRow v-for="repo in resolvedRepos" :key="repo.indexUrl" :repo="repo" :scheme="scheme" :show-broken="showBroken" /> |
| 139 | </div> | 142 | </div> |
| 140 | </div> | 143 | </div> |
| 144 | |||
| 145 | <Teleport to="body"> | ||
| 146 | <div | ||
| 147 | v-if="tooltip" | ||
| 148 | class="ext-fixed-tooltip" | ||
| 149 | :style="{ left: tooltip.x + 'px', top: tooltip.y + 'px' }" | ||
| 150 | >{{ tooltip.text }}</div> | ||
| 151 | </Teleport> | ||
| 141 | </template> | 152 | </template> |
| 142 | 153 | ||
| 143 | <style scoped> | 154 | <style scoped> |
| @@ -179,4 +190,18 @@ const filteredSites = computed(() => { | |||
| 179 | color: var(--vp-c-text-1); | 190 | color: var(--vp-c-text-1); |
| 180 | font-size: 13px; | 191 | font-size: 13px; |
| 181 | } | 192 | } |
| 193 | |||
| 194 | .ext-fixed-tooltip { | ||
| 195 | position: fixed; | ||
| 196 | z-index: 9999; | ||
| 197 | transform: translate(-50%, calc(-100% - 15px)); | ||
| 198 | background: var(--vp-c-bg-soft); | ||
| 199 | color: var(--vp-c-text-1); | ||
| 200 | border: 1px solid var(--vp-c-brand-1); | ||
| 201 | border-radius: 5px; | ||
| 202 | padding: 3px 8px; | ||
| 203 | font-size: 11px; | ||
| 204 | white-space: nowrap; | ||
| 205 | pointer-events: none; | ||
| 206 | } | ||
| 182 | </style> | 207 | </style> |
docs/.vitepress/theme/components/extrepo/RepoRow.vue +5 −2
| @@ -5,6 +5,9 @@ import { stripHtml } from './helpers' | |||
| 5 | import { copyValue, hasCopyButton, installHref, isBrowseOnly, mangayomiCopyValue, mangayomiHref, mangayomiLiveContainerHref } from './install' | 5 | import { copyValue, hasCopyButton, installHref, isBrowseOnly, mangayomiCopyValue, mangayomiHref, mangayomiLiveContainerHref } from './install' |
| 6 | import SiteGrid from './SiteGrid.vue' | 6 | import SiteGrid from './SiteGrid.vue' |
| 7 | import type { Repo, RepoVariant } from './types' | 7 | import type { Repo, RepoVariant } from './types' |
| 8 | import { useTooltip } from './useTooltip' | ||
| 9 | |||
| 10 | const { show: showTooltip, hide: hideTooltip } = useTooltip() | ||
| 8 | 11 | ||
| 9 | const repoData = data.sites | 12 | const repoData = data.sites |
| 10 | 13 | ||
| @@ -90,7 +93,7 @@ function variantSites(variant: RepoVariant) { | |||
| 90 | <span class="i-lucide:download" /> | 93 | <span class="i-lucide:download" /> |
| 91 | <span class="ext-btn-install-label">Install</span> | 94 | <span class="ext-btn-install-label">Install</span> |
| 92 | </a> | 95 | </a> |
| 93 | <a class="ext-btn ext-btn-livecontainer" :href="mangayomiLiveContainerHref(repo, headerVariant)" title="Install via LiveContainer (iOS)"> | 96 | <a class="ext-btn ext-btn-livecontainer" :href="mangayomiLiveContainerHref(repo, headerVariant)" aria-label="Install via LiveContainer (iOS)" @mouseenter="showTooltip($event, 'Install via LiveContainer (iOS)')" @mouseleave="hideTooltip"> |
| 94 | <span class="i-mdi:apple" /> | 97 | <span class="i-mdi:apple" /> |
| 95 | </a> | 98 | </a> |
| 96 | <button | 99 | <button |
| @@ -145,7 +148,7 @@ function variantSites(variant: RepoVariant) { | |||
| 145 | <span class="i-lucide:download" /> | 148 | <span class="i-lucide:download" /> |
| 146 | <span class="ext-btn-install-label">Install</span> | 149 | <span class="ext-btn-install-label">Install</span> |
| 147 | </a> | 150 | </a> |
| 148 | <a class="ext-btn ext-btn-livecontainer" :href="mangayomiLiveContainerHref(repo, variant)" title="Install via LiveContainer (iOS)"> | 151 | <a class="ext-btn ext-btn-livecontainer" :href="mangayomiLiveContainerHref(repo, variant)" aria-label="Install via LiveContainer (iOS)" @mouseenter="showTooltip($event, 'Install via LiveContainer (iOS)')" @mouseleave="hideTooltip"> |
| 149 | <span class="i-mdi:apple" /> | 152 | <span class="i-mdi:apple" /> |
| 150 | </a> | 153 | </a> |
| 151 | <button | 154 | <button |
docs/.vitepress/theme/components/extrepo/SiteCell.vue +13 −5
| @@ -4,6 +4,9 @@ import { langFlagClass, ratingIcon, ratingTitle } from './helpers' | |||
| 4 | import { hasCopyButton } from './install' | 4 | import { hasCopyButton } from './install' |
| 5 | import LazyIcon from './LazyIcon.vue' | 5 | import LazyIcon from './LazyIcon.vue' |
| 6 | import type { RepoSite } from './types' | 6 | import type { RepoSite } from './types' |
| 7 | import { useTooltip } from './useTooltip' | ||
| 8 | |||
| 9 | const { show: showTooltip, hide: hideTooltip } = useTooltip() | ||
| 7 | 10 | ||
| 8 | const props = defineProps<{ | 11 | const props = defineProps<{ |
| 9 | site: RepoSite & { repoName?: string } | 12 | site: RepoSite & { repoName?: string } |
| @@ -34,16 +37,16 @@ async function copyInstallUrl() { | |||
| 34 | > | 37 | > |
| 35 | <div class="ext-site-row"> | 38 | <div class="ext-site-row"> |
| 36 | <LazyIcon class="ext-site-icon" :src="site.icon" :alt="site.name" /> | 39 | <LazyIcon class="ext-site-icon" :src="site.icon" :alt="site.name" /> |
| 37 | <span class="ext-site-name-text" :title="site.name">{{ site.name }}</span> | 40 | <span class="ext-site-name-text" :aria-label="site.name" @mouseenter="showTooltip($event, site.name)" @mouseleave="hideTooltip"><span class="ext-site-name-inner">{{ site.name }}</span></span> |
| 38 | <span v-if="site.rating !== 'safe'" class="ext-site-nsfw" :class="ratingIcon(site.rating)" :title="ratingTitle(site.rating)" /> | 41 | <span v-if="site.rating !== 'safe'" class="ext-site-nsfw" :class="ratingIcon(site.rating)" :aria-label="ratingTitle(site.rating)" @mouseenter="showTooltip($event, ratingTitle(site.rating))" @mouseleave="hideTooltip" /> |
| 39 | <span class="ext-site-lang" :class="langFlagClass(site.lang)" :title="site.lang" /> | 42 | <span class="ext-site-lang" :class="langFlagClass(site.lang)" :aria-label="site.lang" @mouseenter="showTooltip($event, site.lang)" @mouseleave="hideTooltip" /> |
| 40 | </div> | 43 | </div> |
| 41 | <span v-if="site.repoName" class="ext-site-repo">{{ site.repoName }}</span> | 44 | <span v-if="site.repoName" class="ext-site-repo">{{ site.repoName }}</span> |
| 42 | </component> | 45 | </component> |
| 43 | <a v-if="site.installUrl" class="ext-site-install-btn" :href="site.installUrl" :title="`Install ${site.name}`"> | 46 | <a v-if="site.installUrl" class="ext-site-install-btn" :href="site.installUrl" :aria-label="`Install ${site.name}`" @mouseenter="showTooltip($event, `Install ${site.name}`)" @mouseleave="hideTooltip"> |
| 44 | <span class="i-lucide:download" /> | 47 | <span class="i-lucide:download" /> |
| 45 | </a> | 48 | </a> |
| 46 | <button v-if="site.installUrl && hasCopyButton(scheme ?? '')" class="ext-site-copy-btn" type="button" :title="`Copy ${site.name} url`" @click="copyInstallUrl"> | 49 | <button v-if="site.installUrl && hasCopyButton(scheme ?? '')" class="ext-site-copy-btn" type="button" :aria-label="`Copy ${site.name} url`" @mouseenter="showTooltip($event, `Copy ${site.name} url`)" @mouseleave="hideTooltip" @click="copyInstallUrl"> |
| 47 | <span v-if="copied" class="i-lucide:check" /> | 50 | <span v-if="copied" class="i-lucide:check" /> |
| 48 | <span v-else class="i-lucide:copy" /> | 51 | <span v-else class="i-lucide:copy" /> |
| 49 | </button> | 52 | </button> |
| @@ -126,8 +129,13 @@ async function copyInstallUrl() { | |||
| 126 | } | 129 | } |
| 127 | 130 | ||
| 128 | .ext-site-name-text { | 131 | .ext-site-name-text { |
| 132 | display: block; | ||
| 129 | flex: 1; | 133 | flex: 1; |
| 130 | min-width: 0; | 134 | min-width: 0; |
| 135 | } | ||
| 136 | |||
| 137 | .ext-site-name-inner { | ||
| 138 | display: block; | ||
| 131 | font-size: 12.5px; | 139 | font-size: 12.5px; |
| 132 | font-weight: 600; | 140 | font-weight: 600; |
| 133 | line-height: 1.2; | 141 | line-height: 1.2; |
docs/.vitepress/theme/components/extrepo/SiteGroupCell.vue +23 −3
| @@ -3,6 +3,9 @@ import { computed } from 'vue' | |||
| 3 | import { langLabel, ratingIcon, ratingTitle } from './helpers' | 3 | import { langLabel, ratingIcon, ratingTitle } from './helpers' |
| 4 | import LazyIcon from './LazyIcon.vue' | 4 | import LazyIcon from './LazyIcon.vue' |
| 5 | import type { RepoSite } from './types' | 5 | import type { RepoSite } from './types' |
| 6 | import { useTooltip } from './useTooltip' | ||
| 7 | |||
| 8 | const { show: showTooltip, hide: hideTooltip } = useTooltip() | ||
| 6 | 9 | ||
| 7 | const props = defineProps<{ | 10 | const props = defineProps<{ |
| 8 | sites: (RepoSite & { repoName?: string })[] | 11 | sites: (RepoSite & { repoName?: string })[] |
| @@ -45,14 +48,26 @@ const groupName = computed(() => { | |||
| 45 | > | 48 | > |
| 46 | <div class="ext-site-row"> | 49 | <div class="ext-site-row"> |
| 47 | <LazyIcon class="ext-site-icon" :src="primary.icon" :alt="primary.name" /> | 50 | <LazyIcon class="ext-site-icon" :src="primary.icon" :alt="primary.name" /> |
| 48 | <span class="ext-site-name-text" :title="groupName">{{ groupName }}</span> | 51 | <span |
| 52 | class="ext-site-name-text" | ||
| 53 | :aria-label="groupName" | ||
| 54 | @mouseenter="showTooltip($event, groupName)" | ||
| 55 | @mouseleave="hideTooltip" | ||
| 56 | ><span class="ext-site-name-inner">{{ groupName }}</span></span> | ||
| 49 | <span | 57 | <span |
| 50 | v-if="highestRated" | 58 | v-if="highestRated" |
| 51 | class="ext-site-nsfw" | 59 | class="ext-site-nsfw" |
| 52 | :class="ratingIcon(highestRated.rating)" | 60 | :class="ratingIcon(highestRated.rating)" |
| 53 | :title="ratingTitle(highestRated.rating)" | 61 | :aria-label="ratingTitle(highestRated.rating)" |
| 62 | @mouseenter="showTooltip($event, ratingTitle(highestRated.rating))" | ||
| 63 | @mouseleave="hideTooltip" | ||
| 64 | /> | ||
| 65 | <span | ||
| 66 | class="ext-site-layers i-lucide:layers" | ||
| 67 | :aria-label="`${sites.length} versions available`" | ||
| 68 | @mouseenter="showTooltip($event, `${sites.length} versions available`)" | ||
| 69 | @mouseleave="hideTooltip" | ||
| 54 | /> | 70 | /> |
| 55 | <span class="ext-site-layers i-lucide:layers" :title="`${sites.length} versions available`" /> | ||
| 56 | </div> | 71 | </div> |
| 57 | <span v-if="primary.repoName" class="ext-site-repo">{{ primary.repoName }}</span> | 72 | <span v-if="primary.repoName" class="ext-site-repo">{{ primary.repoName }}</span> |
| 58 | </button> | 73 | </button> |
| @@ -113,8 +128,13 @@ const groupName = computed(() => { | |||
| 113 | } | 128 | } |
| 114 | 129 | ||
| 115 | .ext-site-name-text { | 130 | .ext-site-name-text { |
| 131 | display: block; | ||
| 116 | flex: 1; | 132 | flex: 1; |
| 117 | min-width: 0; | 133 | min-width: 0; |
| 134 | } | ||
| 135 | |||
| 136 | .ext-site-name-inner { | ||
| 137 | display: block; | ||
| 118 | font-size: 12.5px; | 138 | font-size: 12.5px; |
| 119 | font-weight: 600; | 139 | font-weight: 600; |
| 120 | line-height: 1.2; | 140 | line-height: 1.2; |
docs/.vitepress/theme/components/extrepo/useTooltip.ts added +38
| @@ -0,0 +1,38 @@ | |||
| 1 | import { inject, provide, ref, type InjectionKey } from 'vue' | ||
| 2 | |||
| 3 | interface TooltipState { | ||
| 4 | text: string | ||
| 5 | x: number | ||
| 6 | y: number | ||
| 7 | } | ||
| 8 | |||
| 9 | interface TooltipCtx { | ||
| 10 | show: (e: MouseEvent, text: string) => void | ||
| 11 | hide: () => void | ||
| 12 | } | ||
| 13 | |||
| 14 | const KEY: InjectionKey<TooltipCtx> = Symbol('ext-tooltip') | ||
| 15 | |||
| 16 | export function provideTooltip() { | ||
| 17 | const tooltip = ref<TooltipState | null>(null) | ||
| 18 | |||
| 19 | function show(e: MouseEvent, text: string) { | ||
| 20 | if (typeof window === 'undefined' || !window.matchMedia('(hover: hover)').matches) return | ||
| 21 | const rect = (e.currentTarget as HTMLElement).getBoundingClientRect() | ||
| 22 | tooltip.value = { text, x: rect.left + rect.width / 2, y: rect.top } | ||
| 23 | } | ||
| 24 | |||
| 25 | function hide() { | ||
| 26 | tooltip.value = null | ||
| 27 | } | ||
| 28 | |||
| 29 | provide(KEY, { show, hide }) | ||
| 30 | |||
| 31 | return { tooltip } | ||
| 32 | } | ||
| 33 | |||
| 34 | export function useTooltip(): TooltipCtx { | ||
| 35 | const ctx = inject(KEY) | ||
| 36 | if (!ctx) throw new Error('useTooltip() must be called within a component tree wrapped by provideTooltip()') | ||
| 37 | return ctx | ||
| 38 | } | ||