Commit 0adefbb165

0adefbb16515c2894412a024b6117730e1b8dc7d

parent: e68ad60085

Unsigned

TubaApollo <86665265+TubaApollo@users.noreply.github.com> · 2026-04-12 14:00 UTC

feat: add ScrapeTable component with drag-scroll and scroll indicator

Layout: unified · split

docs/.vitepress/theme/components/ScrapeTable.vue added +163
@@ -0,0 +1,163 @@
1<script setup lang="ts">
2import { useEventListener } from '@vueuse/core'
3import { computed, ref, onMounted } from 'vue'
4
5interface Site {
6 name: string
7 scrapes: Record<string, string>
8}
9
10const props = defineProps<{
11 sites: Site[]
12}>()
13
14// Normalize source names (case-insensitive dedup, keep first-seen casing)
15const normalizedSites = computed(() => {
16 const canonical: Record<string, string> = {}
17 for (const site of props.sites) {
18 for (const source of Object.keys(site.scrapes)) {
19 const key = source.toLowerCase()
20 if (!canonical[key]) canonical[key] = source
21 }
22 }
23 return props.sites.map(site => {
24 const scrapes: Record<string, string> = {}
25 for (const [source, player] of Object.entries(site.scrapes)) {
26 scrapes[canonical[source.toLowerCase()]] = player
27 }
28 return { name: site.name, scrapes }
29 })
30})
31
32const sources = computed(() => {
33 const count: Record<string, number> = {}
34 for (const site of normalizedSites.value) {
35 for (const source of Object.keys(site.scrapes)) {
36 count[source] = (count[source] || 0) + 1
37 }
38 }
39 return Object.keys(count).sort((a, b) => count[b] - count[a])
40})
41
42// Drag to scroll + scroll indicator
43const wrapRef = ref<HTMLElement | null>(null)
44const canScrollRight = ref(false)
45let isDragging = false
46let startX = 0
47let scrollStart = 0
48
49const SCROLL_END_PX = 2
50
51function checkScroll() {
52 const el = wrapRef.value
53 if (!el) return
54 canScrollRight.value = el.scrollLeft + el.clientWidth < el.scrollWidth - SCROLL_END_PX
55}
56
57function onPointerDown(e: PointerEvent) {
58 const el = wrapRef.value
59 if (!el) return
60 isDragging = true
61 startX = e.clientX
62 scrollStart = el.scrollLeft
63 el.setPointerCapture(e.pointerId)
64 el.style.cursor = 'grabbing'
65}
66
67function onPointerMove(e: PointerEvent) {
68 if (!isDragging || !wrapRef.value) return
69 wrapRef.value.scrollLeft = scrollStart - (e.clientX - startX)
70}
71
72function onPointerUp(e: PointerEvent) {
73 isDragging = false
74 if (wrapRef.value) {
75 wrapRef.value.releasePointerCapture(e.pointerId)
76 wrapRef.value.style.cursor = ''
77 }
78}
79
80onMounted(() => {
81 checkScroll()
82 useEventListener(wrapRef, 'scroll', checkScroll, { passive: true })
83 useEventListener(window, 'resize', checkScroll, { passive: true })
84})
85</script>
86
87<template>
88 <div class="scrape-table-outer">
89 <div
90 ref="wrapRef"
91 class="scrape-table-wrap"
92 @pointerdown="onPointerDown"
93 @pointermove="onPointerMove"
94 @pointerup="onPointerUp"
95 @pointercancel="onPointerUp"
96 >
97 <table class="scrape-table">
98 <colgroup>
99 <col />
100 <col v-for="source in sources" :key="source" class="col-cell" />
101 </colgroup>
102 <thead>
103 <tr>
104 <th class="corner">Website</th>
105 <th v-for="source in sources" :key="source" class="source-header">
106 <span>{{ source }}</span>
107 </th>
108 </tr>
109 </thead>
110 <tbody>
111 <tr v-for="site in normalizedSites" :key="site.name">
112 <td class="site-name">{{ site.name }}</td>
113 <td
114 v-for="source in sources"
115 :key="source"
116 class="cell"
117 :class="{ active: source in site.scrapes }"
118 :title="site.scrapes[source] || undefined"
119 />
120 </tr>
121 </tbody>
122 </table>
123 </div>
124 <div v-if="canScrollRight" class="scroll-indicator">
125 <span class="i-lucide-chevron-right" />
126 </div>
127 </div>
128</template>
129
130<style>
131.scrape-table-outer {
132 position: relative;
133 margin: 16px 0;
134}
135
136.scrape-table-wrap {
137 overflow-x: auto;
138 max-width: 100%;
139 cursor: grab;
140 user-select: none;
141}
142
143.scroll-indicator {
144 position: absolute;
145 right: 0;
146 top: 0;
147 bottom: 0;
148 width: 40px;
149 display: flex;
150 align-items: center;
151 justify-content: center;
152 background: linear-gradient(to right, transparent, var(--vp-c-bg) 70%);
153 pointer-events: none;
154 color: var(--vp-c-text-2);
155 font-size: 20px;
156 animation: pulse-right 1.5s ease-in-out infinite;
157}
158
159@keyframes pulse-right {
160 0%, 100% { opacity: 0.5; transform: translateX(0); }
161 50% { opacity: 1; transform: translateX(4px); }
162}
163</style>
docs/.vitepress/theme/index.ts +2
@@ -19,6 +19,7 @@ import Tooltip from './components/Tooltip.vue'
19import { createMediumZoomProvider } from './composables/medium-zoom' 19import { createMediumZoomProvider } from './composables/medium-zoom'
20import 'virtual:uno.css' 20import 'virtual:uno.css'
21import Feedback from './components/Feedback.vue' 21import Feedback from './components/Feedback.vue'
22import ScrapeTable from './components/ScrapeTable.vue'
22import Layout from './Layout.vue' 23import Layout from './Layout.vue'
23import './styles/tooltip-hint.css' 24import './styles/tooltip-hint.css'
24import './styles/steps.css' 25import './styles/steps.css'
@@ -50,6 +51,7 @@ export default {
50 app.component('Authors', Authors) 51 app.component('Authors', Authors)
51 app.component('Tooltip', Tooltip) 52 app.component('Tooltip', Tooltip)
52 app.component('Feedback', Feedback) 53 app.component('Feedback', Feedback)
54 app.component('ScrapeTable', ScrapeTable)
53 createMediumZoomProvider(app, router) 55 createMediumZoomProvider(app, router)
54 app.use( 56 app.use(
55 NolebasePagePropertiesPlugin<{ tags: string[]; progress: number }>(), 57 NolebasePagePropertiesPlugin<{ tags: string[]; progress: number }>(),
docs/.vitepress/theme/styles/style.scss +121
@@ -1439,3 +1439,124 @@ table tr:nth-child(odd) {
1439 opacity: 1; 1439 opacity: 1;
1440 } 1440 }
1441} 1441}
1442
1443/* ScrapeTable */
1444:root {
1445 --scrape-cell-bg: #ebedf0;
1446 --scrape-cell-active: #56d364;
1447}
1448
1449.dark {
1450 --scrape-cell-bg: #151b23;
1451}
1452
1453/* Override VitePress .vp-doc table/tr/th/td defaults */
1454.scrape-table {
1455 display: table !important;
1456 table-layout: fixed;
1457 border-collapse: separate !important;
1458 border-spacing: 0;
1459 white-space: nowrap;
1460 width: max-content;
1461 overflow: visible !important;
1462 margin: 0 !important;
1463
1464 .col-cell { width: 34px; }
1465
1466 tr {
1467 background: transparent !important;
1468 border: none !important;
1469 }
1470
1471 th, td {
1472 background: transparent !important;
1473 padding: 0 !important;
1474 border: none !important;
1475 }
1476
1477 .corner,
1478 .source-header {
1479 border: 1px solid var(--vp-c-divider) !important;
1480 border-left: none !important;
1481 }
1482
1483 .corner {
1484 position: sticky;
1485 left: 0;
1486 z-index: 2;
1487 padding: 0 12px !important;
1488 height: 140px;
1489 background-color: var(--vp-c-bg-soft) !important;
1490 border-left: 1px solid var(--vp-c-divider) !important;
1491 color: var(--vp-c-text-2);
1492 font-weight: 600;
1493 font-size: 13px;
1494 vertical-align: middle;
1495 text-align: center;
1496 }
1497
1498 .source-header {
1499 vertical-align: bottom;
1500 height: 140px;
1501 text-align: center;
1502
1503 span {
1504 writing-mode: vertical-lr;
1505 transform: rotate(180deg);
1506 display: inline-block;
1507 font-weight: 600;
1508 color: var(--vp-c-text-1);
1509 font-size: 12px;
1510 }
1511 }
1512
1513 .site-name {
1514 position: sticky;
1515 left: 0;
1516 z-index: 1;
1517 padding: 4px 12px !important;
1518 background: var(--vp-c-bg) !important;
1519 border: 1px solid var(--vp-c-divider) !important;
1520 border-top: none !important;
1521 color: var(--vp-c-text-1);
1522 font-weight: 600;
1523 font-size: 13px;
1524 line-height: 1;
1525 }
1526
1527 .cell {
1528 border: 2px solid transparent !important;
1529 height: 34px;
1530 position: relative;
1531
1532 &::before {
1533 content: '';
1534 display: block;
1535 width: 100%;
1536 height: 100%;
1537 border-radius: 6px;
1538 background: var(--scrape-cell-bg);
1539 }
1540
1541 &.active::before {
1542 background: var(--scrape-cell-active);
1543 }
1544
1545 &.active[title]:hover::after {
1546 content: attr(title);
1547 position: absolute;
1548 bottom: calc(100% + 4px);
1549 left: 50%;
1550 transform: translateX(-50%);
1551 padding: 3px 8px;
1552 border-radius: 6px;
1553 background: var(--vp-c-bg-elv);
1554 color: var(--vp-c-text-1);
1555 font-size: 11px;
1556 white-space: nowrap;
1557 box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
1558 z-index: 10;
1559 pointer-events: none;
1560 }
1561 }
1562}
docs/websites.md +12
@@ -27,6 +27,18 @@ outline: 1
27| [KickassAnime](https://kaa.lt/) ==KAA== | :sup: | :yes: | :msync: | :cc: | 27| [KickassAnime](https://kaa.lt/) ==KAA== | :sup: | :yes: | :msync: | :cc: |
28| [AniZone](https://anizone.to/) ==AniZone== | :sup: | :no: | :no: | :cc: | 28| [AniZone](https://anizone.to/) ==AniZone== | :sup: | :no: | :no: | :cc: |
29 29
30### Scrape Sources
31
32<ScrapeTable :sites="[
33 { name: '1anime', scrapes: { 'Animekai': 'kai & kiwi', 'Anime Nexus': 'nexus', 'Animepahe': 'pahe', 'Anitaku': 'gogo', 'Anizone': 'Zone' } },
34 { name: 'Anidap', scrapes: { 'Animepahe': 'pahe', 'Anify': 'lofi', 'AniWave': 'neko', 'AnimeKai': 'ozzy', 'AniXL': 'kuro', 'AniZone': 'zone', 'HiAnime': 'yuki', 'KickassAnime': 'kami', 'Sudatchi': 'sora' } },
35 { name: 'Anikuro', scrapes: { '123anime': '', 'AniX': '', 'AllAnime': 'AllAni', 'Animepahe': 'Pahe', 'Anify': '', 'AniHQ': '', 'AnimeDunya': 'AniD', 'AnimeGG': 'AniGG', 'AnimeKai': 'Kai', 'AnimeZ': '', 'AniTaku': 'AniT', 'AniZone': 'AniZ', 'HiAnime': 'Zoro', 'KickassAnime': 'Kaa', 'Kuudere': 'AniW', 'Otaku-Streamers': 'AniS' } },
36 { name: 'AnimeRealms', scrapes: { 'AllManga': '', 'AnimePahe': '', 'AnimeZ': '', 'Hianime': '', 'Kuudere': 'ZenCloud' } },
37 { name: 'AnimeX', scrapes: { 'Animepahe': 'pahe', 'Anify': 'lofi', 'AniWave': 'neko', 'AnimeKai': 'ozzy', 'AniXL': 'kuro', 'AniZone': 'zone', 'HiAnime': 'yuki', 'KickassAnime': 'kami', 'Sudatchi': 'sora' } },
38 { name: 'Animetsu', scrapes: { 'AnimeGG': 'Meg', 'AnimePahe': 'Pahe', 'AnimeZ': 'Zaza', 'HiAnime': 'Zoro' } },
39 { name: 'Miruro', scrapes: { 'AnimeKai': 'arc', 'Animepahe': 'kiwi & telli', 'AnimeZ': 'jet', 'HiAnime': 'bee & bun', 'KickassAnime': 'hop & kuz' } }
40]" />
41
30:::details More 42:::details More
31 43
32### Self-uploaded 44### Self-uploaded