nyuchimzizi
Mzizi — an open-architecture project of the Bundu Foundation, operated and developed by Nyuchi. Built on the Five African Minerals palette.
Built by Nyuchi Africav4.0.39
Citation card linking AI responses to source documents.
View the full component source code below.
import * as React from "react"
import { ExternalLink } from "@/lib/icons"
import { cva } from "class-variance-authority"
import { cn } from "@/lib/utils"
const relevanceVariants = cva(
"inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",
{
variants: {
level: {
high: "bg-mineral-malachite/15 text-mineral-malachite",
medium: "bg-mineral-gold/15 text-mineral-gold",
low: "bg-muted text-muted-foreground",
},
},
defaultVariants: {
level: "medium",
},
}
)
function getRelevanceLevel(relevance: number): "high" | "medium" | "low" {
if (relevance >= 0.7) return "high"
if (relevance >= 0.4) return "medium"
return "low"
}
function SourceCitation({
className,
title,
url,
snippet,
relevance,
...props
}: React.ComponentProps<"div"> & {
title: string
url: string
snippet?: string
relevance?: number
}) {
const level = relevance !== undefined ? getRelevanceLevel(relevance) : undefined
return (
<div
data-slot="source-citation" data-portal="https://design.nyuchi.com/components/source-citation"
className={cn(
"group flex flex-col gap-1.5 rounded-[var(--radius-xl,17px)] bg-card p-3 text-sm ring-1 ring-foreground/10",
className
)}
{...props}
>
<div className="flex items-start justify-between gap-2">
<a
href={url}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1.5 font-medium text-foreground transition-colors hover:text-primary"
>
{title}
<ExternalLink className="size-3 shrink-0 text-muted-foreground" />
</a>
{level && (
<span className={relevanceVariants({ level })}>{Math.round(relevance! * 100)}%</span>
)}
</div>
{snippet && <p className="line-clamp-2 text-xs text-muted-foreground">{snippet}</p>}
</div>
)
}
export { SourceCitation }
npx shadcn@latest add https://mzizi.dev/api/v1/ui/source-citationFetch this component's metadata and source code from the registry API.
/api/v1/ui/source-citationcomponents/ui/source-citation.tsx