import { useCollaborationStore } from '../../store/collaborationStore'; const AVATAR_COLORS = [ '#22d3ee', '#f472b6', '#34d399', '#fbbf24', '#a78bfa', '#fb923c', '#4ade80', '#f87171', '#38bdf8', '#c084fc', ]; function getColor(userId: string): string { let hash = 0; for (let i = 0; i < userId.length; i++) { hash = ((hash << 5) - hash) + userId.charCodeAt(i); } return AVATAR_COLORS[Math.abs(hash) % AVATAR_COLORS.length]; } export default function CollaboratorAvatars({ fileId }: { fileId?: string }) { const collaborators = useCollaborationStore((s) => s.collaborators); const connected = useCollaborationStore((s) => s.connected); if (!connected || collaborators.length === 0) return null; const visible = fileId ? collaborators.filter((c) => c.activeFileId === fileId) : collaborators; if (visible.length === 0) return null; return (
{visible.map((c) => (
{c.username.charAt(0).toUpperCase()}
{c.username}
{c.permission}
))}
); } export { getColor };