Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

1.0 KB
Raw Blame
import { Badge } from "@/components/ui/badge";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";

interface Props {
  label: string;
  value: string;
  tooltip?: string;
  className?: string;
}

const InfoChip = ({ label, value, tooltip, className }: Props) => {
  const chip = (
    <Badge
      variant="outline"
      shape="pill"
      className={cn("max-w-full items-start gap-1.5 px-2.5 py-1 text-[11px] font-normal leading-4 whitespace-nowrap", className)}
    >
      <span className="text-muted-foreground">{label}</span>
      <span className="max-w-[20rem] truncate text-foreground">{value}</span>
    </Badge>
  );

  if (!tooltip) {
    return chip;
  }

  return (
    <Tooltip>
      <TooltipTrigger render={<span className="inline-flex" tabIndex={0} aria-label={tooltip} />}>{chip}</TooltipTrigger>
      <TooltipContent className="max-w-xs whitespace-pre-wrap break-words">{tooltip}</TooltipContent>
    </Tooltip>
  );
};

export default InfoChip;