Skip to content

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

1.0 KB
Raw Blame
import { cn } from '@/utils/cn';

interface DotProps {
  className?: string;
  size?: number;
  animated?: boolean;
}

function filterCn(filter: string[], className: string | undefined) {
  const split: string[] = className?.split(' ') || [];
  return split
    .filter((item) => !filter.some((filterItem) => item.startsWith(filterItem)))
    .join(' ');
}

export function Dot({ className, size = 8, animated }: DotProps) {
  const style = {
    width: size,
    height: size,
  };
  return (
    <div
      className={cn(
        'relative',
        filterCn(['bg-', 'animate-', 'group-hover/row'], className)
      )}
      style={style}
    >
      <div
        className={cn(
          '!m-0 absolute rounded-full',
          animated !== false && 'animate-ping',
          className
        )}
        style={style}
      />
      <div
        className={cn(
          '!m-0 absolute rounded-full',
          filterCn(['animate-', 'group-hover/row'], className)
        )}
        style={style}
      />
    </div>
  );
}