import type { CSSProperties } from 'react';
import type { StageDisplayStyle } from '@/features/objects/types';
import { stageStyle } from '../stageRules';

/**
 * LP5 ("Set pipeline display colors", Settings › Objects › Pipelines): a stage name as the object
 * shows them on its list and board: plain text, text with the stage's coloured dot, or a coloured
 * badge. Without a colour, or with `none`, it is the plain name, as before.
 */
export function StageName({
  name,
  color,
  style = 'none',
}: {
  name: string;
  color: string | null | undefined;
  style?: StageDisplayStyle;
}) {
  if (style === 'none' || !color) return <>{name}</>;
  return (
    <span
      className={style === 'dot' ? 'lpl-stage lpl-stage--dot' : 'lpl-stage lpl-stage--badge'}
      style={stageStyle(color) as CSSProperties}
    >
      {name}
    </span>
  );
}
