Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

594 B
Raw Blame
'use client';

import { useLegendItem } from './legend-context';
import { cn } from '@/lib/utils';

export interface LegendMarkerProps {
  /** Marker size class. Default: "h-2.5 w-2.5" */
  className?: string;
}

export function LegendMarker({ className = 'h-2.5 w-2.5' }: LegendMarkerProps) {
  const { item } = useLegendItem();

  // Note: backgroundColor must remain inline style as item.color is dynamic data
  return (
    <div
      className={cn('shrink-0 rounded-full', className)}
      style={{ backgroundColor: item.color }}
    />
  );
}

LegendMarker.displayName = 'LegendMarker';