Commit b13892dd57
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/ScrapeTable.vue +40 −6
| @@ -2,15 +2,46 @@ | |||
| 2 | import { useEventListener } from '@vueuse/core' | 2 | import { useEventListener } from '@vueuse/core' |
| 3 | import { computed, ref, onMounted } from 'vue' | 3 | import { computed, ref, onMounted } from 'vue' |
| 4 | 4 | ||
| 5 | interface ScrapeValueObject { | ||
| 6 | name: string | ||
| 7 | metadata?: string[] | ||
| 8 | } | ||
| 9 | |||
| 10 | type ScrapeValue = string | ScrapeValueObject | ||
| 11 | |||
| 12 | interface NormalizedScrapeValue { | ||
| 13 | name: string | ||
| 14 | metadata: string[] | ||
| 15 | } | ||
| 16 | |||
| 5 | interface Site { | 17 | interface Site { |
| 6 | name: string | 18 | name: string |
| 7 | scrapes: Record<string, string> | 19 | scrapes: Record<string, ScrapeValue> |
| 8 | } | 20 | } |
| 9 | 21 | ||
| 10 | const props = defineProps<{ | 22 | const props = defineProps<{ |
| 11 | sites: Site[] | 23 | sites: Site[] |
| 12 | }>() | 24 | }>() |
| 13 | 25 | ||
| 26 | function normalizeScrapeValue(value: ScrapeValue): NormalizedScrapeValue { | ||
| 27 | if (typeof value === 'string') { | ||
| 28 | return { name: value, metadata: [] } | ||
| 29 | } | ||
| 30 | |||
| 31 | return { | ||
| 32 | name: value.name, | ||
| 33 | metadata: value.metadata ?? [], | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | function hasMetadata(value: NormalizedScrapeValue | undefined, metadata: string) { | ||
| 38 | return value?.metadata.some(item => item.toLowerCase() === metadata.toLowerCase()) ?? false | ||
| 39 | } | ||
| 40 | |||
| 41 | function getScrapeTitle(value: NormalizedScrapeValue | undefined) { | ||
| 42 | return value?.name || undefined | ||
| 43 | } | ||
| 44 | |||
| 14 | // Normalize source names (case-insensitive dedup, keep first-seen casing) | 45 | // Normalize source names (case-insensitive dedup, keep first-seen casing) |
| 15 | const normalizedSites = computed(() => { | 46 | const normalizedSites = computed(() => { |
| 16 | const canonical: Record<string, string> = {} | 47 | const canonical: Record<string, string> = {} |
| @@ -21,9 +52,9 @@ const normalizedSites = computed(() => { | |||
| 21 | } | 52 | } |
| 22 | } | 53 | } |
| 23 | return props.sites.map(site => { | 54 | return props.sites.map(site => { |
| 24 | const scrapes: Record<string, string> = {} | 55 | const scrapes: Record<string, NormalizedScrapeValue> = {} |
| 25 | for (const [source, player] of Object.entries(site.scrapes)) { | 56 | for (const [source, value] of Object.entries(site.scrapes)) { |
| 26 | scrapes[canonical[source.toLowerCase()]] = player | 57 | scrapes[canonical[source.toLowerCase()]] = normalizeScrapeValue(value) |
| 27 | } | 58 | } |
| 28 | return { name: site.name, scrapes } | 59 | return { name: site.name, scrapes } |
| 29 | }) | 60 | }) |
| @@ -125,8 +156,11 @@ onMounted(() => { | |||
| 125 | v-for="source in sources" | 156 | v-for="source in sources" |
| 126 | :key="source" | 157 | :key="source" |
| 127 | class="cell" | 158 | class="cell" |
| 128 | :class="{ active: source in site.scrapes }" | 159 | :class="{ |
| 129 | :title="site.scrapes[source] || undefined" | 160 | active: source in site.scrapes, |
| 161 | 'active-sd': hasMetadata(site.scrapes[source], 'SD'), | ||
| 162 | }" | ||
| 163 | :title="getScrapeTitle(site.scrapes[source])" | ||
| 130 | /> | 164 | /> |
| 131 | </tr> | 165 | </tr> |
| 132 | </tbody> | 166 | </tbody> |
docs/.vitepress/theme/styles/style.scss +5
| @@ -1444,6 +1444,7 @@ table tr:nth-child(odd) { | |||
| 1444 | :root { | 1444 | :root { |
| 1445 | --scrape-cell-bg: #ebedf0; | 1445 | --scrape-cell-bg: #ebedf0; |
| 1446 | --scrape-cell-active: #56d364; | 1446 | --scrape-cell-active: #56d364; |
| 1447 | --scrape-cell-active-sd: #ff4d4f; | ||
| 1447 | } | 1448 | } |
| 1448 | 1449 | ||
| 1449 | .dark { | 1450 | .dark { |
| @@ -1544,6 +1545,10 @@ table tr:nth-child(odd) { | |||
| 1544 | background: var(--scrape-cell-active); | 1545 | background: var(--scrape-cell-active); |
| 1545 | } | 1546 | } |
| 1546 | 1547 | ||
| 1548 | &.active-sd::before { | ||
| 1549 | background: var(--scrape-cell-active-sd); | ||
| 1550 | } | ||
| 1551 | |||
| 1547 | &.active[title]:hover::after { | 1552 | &.active[title]:hover::after { |
| 1548 | content: attr(title); | 1553 | content: attr(title); |
| 1549 | position: absolute; | 1554 | position: absolute; |