All files / packages/design-system-2-site/src/components/ui Tooltip.tsx

100% Statements 2/2
100% Branches 4/4
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                              4x 4x            
import type { ReactNode } from 'react';
 
interface TooltipProps {
  children: ReactNode;
  /** Render in-flow (for previews / docs) instead of fixed bottom-right. */
  inline?: boolean;
  size?: 'small' | 'large';
}
 
/**
 * Small inverse label shown after an action (e.g. "Copied: …"). Not a
 * dismissible toast: callers control visibility by rendering it conditionally.
 * Fixed bottom-right by default; `inline` shows it in-flow.
 */
export function Tooltip({ children, inline = false, size = 'large' }: TooltipProps) {
  const classes = ['tooltip', `tooltip--${size}`, inline ? 'tooltip--inline' : ''].filter(Boolean).join(' ');
  return (
    <div role="status" aria-live="polite" className={classes}>
      {children}
    </div>
  );
}