Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

1.3 KB
Raw Blame
import React from 'react';
import { HoverCardPortal, HoverCardContent } from '@librechat/client';
import { TranslationKeys, useLocalize } from '~/hooks';
import useDirection from '~/hooks/Nav/useDirection';
import { ESide } from '~/common';

/** Callers name the side for an LTR layout; RTL mirrors the horizontal ones. */
const mirrorSide = (side: ESide): ESide => {
  if (side === ESide.Left) {
    return ESide.Right;
  }
  return side === ESide.Right ? ESide.Left : side;
};

type TOptionHoverProps = {
  description: string;
  langCode?: boolean;
  sideOffset?: number;
  disabled?: boolean;
  side: ESide;
  className?: string;
};

function OptionHover({
  side,
  description,
  disabled,
  langCode,
  sideOffset = 30,
  className,
}: TOptionHoverProps) {
  const localize = useLocalize();
  const direction = useDirection();
  if (disabled) {
    return null;
  }
  const text = langCode ? localize(description as TranslationKeys) : description;
  return (
    <HoverCardPortal>
      <HoverCardContent
        side={direction === 'rtl' ? mirrorSide(side) : side}
        className={`z-[999] w-80 ${className}`}
        sideOffset={sideOffset}
      >
        <div className="space-y-2">
          <p className="text-text-secondary text-sm whitespace-pre-wrap">{text}</p>
        </div>
      </HoverCardContent>
    </HoverCardPortal>
  );
}

export default OptionHover;