mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +00:00
Add back hover state with collapsed references
This commit is contained in:
@@ -31,6 +31,7 @@ import {
|
|||||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||||
import DOMPurify from "dompurify";
|
import DOMPurify from "dompurify";
|
||||||
import { getIconFromFilename } from "@/app/common/iconUtils";
|
import { getIconFromFilename } from "@/app/common/iconUtils";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
interface NotesContextReferenceData {
|
interface NotesContextReferenceData {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -68,8 +69,13 @@ function NotesContextReferenceCard(props: NotesContextReferenceCardProps) {
|
|||||||
<Card
|
<Card
|
||||||
onMouseEnter={() => setIsHovering(true)}
|
onMouseEnter={() => setIsHovering(true)}
|
||||||
onMouseLeave={() => setIsHovering(false)}
|
onMouseLeave={() => setIsHovering(false)}
|
||||||
className={`${props.showFullContent ? "w-auto" : "w-[200px]"} overflow-hidden break-words text-balance rounded-lg border-none p-2 bg-muted`}
|
className={`${props.showFullContent ? "w-auto bg-muted" : "w-auto"} overflow-hidden break-words text-balance rounded-lg border-none p-2`}
|
||||||
>
|
>
|
||||||
|
{
|
||||||
|
!props.showFullContent ?
|
||||||
|
<SimpleIcon type="notes" key={`${props.title}`} />
|
||||||
|
:
|
||||||
|
<>
|
||||||
<h3
|
<h3
|
||||||
className={`${props.showFullContent ? "block" : "line-clamp-1"} text-muted-foreground}`}
|
className={`${props.showFullContent ? "block" : "line-clamp-1"} text-muted-foreground}`}
|
||||||
>
|
>
|
||||||
@@ -77,9 +83,11 @@ function NotesContextReferenceCard(props: NotesContextReferenceCardProps) {
|
|||||||
{props.showFullContent ? props.title : fileName}
|
{props.showFullContent ? props.title : fileName}
|
||||||
</h3>
|
</h3>
|
||||||
<p
|
<p
|
||||||
className={`text-sm ${props.showFullContent ? "overflow-x-auto block" : "overflow-hidden line-clamp-2"}`}
|
className={`text-sm overflow-x-auto block`}
|
||||||
dangerouslySetInnerHTML={{ __html: snippet }}
|
dangerouslySetInnerHTML={{ __html: snippet }}
|
||||||
></p>
|
></p>
|
||||||
|
</>
|
||||||
|
}
|
||||||
</Card>
|
</Card>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-[400px] mx-2">
|
<PopoverContent className="w-[400px] mx-2">
|
||||||
@@ -204,8 +212,12 @@ function CodeContextReferenceCard(props: CodeContextReferenceCardProps) {
|
|||||||
<Card
|
<Card
|
||||||
onMouseEnter={() => setIsHovering(true)}
|
onMouseEnter={() => setIsHovering(true)}
|
||||||
onMouseLeave={() => setIsHovering(false)}
|
onMouseLeave={() => setIsHovering(false)}
|
||||||
className={`${props.showFullContent ? "w-auto" : "w-[200px]"} overflow-hidden break-words text-balance rounded-lg border-none p-2 bg-muted`}
|
className={`${props.showFullContent ? "w-auto bg-muted" : "w-auto"} overflow-hidden break-words text-balance rounded-lg border-none p-2`}
|
||||||
>
|
>
|
||||||
|
{
|
||||||
|
!props.showFullContent ?
|
||||||
|
<SimpleIcon type="code" key={`code-${props.code}`} />
|
||||||
|
:
|
||||||
<div className="flex flex-col px-1">
|
<div className="flex flex-col px-1">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{fileIcon}
|
{fileIcon}
|
||||||
@@ -223,6 +235,7 @@ function CodeContextReferenceCard(props: CodeContextReferenceCardProps) {
|
|||||||
{props.output_files?.length > 0 &&
|
{props.output_files?.length > 0 &&
|
||||||
renderOutputFiles(props.output_files, false)}
|
renderOutputFiles(props.output_files, false)}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</Card>
|
</Card>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-[400px] mx-2">
|
<PopoverContent className="w-[400px] mx-2">
|
||||||
@@ -299,15 +312,15 @@ function GenericOnlineReferenceCard(props: OnlineReferenceCardProps) {
|
|||||||
<Card
|
<Card
|
||||||
onMouseEnter={handleMouseEnter}
|
onMouseEnter={handleMouseEnter}
|
||||||
onMouseLeave={handleMouseLeave}
|
onMouseLeave={handleMouseLeave}
|
||||||
className={`${props.showFullContent ? "w-auto" : "w-[200px]"} overflow-hidden break-words text-balance rounded-lg border-none p-2 bg-muted`}
|
className={`${props.showFullContent ? "w-auto bg-muted" : "w-auto"} overflow-hidden break-words text-balance rounded-lg border-none p-2`}
|
||||||
>
|
>
|
||||||
|
{
|
||||||
|
!props.showFullContent ?
|
||||||
|
<SimpleIcon type="online" key={props.title} link={props.link} />
|
||||||
|
:
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<a
|
{
|
||||||
href={props.link}
|
<Link href={props.link}>
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
className="!no-underline px-1"
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<img src={favicon} alt="" className="!w-4 h-4 flex-shrink-0" />
|
<img src={favicon} alt="" className="!w-4 h-4 flex-shrink-0" />
|
||||||
<h3
|
<h3
|
||||||
@@ -316,6 +329,8 @@ function GenericOnlineReferenceCard(props: OnlineReferenceCardProps) {
|
|||||||
{domain}
|
{domain}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
<h3
|
<h3
|
||||||
className={`overflow-hidden ${props.showFullContent ? "block" : "line-clamp-1"} font-bold`}
|
className={`overflow-hidden ${props.showFullContent ? "block" : "line-clamp-1"} font-bold`}
|
||||||
>
|
>
|
||||||
@@ -326,8 +341,8 @@ function GenericOnlineReferenceCard(props: OnlineReferenceCardProps) {
|
|||||||
>
|
>
|
||||||
{props.description}
|
{props.description}
|
||||||
</p>
|
</p>
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</Card>
|
</Card>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-[400px] mx-2">
|
<PopoverContent className="w-[400px] mx-2">
|
||||||
@@ -609,17 +624,29 @@ export default function ReferencePanel(props: ReferencePanelDataProps) {
|
|||||||
<SheetTrigger className="text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center m-0 inline-flex">
|
<SheetTrigger className="text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center m-0 inline-flex">
|
||||||
{codeDataToShow.map((code, index) => {
|
{codeDataToShow.map((code, index) => {
|
||||||
return (
|
return (
|
||||||
<SimpleIcon type="code" key={`code-${index}`} />
|
<CodeContextReferenceCard
|
||||||
|
showFullContent={false}
|
||||||
|
{...code}
|
||||||
|
key={`code-${index}`}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{notesDataToShow.map((note, index) => {
|
{notesDataToShow.map((note, index) => {
|
||||||
return (
|
return (
|
||||||
<SimpleIcon type="notes" key={`${note.title}-${index}`} />
|
<NotesContextReferenceCard
|
||||||
|
showFullContent={false}
|
||||||
|
{...note}
|
||||||
|
key={`${note.title}-${index}`}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{onlineDataToShow.map((online, index) => {
|
{onlineDataToShow.map((online, index) => {
|
||||||
return (
|
return (
|
||||||
<SimpleIcon type="online" key={`${online.title}-${index}`} link={online.link} />
|
<GenericOnlineReferenceCard
|
||||||
|
showFullContent={false}
|
||||||
|
{...online}
|
||||||
|
key={`${online.title}-${index}`}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<ArrowRight className="m-0" />
|
<ArrowRight className="m-0" />
|
||||||
|
|||||||
Reference in New Issue
Block a user