/**
* SectionContextBadge - Muted badge showing section context for bill comments
*
* Displays the section reference (e.g., "Section 2.1", "Part 1", "General")
* in a subtle, de-emphasized style.
*/
'use client';
interface SectionContextBadgeProps {
/** Section reference (e.g., "s2.1", "part-1") or null for general */
sectionRef: string | null;
/** Current locale for i18n */
locale: string;
/** Additional CSS classes */
className?: string;
}
/**
* Convert section reference to human-readable label
*/
function getSectionLabel(sectionRef: string | null, locale: string): string {
if (!sectionRef) {
return locale === 'fr' ? 'Général' : 'General';
}
if (sectionRef.startsWith('part-')) {
const partNum = sectionRef.replace('part-', '');
return locale === 'fr' ? `Partie ${partNum}` : `Part ${partNum}`;
}
if (sectionRef.startsWith('s')) {
const ref = sectionRef.slice(1);
return `Section ${ref}`;
}
// Fallback to raw reference
return sectionRef;
}
export function SectionContextBadge({
sectionRef,
locale,
className = '',
}: SectionContextBadgeProps) {
const label = getSectionLabel(sectionRef, locale);
return (
<span
className={`
inline-flex items-center px-2 py-0.5 rounded text-xs
bg-slate-700/50 text-slate-400
font-medium
${className}
`}
>
{label}
</span>
);
}
export default SectionContextBadge;