import { useState, useRef, useEffect } from 'react'; import { Pill } from '../pill'; import { twMerge } from 'tailwind-merge'; interface OwnersListProps { owners: string[]; className?: string; } export function OwnersList({ owners, className }: OwnersListProps) { const [isExpanded, _setIsExpanded] = useState(false); const [isOverflowing, setIsOverflowing] = useState(false); const ownersContainerRef = useRef(null); const checkOverflow = () => { requestAnimationFrame(() => { if (ownersContainerRef.current) { setIsOverflowing( ownersContainerRef.current.scrollWidth > ownersContainerRef.current.offsetWidth ); } }); }; const setExpanded = (value: boolean) => { _setIsExpanded(value); checkOverflow(); }; useEffect(() => { checkOverflow(); window.addEventListener('resize', checkOverflow); return () => window.removeEventListener('resize', checkOverflow); }, [ownersContainerRef]); return (

Owners: {owners.map((tag) => ( ))} {isExpanded && ( )} {isOverflowing && !isExpanded && ( )}

); }