diff --git a/index.html b/index.html index 657d80b..f49e418 100644 --- a/index.html +++ b/index.html @@ -1835,6 +1835,35 @@ } function renderNotesList(items) { + // Color palette for shared with person names (different from green) + const personColorPalette = [ + { bg: 'bg-blue-200', border: 'border-blue-400', text: 'text-blue-900' }, + { bg: 'bg-purple-200', border: 'border-purple-400', text: 'text-purple-900' }, + { bg: 'bg-indigo-200', border: 'border-indigo-400', text: 'text-indigo-900' }, + { bg: 'bg-cyan-200', border: 'border-cyan-400', text: 'text-cyan-900' }, + { bg: 'bg-teal-200', border: 'border-teal-400', text: 'text-teal-900' }, + { bg: 'bg-sky-200', border: 'border-sky-400', text: 'text-sky-900' }, + { bg: 'bg-lime-200', border: 'border-lime-400', text: 'text-lime-900' }, + { bg: 'bg-rose-200', border: 'border-rose-400', text: 'text-rose-900' }, + ]; + + // Map to store consistent colors for each person + const personColorMap = {}; + + function getPersonColor(name) { + if (!personColorMap[name]) { + // Generate consistent hash-based color index for this person + let hash = 0; + for (let i = 0; i < name.length; i++) { + hash = ((hash << 5) - hash) + name.charCodeAt(i); + hash = hash & hash; // Convert to 32-bit integer + } + const colorIndex = Math.abs(hash) % personColorPalette.length; + personColorMap[name] = personColorPalette[colorIndex]; + } + return personColorMap[name]; + } + const grid = document.getElementById('notesGrid'); const empty = document.getElementById('notesEmpty'); grid.innerHTML = ''; @@ -1899,7 +1928,8 @@ const sharedNames = Array.isArray(note.shared_with) ? note.shared_with : (typeof note.shared_with === 'string' ? note.shared_with.split(',').map(n => n.trim()) : []); const capsules = sharedNames.map(name => { const firstName = name.split(' ')[0]; - return `${escapeHtml(firstName)}`; + const colors = getPersonColor(name); + return `${escapeHtml(firstName)}`; }).join(''); sharedWithDisplay = `
${capsules}
`; } @@ -1908,16 +1938,18 @@ card.innerHTML = `
${escapeHtml(title)}
-
-
${formatDateShort(note.created)}
- ${note.shared ? `
${typeBubble}${sharedWithDisplay}
` : ''} -
+
${formatDateShort(note.created)}
-
${escapeHtml(snippet || '(empty)')}
-
- ${note.shared ? '' : escapeHtml(meta)} +
+
${escapeHtml(snippet || '(empty)')}
+ ${note.shared ? `
${typeBubble}
` : ''} +
+
- ${note.shared ? '' : attachmentIcons} + ${attachmentIcons} +
+
+ ${note.shared ? sharedWithDisplay : ''}
`;