Vrda's picture
Deploy Learn Pathophysiology WC3 Edition
8b9f7d9
raw
history blame
1.52 kB
<script setup lang="ts">
import { ref } from 'vue'
import type { Citation } from '../types'
defineProps<{ citations: Citation[] }>()
const isOpen = ref(false)
function scoreColor(score: number): string {
if (score >= 0.8) return '#44aa44'
if (score >= 0.6) return '#aaaa44'
return '#aa7744'
}
function scoreBar(score: number): string {
return `${Math.round(score * 100)}%`
}
</script>
<template>
<div>
<button class="citations-toggle" @click="isOpen = !isOpen">
📜 Izvori ({{ citations.length }})
{{ isOpen ? '▲' : '▼' }}
</button>
<div v-if="isOpen" class="citations-panel">
<div
v-for="c in citations"
:key="c.rank"
class="citation-item"
>
<div class="citation-header">
<span>#{{ c.rank }}</span>
<span style="margin-left: 0.75rem;">
📄 {{ c.source }} — str. {{ c.page_num }}
</span>
<span style="margin-left: auto; display: inline-flex; align-items: center; gap: 0.3rem;">
<span
style="display: inline-block; height: 8px; border-radius: 2px;"
:style="{ width: scoreBar(c.score), background: scoreColor(c.score), minWidth: '20px' }"
></span>
<span style="font-size: 0.75rem; color: var(--wc3-text-dim);">
{{ (c.score * 100).toFixed(0) }}%
</span>
</span>
</div>
<div class="citation-text">{{ c.text }}</div>
</div>
</div>
</div>
</template>