OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
"use client";
import { Check } from "lucide-react";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import {
FILTER_COLORS,
type FilterColor,
ICON_MAP,
type IconKey,
iconKeyToComponent,
} from "@/lib/filter-constants";
import { cn } from "@/lib/utils";
import { filterAccentClasses } from "./knowledge-filter-panel";
export type { FilterColor, IconKey };
const colorSwatchClasses = {
zinc: "bg-muted-foreground",
pink: "bg-accent-pink-foreground",
purple: "bg-accent-purple-foreground",
indigo: "bg-accent-indigo-foreground",
emerald: "bg-accent-emerald-foreground",
amber: "bg-accent-amber-foreground",
red: "bg-accent-red-foreground",
};
export interface FilterIconPopoverProps {
color: FilterColor;
iconKey: IconKey;
onColorChange: (c: FilterColor) => void;
onIconChange: (k: IconKey) => void;
triggerClassName?: string;
}
export function FilterIconPopover({
color,
iconKey,
onColorChange,
onIconChange,
triggerClassName,
}: FilterIconPopoverProps) {
const Icon = iconKeyToComponent(iconKey);
return (
<Popover>
<PopoverTrigger asChild>
<button
type="button"
className={cn(
"h-10 w-10 min-w-10 min-h-10 rounded-md flex items-center justify-center transition-colors",
filterAccentClasses[color],
triggerClassName,
)}
>
{Icon && <Icon className="h-5 w-5" />}
</button>
</PopoverTrigger>
<PopoverContent className="w-80" align="start">
<div className="space-y-4">
<div className="grid grid-cols-7 items-center gap-2">
{FILTER_COLORS.map((c) => (
<button
key={c}
type="button"
onClick={() => onColorChange(c)}
className={cn(
"flex items-center justify-center h-6 w-6 rounded-sm transition-colors text-white",
colorSwatchClasses[c],
)}
aria-label={c}
>
{c === color && <Check className="h-3.5 w-3.5" />}
</button>
))}
</div>
<div className="grid grid-cols-6 gap-2">
{Object.keys(ICON_MAP).map((k: string) => {
const OptIcon = ICON_MAP[k as IconKey];
const active = iconKey === k;
return (
<button
key={k}
type="button"
onClick={() => onIconChange(k as IconKey)}
className={
"h-8 w-8 inline-flex items-center hover:text-foreground justify-center rounded " +
(active ? "bg-muted text-primary" : "text-muted-foreground")
}
aria-label={k}
>
<OptIcon className="h-4 w-4" />
</button>
);
})}
</div>
</div>
</PopoverContent>
</Popover>
);
}