import type { RecordTag } from '../tags';

/** One record tag, in its colour (object-settings.css `.os-tagchip`). */
export function TagChip({ tag }: { tag: Pick<RecordTag, 'name' | 'color'> }) {
  return <span className={`os-tagchip os-tagchip--${tag.color}`}>{tag.name}</span>;
}

/** The tags a record carries (HUB-226), on board cards and record pages; nothing when none. */
export function TagChips({ tags, className }: { tags: RecordTag[]; className?: string }) {
  if (tags.length === 0) return null;
  return (
    <div className={className ?? 'crm-d-flex crm-flex-wrap crm-gap-2'} aria-label="Tags">
      {tags.map((tag) => (
        <span key={tag.id} title={tag.description ?? undefined}>
          <TagChip tag={tag} />
        </span>
      ))}
    </div>
  );
}
