forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

rag-citations.tsx44 lines, 1.9 KiBHistoryRawDownload
1import { For, Show } from "solid-js";
2import type { RagCitation } from "@/api/client";
3import { IconBook, IconFileText } from "@/components/ui/icons";
4
5export function RagCitations(props: {
6 citations: RagCitation[];
7 labels: { sources: string; source: string; subject: string; pages: string; document: string };
8}) {
9 return (
10 <Show when={props.citations.length > 0}>
11 <div class="mt-3 border-t border-border/60 pt-3">
12 <p class="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
13 {props.labels.sources}
14 </p>
15 <ol class="grid gap-2 sm:grid-cols-2">
16 <For each={props.citations}>
17 {(citation) => (
18 <li class="rounded-lg border border-border/70 bg-muted/30 px-3 py-2 text-xs">
19 <div class="flex items-start gap-2">
20 <span class="mt-0.5 flex h-5 min-w-5 items-center justify-center rounded-md bg-primary/10 px-1 font-mono font-semibold text-primary-text">
21 {citation.n}
22 </span>
23 <div class="min-w-0 space-y-1">
24 <p class="flex items-center gap-1.5 font-medium text-foreground">
25 <Show when={citation.ders} fallback={<IconFileText class="h-3.5 w-3.5" />}>
26 <IconBook class="h-3.5 w-3.5" />
27 </Show>
28 <span class="truncate">{citation.ders || props.labels.document}</span>
29 </p>
30 <Show when={citation.pages.length > 0}>
31 <p class="text-muted-foreground">
32 {props.labels.pages}: <span class="tabular-nums">{citation.pages.join(", ")}</span>
33 </p>
34 </Show>
35 </div>
36 </div>
37 </li>
38 )}
39 </For>
40 </ol>
41 </div>
42 </Show>
43 );
44}