diff --git a/app/components/sidebar/HistoryItem.tsx b/app/components/sidebar/HistoryItem.tsx index 3f58735f8..4c284359d 100644 --- a/app/components/sidebar/HistoryItem.tsx +++ b/app/components/sidebar/HistoryItem.tsx @@ -1,5 +1,4 @@ import * as Dialog from '@radix-ui/react-dialog'; -import { useEffect, useRef, useState } from 'react'; import { type ChatHistoryItem } from '~/lib/persistence'; import WithTooltip from '~/components/ui/Tooltip'; @@ -11,78 +10,46 @@ interface HistoryItemProps { } export function HistoryItem({ item, onDelete, onDuplicate, exportChat }: HistoryItemProps) { - const [hovering, setHovering] = useState(false); - const hoverRef = useRef(null); - - useEffect(() => { - let timeout: NodeJS.Timeout | undefined; - - function mouseEnter() { - setHovering(true); - - if (timeout) { - clearTimeout(timeout); - } - } - - function mouseLeave() { - setHovering(false); - } - - hoverRef.current?.addEventListener('mouseenter', mouseEnter); - hoverRef.current?.addEventListener('mouseleave', mouseLeave); - - return () => { - hoverRef.current?.removeEventListener('mouseenter', mouseEnter); - hoverRef.current?.removeEventListener('mouseleave', mouseLeave); - }; - }, []); - return ( -
+
{item.description}
- {hovering && ( -
- +
+ +
- )} + +
diff --git a/app/components/sidebar/Menu.client.tsx b/app/components/sidebar/Menu.client.tsx index 5becf82c4..d753d242e 100644 --- a/app/components/sidebar/Menu.client.tsx +++ b/app/components/sidebar/Menu.client.tsx @@ -129,7 +129,7 @@ export function Menu() {
Your Chats
-
+
{list.length === 0 &&
No previous conversations
} {binDates(list).map(({ category, items }) => ( diff --git a/app/components/ui/Tooltip.tsx b/app/components/ui/Tooltip.tsx index 73ababb3a..4e22f540c 100644 --- a/app/components/ui/Tooltip.tsx +++ b/app/components/ui/Tooltip.tsx @@ -1,14 +1,15 @@ -import React from 'react'; import * as Tooltip from '@radix-ui/react-tooltip'; -import type { ReactNode } from 'react'; -interface ToolTipProps { - tooltip: string; - children: ReactNode | ReactNode[]; +interface TooltipProps { + tooltip: React.ReactNode; + children: React.ReactNode; sideOffset?: number; className?: string; arrowClassName?: string; - tooltipStyle?: any; //TODO better type + tooltipStyle?: React.CSSProperties; + position?: 'top' | 'bottom' | 'left' | 'right'; + maxWidth?: number; + delay?: number; } const WithTooltip = ({ @@ -18,18 +19,51 @@ const WithTooltip = ({ className = '', arrowClassName = '', tooltipStyle = {}, -}: ToolTipProps) => { + position = 'top', + maxWidth = 250, + delay = 0, +}: TooltipProps) => { return ( - + {children} - {tooltip} - +
{tooltip}
+