The user wants me to create a real-time collaboration UX interface. This is a complex UI/UX challenge that involves:
- Presence Indicators - Show who's online, where they're editing, what they're viewing
- Conflict Resolution - Handle simultaneous edits gracefully
- Document Version Storytelling - Visual history/timeline of changes
Let me design a sophisticated, interactive demo that showcases these concepts. I'll create:
- A document editor interface with multiple "fake" collaborators
- Live presence avatars with cursor positions
- A conflict resolution modal/panel
- A version timeline/story visualization
- Smooth animations and transitions
Design Direction:
- Aesthetic: Modern, professional, slightly editorial feel - like Notion meets Linear
- Color Palette: Dark mode with warm accents - deep navy/charcoal base, coral/amber accent
- Typography: Something distinctive - maybe "Space Grotesk" for headings, "DM Sans" for body
Key Features:
-
Presence System:
- Animated avatars showing online users
- Colored cursors with names
- Typing indicators
- "Viewing this section" highlights
-
Conflict Resolution:
- Visual diff view showing conflicting changes
- Options to accept/reject/merge
- Color-coded change attribution
-
Version Storytelling:
- Interactive timeline
- Expandable version cards
- Change visualization
- "Time travel" slider
Let me build this with careful attention to:
- Visual hierarchy
- Meaningful interactions
- Polished animations
- Accessibility
- Performance
I'll simulate real-time behavior with intervals and timeouts to make it feel alive.
Real-time Collaboration UX Design
This is a sophisticated collaboration interface demonstrating presence, conflict resolution, and version storytelling. The design uses a refined dark aesthetic with warm coral accents.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Collab Studio - Real-time Collaboration</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0f1117;
--bg-elevated: #161920;
--bg-surface: #1c1f2a;
--fg: #e8e9ed;
--fg-muted: #6b7085;
--fg-dim: #3d4255;
--accent: #ff6b4a;
--accent-glow: rgba(255, 107, 74, 0.3);
--success: #4ade80;
--warning: #fbbf24;
--conflict: #f472b6;
--user-amber: #f59e0b;
--user-violet: #a78bfa;
--user-emerald: #34d399;
--user-sky: #38bdf8;
--border: #2a2e3d;
--border-active: #3d4255;
}
* {
font-family: 'Space Grotesk', sans-serif;
}
body {
background: var(--bg);
color: var(--fg);
}
.font-mono {
font-family: 'JetBrains Mono', monospace;
}
/* Scrollbar */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--border-active);
}
/* Animations */
@keyframes pulse-ring {
0% { transform: scale(0.9); opacity: 1; }
100% { transform: scale(1.3); opacity: 0; }
}
@keyframes cursor-blink {
0%, 50% { opacity: 1; }
51%, 100% { opacity: 0; }
}
@keyframes typing-dot {
0%, 60%, 100% { transform: translateY(0); }
30% { transform: translateY(-4px); }
}
@keyframes slide-up {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes scale-in {
from { opacity: 0; transform: scale(0.95); }
to { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
.animate-slide-up {
animation: slide-up 0.5s ease-out forwards;
}
.animate-fade-in {
animation: fade-in 0.3s ease-out forwards;
}
.animate-scale-in {
animation: scale-in 0.3s ease-out forwards;
}
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
/* Presence Cursor */
.presence-cursor {
position: absolute;
pointer-events: none;
z-index: 100;
transition: all 0.15s ease-out;
}
.cursor-caret {
width: 2px;
height: 20px;
animation: cursor-blink 1s infinite;
}
.cursor-label {
position: absolute;
top: -24px;
left: 8px;
font-size: 11px;
padding: 2px 6px;
border-radius: 4px;
white-space: nowrap;
font-weight: 500;
}
/* Typing indicator */
.typing-dot {
width: 4px;
height: 4px;
border-radius: 50%;
animation: typing-dot 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
/* Online pulse */
.online-pulse::before {
content: '';
position: absolute;
inset: 0;
border-radius: 50%;
background: currentColor;
animation: pulse-ring 1.5s infinite;
}
/* Conflict highlight */
.conflict-region {
background: linear-gradient(90deg, rgba(244, 114, 182, 0.15), transparent);
border-left: 3px solid var(--conflict);
}
/* Version timeline */
.version-node {
position: relative;
}
.version-node::before {
content: '';
position: absolute;
left: 50%;
top: 100%;
width: 2px;
height: 40px;
background: var(--border);
transform: translateX(-50%);
}
.version-node:last-child::before {
display: none;
}
/* Focus states */
button:focus-visible, a:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* Custom selection */
::selection {
background: var(--accent);
color: white;
}
</style>
</head>
<body class="min-h-screen overflow-x-hidden">
<!-- Background atmosphere -->
<div class="fixed inset-0 pointer-events-none">
<div class="absolute top-0 left-1/4 w-96 h-96 bg-gradient-to-br from-amber-500/5 to-transparent rounded-full blur-3xl"></div>
<div class="absolute bottom-0 right-1/4 w-96 h-96 bg-gradient-to-tl from-violet-500/5 to-transparent rounded-full blur-3xl"></div>
</div>
<div class="relative flex h-screen">
<!-- Left Sidebar - Version Storytelling -->
<aside id="versionSidebar" class="w-72 border-r border-[var(--border)] bg-[var(--bg-elevated)] flex flex-col transform -translate-x-full lg:translate-x-0 fixed lg:relative z-40 h-full transition-transform duration-300">
<div class="p-4 border-b border-[var(--border)]">
<div class="flex items-center justify-between mb-4">
<h2 class="font-semibold text-sm tracking-wide text-[var(--fg-muted)] uppercase">Version History</h2>
<button id="closeVersionBtn" class="lg:hidden p-1 rounded hover:bg-[var(--bg-surface)]">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
<div class="flex items-center gap-2 p-2 bg-[var(--bg-surface)] rounded-lg">
<div class="w-8 h-8 rounded-full bg-gradient-to-br from-amber-400 to-orange-500 flex items-center justify-center text-white text-xs font-bold">Q</div>
<div class="flex-1 min-w-0">
<div class="text-sm font-medium truncate">Q4 Strategy Doc</div>
<div class="text-xs text-[var(--fg-muted)]">24 versions</div>
</div>
</div>
</div>
<div class="flex-1 overflow-y-auto p-4">
<!-- Version Timeline -->
<div class="space-y-0" id="versionTimeline">
<!-- Versions will be rendered here -->
</div>
</div>
<!-- Time Travel Slider -->
<div class="p-4 border-t border-[var(--border)] bg-[var(--bg)]">
<label class="text-xs text-[var(--fg-muted)] block mb-2">Time Travel</label>
<input type="range" id="timeSlider" min="0" max="23" value="23" class="w-full h-2 bg-[var(--bg-surface)] rounded-lg appearance-none cursor-pointer accent-[var(--accent)]">
<div class="flex justify-between text-xs text-[var(--fg-muted)] mt-1">
<span>Oct 1</span>
<span id="currentDate" class="text-[var(--fg)]">Today</span>
</div>
</div>
</aside>
<!-- Main Editor Area -->
<main class="flex-1 flex flex-col min-w-0">
<!-- Top Bar -->
<header class="h-14 border-b border-[var(--border)] bg-[var(--bg-elevated)] flex items-center px-4 gap-4">
<button id="openVersionBtn" class="lg:hidden p-2 rounded-lg hover:bg-[var(--bg-surface)] transition-colors" aria-label="Open version history">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</button>
<div class="flex-1 flex items-center gap-3">
<div class="w-8 h-8 rounded-lg bg-gradient-to-br from-amber-400 to-orange-500 flex items-center justify-center text-white text-xs font-bold">Q</div>
<div>
<h1 class="font-semibold text-sm">Q4 Strategy Document</h1>
<div class="text-xs text-[var(--fg-muted)]">Last saved 2 seconds ago</div>
</div>
</div>
<!-- Presence Avatars -->
<div class="flex items-center">
<div id="presenceAvatars" class="flex -space-x-2">
<!-- Avatars rendered by JS -->
</div>
<button id="inviteBtn" class="ml-2 w-8 h-8 rounded-full border-2 border-dashed border-[var(--border)] flex items-center justify-center hover:border-[var(--accent)] hover:text-[var(--accent)] transition-colors" aria-label="Invite collaborators">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
</svg>
</button>
</div>
<div class="w-px h-6 bg-[var(--border)]"></div>
<button id="conflictBtn" class="relative px-3 py-1.5 rounded-lg text-sm font-medium bg-[var(--conflict)]/10 text-[var(--conflict)] hover:bg-[var(--conflict)]/20 transition-colors hidden">
<span class="flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
<span id="conflictCount">0</span> Conflicts
</span>
</button>
<button class="px-4 py-1.5 rounded-lg text-sm font-medium bg-[var(--accent)] text-white hover:bg-[var(--accent)]/90 transition-colors">
Share
</button>
</header>
<!-- Editor Content -->
<div class="flex-1 overflow-y-auto">
<div class="max-w-3xl mx-auto py-12 px-6">
<!-- Document Title -->
<div class="mb-8 animate-slide-up opacity-0" style="animation-delay: 0.1s">
<input type="text" value="Q4 Strategy Document" class="w-full text-4xl font-bold bg-transparent border-none outline-none placeholder:text-[var(--fg-dim)]" placeholder="Untitled">
<div class="flex items-center gap-4 mt-3 text-sm text-[var(--fg-muted)]">
<span class="flex items-center gap-1.5">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
October 24, 2024
</span>
<span class="flex items-center gap-1.5">
<div class="w-2 h-2 rounded-full bg-[var(--success)]"></div>
Auto-saved
</span>
</div>
</div>
<!-- Editor Blocks -->
<div id="editorBlocks" class="space-y-6">
<!-- Blocks rendered by JS -->
</div>
</div>
</div>
<!-- Typing Indicators Bar -->
<div id="typingBar" class="h-10 border-t border-[var(--border)] bg-[var(--bg-elevated)] flex items-center px-4 text-sm text-[var(--fg-muted)] transition-opacity duration-200">
<!-- Typing indicators rendered by JS -->
</div>
</main>
<!-- Right Panel - Activity / Conflicts -->
<aside id="rightPanel" class="w-80 border-l border-[var(--border)] bg-[var(--bg-elevated)] flex-col hidden lg:flex">
<!-- Panel Tabs -->
<div class="flex border-b border-[var(--border)]">
<button id="tabActivity" class="flex-1 px-4 py-3 text-sm font-medium border-b-2 border-[var(--accent)] text-[var(--fg)]">Activity</button>
<button id="tabConflicts" class="flex-1 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-[var(--fg-muted)] hover:text-[var(--fg)]">Conflicts</button>
</div>
<!-- Activity Panel -->
<div id="activityPanel" class="flex-1 overflow-y-auto p-4">
<div id="activityFeed" class="space-y-3">
<!-- Activity items rendered by JS -->
</div>
</div>
<!-- Conflicts Panel -->
<div id="conflictsPanel" class="flex-1 overflow-y-auto p-4 hidden">
<div id="conflictsList" class="space-y-4">
<!-- Conflicts rendered by JS -->
</div>
</div>
</aside>
</div>
<!-- Conflict Resolution Modal -->
<div id="conflictModal" class="fixed inset-0 bg-black/60 backdrop-blur-sm z-50 hidden items-center justify-center p-4">
<div class="bg-[var(--bg-elevated)] rounded-2xl shadow-2xl w-full max-w-2xl max-h-[80vh] overflow-hidden animate-scale-in">
<div class="p-6 border-b border-[var(--border)]">
<div class="flex items-center justify-between">
<h3 class="text-lg font-semibold">Resolve Conflict</h3>
<button id="closeModalBtn" class="p-2 rounded-lg hover:bg-[var(--bg-surface)] transition-colors">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
<p class="text-sm text-[var(--fg-muted)] mt-1">Two collaborators edited the same section simultaneously</p>
</div>
<div class="p-6 grid grid-cols-2 gap-4">
<!-- Your Version -->
<div class="space-y-3">
<div class="flex items-center gap-2">
<div class="w-6 h-6 rounded-full bg-gradient-to-br from-amber-400 to-orange-500"></div>
<span class="text-sm font-medium">Your version</span>
<span class="text-xs text-[var(--fg-muted)]">2 min ago</span>
</div>
<div class="p-4 rounded-lg bg-[var(--bg-surface)] border-2 border-[var(--accent)] text-sm leading-relaxed">
<p>Focus on enterprise clients in Q4, targeting a 40% increase in deal size through strategic partnerships with major cloud providers.</p>
</div>
<button class="w-full py-2 rounded-lg bg-[var(--accent)] text-white text-sm font-medium hover:bg-[var(--accent)]/90 transition-colors">
Keep your version
</button>
</div>
<!-- Their Version -->
<div class="space-y-3">
<div class="flex items-center gap-2">
<div class="w-6 h-6 rounded-full bg-gradient-to-br from-violet-400 to-purple-500"></div>
<span class="text-sm font-medium">Sarah's version</span>
<span class="text-xs text-[var(--fg-muted)]">1 min ago</span>
</div>
<div class="p-4 rounded-lg bg-[var(--bg-surface)] border-2 border-[var(--conflict)] text-sm leading-relaxed">
<p>Prioritize mid-market expansion in Q4, aiming for 60% growth in new customer acquisition through targeted digital campaigns.</p>
</div>
<button class="w-full py-2 rounded-lg bg-[var(--bg-surface)] text-[var(--fg)] text-sm font-medium border border-[var(--border)] hover:border-[var(--conflict)] transition-colors">
Accept Sarah's version
</button>
</div>
</div>
<div class="p-6 border-t border-[var(--border)] bg-[var(--bg)]">
<button class="w-full py-3 rounded-lg bg-[var(--bg-surface)] text-[var(--fg)] text-sm font-medium border border-[var(--border)] hover:border-[var(--success)] hover:text-[var(--success)] transition-colors flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"/>
</svg>
Merge both versions
</button>
</div>
</div>
</div>
<!-- Mobile overlay -->
<div id="mobileOverlay" class="fixed inset-0 bg-black/50 z-30 hidden lg:hidden"></div>
<script>
// ===== Data =====
const collaborators = [
{ id: 1, name: 'You', color: '#f59e0b', gradient: 'from-amber-400 to-orange-500', status: 'editing', cursor: { line: 3, col: 15 } },
{ id: 2, name: 'Sarah Chen', color: '#a78bfa', gradient: 'from-violet-400 to-purple-500', status: 'viewing', cursor: { line: 1, col: 8 } },
{ id: 3, name: 'Marcus Kim', color: '#34d399', gradient: 'from-emerald-400 to-teal-500', status: 'typing', cursor: { line: 5, col: 22 } },
{ id: 4, name: 'Alex Rivera', color: '#38bdf8', gradient: 'from-sky-400 to-blue-500', status: 'idle', cursor: null }
];
const documentBlocks = [
{ id: 1, type: 'paragraph', content: 'Our Q4 strategy centers on three key pillars: enterprise expansion, product innovation, and operational excellence. This document outlines our approach and success metrics for each initiative.', editedBy: null },
{ id: 2, type: 'heading', content: 'Enterprise Expansion', editedBy: null },
{ id: 3, type: 'paragraph', content: 'Focus on enterprise clients in Q4, targeting a 40% increase in deal size through strategic partnerships with major cloud providers.', editedBy: 2, hasConflict: true },
{ id: 4, type: 'bullet-list', items: ['Increase enterprise sales team by 25%', 'Launch dedicated partner program', 'Host 3 executive roundtables'], editedBy: 3 },
{ id: 5, type: 'heading', content: 'Product Innovation', editedBy: null },
{ id: 6, type: 'paragraph', content: 'Ship the new analytics dashboard by mid-November, followed by AI-powered recommendations engine in December. Both features address top customer requests from our recent NPS survey.', editedBy: null },
{ id: 7, type: 'callout', content: 'Key milestone: Dashboard beta starts November 15th with 50 pilot customers', style: 'info', editedBy: null }
];
const versions = [
{ id: 23, date: 'Today, 2:34 PM', author: 'You', changes: 'Updated enterprise expansion section', major: false },
{ id: 22, date: 'Today, 1:15 PM', author: 'Sarah Chen', changes: 'Added product innovation details', major: true, label: 'Significant edit' },
{ id: 21, date: 'Today, 11:42 AM', author: 'Marcus Kim', changes: 'Bullet list formatting', major: false },
{ id: 20, date: 'Yesterday, 4:20 PM', author: 'You', changes: 'Initial Q4 strategy draft', major: true, label: 'Created' },
{ id: 19, date: 'Oct 22, 3:15 PM', author: 'Sarah Chen', changes: 'Added competitive analysis', major: false },
{ id: 18, date: 'Oct 21, 10:00 AM', author: 'Alex Rivera', changes: 'Executive summary updates', major: false }
];
const activities = [
{ user: 'Sarah Chen', action: 'is viewing', target: 'Enterprise Expansion', time: 'now', type: 'view' },
{ user: 'Marcus Kim', action: 'edited', target: 'Bullet list', time: '30s ago', type: 'edit' },
{ user: 'You', action: 'saved', target: 'Document', time: '2m ago', type: 'save' },
{ user: 'Alex Rivera', action: 'joined', target: '', time: '5m ago', type: 'join' },
{ user: 'Sarah Chen', action: 'commented on', target: 'Product Innovation', time: '12m ago', type: 'comment' }
];
const conflicts = [
{ id: 1, section: 'Enterprise Expansion', line: 3, users: ['You', 'Sarah Chen'], severity: 'high' }
];
// ===== DOM Elements =====
const presenceAvatars = document.getElementById('presenceAvatars');
const typingBar = document.getElementById('typingBar');
const editorBlocks = document.getElementById('editorBlocks');
const versionTimeline = document.getElementById('versionTimeline');
const activityFeed = document.getElementById('activityFeed');
const conflictsList = document.getElementById('conflictsList');
const conflictModal = document.getElementById('conflictModal');
const conflictBtn = document.getElementById('conflictBtn');
const timeSlider = document.getElementById('timeSlider');
const versionSidebar = document.getElementById('versionSidebar');
const mobileOverlay = document.getElementById('mobileOverlay');
const openVersionBtn = document.getElementById('openVersionBtn');
const closeVersionBtn = document.getElementById('closeVersionBtn');
const closeModalBtn = document.getElementById('closeModalBtn');
const tabActivity = document.getElementById('tabActivity');
const tabConflicts = document.getElementById('tabConflicts');
const activityPanel = document.getElementById('activityPanel');
const conflictsPanel = document.getElementById('conflictsPanel');
const rightPanel = document.getElementById('rightPanel');
// ===== Render Functions =====
function renderPresenceAvatars() {
presenceAvatars.innerHTML = collaborators.map((c, i) => `
<div class="relative group" style="z-index: ${collaborators.length - i}">
<div class="w-8 h-8 rounded-full bg-gradient-to-br ${c.gradient} flex items-center justify-center text-white text-xs font-bold ring-2 ring-[var(--bg-elevated)] cursor-pointer hover:scale-110 transition-transform">
${c.name.charAt(0)}
</div>
<div class="absolute ${c.status === 'editing' ? 'online-pulse' : ''}" style="color: ${c.color}"></div>
${c.status !== 'idle' ? `<div class="absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full ${c.status === 'typing' ? 'bg-[var(--success)]' : c.status === 'editing' ? 'bg-[var(--warning)]' : 'bg-[var(--user-sky)]'} ring-2 ring-[var(--bg-elevated)]"></div>` : ''}
<div class="absolute top-full mt-2 left-1/2 -translate-x-1/2 bg-[var(--bg-surface)] px-3 py-2 rounded-lg text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none shadow-xl">
<div class="font-medium">${c.name}</div>
<div class="text-[var(--fg-muted)] capitalize">${c.status}</div>
</div>
</div>
`).join('');
}
function renderTypingIndicator() {
const typing = collaborators.filter(c => c.status === 'typing');
if (typing.length === 0) {
typingBar.style.opacity = '0';
return;
}
typingBar.style.opacity = '1';
const names = typing.map(c => c.name).join(' and ');
typingBar.innerHTML = `
<div class="flex items-center gap-2">
<div class="flex gap-1">
<div class="typing-dot bg-[var(--fg-muted)]"></div>
<div class="typing-dot bg-[var(--fg-muted)]"></div>
<div class="typing-dot bg-[var(--fg-muted)]"></div>
</div>
<span><strong>${names}</strong> ${typing.length > 1 ? 'are' : 'is'} typing...</span>
</div>
`;
}
function renderEditorBlocks() {
editorBlocks.innerHTML = documentBlocks.map((block, i) => {
const collaborator = block.editedBy ? collaborators.find(c => c.id === block.editedBy) : null;
let content = '';
if (block.type === 'heading') {
content = `<h2 class="text-2xl font-bold">${block.content}</h2>`;
} else if (block.type === 'paragraph') {
content = `<p class="text-[var(--fg)] leading-relaxed">${block.content}</p>`;
} else if (block.type === 'bullet-list') {
content = `<ul class="space-y-2">${block.items.map(item => `<li class="flex items-start gap-3"><span class="w-1.5 h-1.5 rounded-full bg-[var(--accent)] mt-2 flex-shrink-0"></span><span>${item}</span></li>`).join('')}</ul>`;
} else if (block.type === 'callout') {
content = `<div class="p-4 rounded-xl bg-[var(--accent)]/10 border border-[var(--accent)]/20"><p class="text-sm font-medium">${block.content}</p></div>`;
}
return `
<div class="relative group animate-slide-up opacity-0 ${block.hasConflict ? 'conflict-region' : ''}" style="animation-delay: ${0.15 + i * 0.08}s">
<div class="absolute -left-12 top-0 opacity-0 group-hover:opacity-100 transition-opacity">
<button class="p-1.5 rounded hover:bg-[var(--bg-surface)] text-[var(--fg-muted)]" aria-label="Block options">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"/>
</svg>
</button>
</div>
${content}
${collaborator ? `
<div class="absolute -right-4 top-0 translate-x-full opacity-0 group-hover:opacity-100 transition-opacity">
<div class="flex items-center gap-1.5 px-2 py-1 bg-[var(--bg-surface)] rounded text-xs">
<div class="w-4 h-4 rounded-full bg-gradient-to-br ${collaborator.gradient}"></div>
<span class="text-[var(--fg-muted)]">Editing</span>
</div>
</div>
` : ''}
${block.hasConflict ? `
<button onclick="openConflictModal()" class="absolute right-0 top-1/2 -translate-y-1/2 px-2 py-1 bg-[var(--conflict)]/20 text-[var(--conflict)] text-xs rounded font-medium hover:bg-[var(--conflict)]/30 transition-colors">
Resolve
</button>
` : ''}
</div>
`;
}).join('');
}
function renderVersionTimeline() {
versionTimeline.innerHTML = versions.map((v, i) => `
<div class="version-node pb-10">
<button class="w-full text-left group" onclick="restoreVersion(${v.id})">
<div class="flex items-start gap-3">
<div class="w-10 h-10 rounded-full bg-[var(--bg-surface)] flex items-center justify-center flex-shrink-0 ${i === 0 ? 'ring-2 ring-[var(--accent)]' : ''} group-hover:bg-[var(--bg)] transition-colors">
<svg class="w-4 h-4 ${i === 0 ? 'text-[var(--accent)]' : 'text-[var(--fg-muted)]'}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center gap-2">
<span class="font-medium text-sm">${v.date}</span>
${v.major ? `<span class="px-1.5 py-0.5 bg-[var(--accent)]/20 text-[var(--accent)] text-xs rounded">${v.label}</span>` : ''}
</div>
<div class="text-sm text-[var(--fg-muted)] mt-0.5">${v.changes}</div>
<div class="text-xs text-[var(--fg-dim)] mt-1">by ${v.author}</div>
</div>
</div>
</button>
</div>
`).join('');
}
function renderActivityFeed() {
activityFeed.innerHTML = activities.map((a, i) => `
<div class="flex items-start gap-3 animate-slide-up opacity-0" style="animation-delay: ${i * 0.1}s">
<div class="w-8 h-8 rounded-full bg-[var(--bg-surface)] flex items-center justify-center flex-shrink-0">
${a.type === 'edit' ? `<svg class="w-4 h-4 text-[var(--warning)]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>` : ''}
${a.type === 'view' ? `<svg class="w-4 h-4 text-[var(--user-sky)]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>` : ''}
${a.type === 'save' ? `<svg class="w-4 h-4 text-[var(--success)]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>` : ''}
${a.type === 'join' ? `<svg class="w-4 h-4 text-[var(--user-emerald)]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z"/></svg>` : ''}
${a.type === 'comment' ? `<svg class="w-4 h-4 text-[var(--user-violet)]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"/></svg>` : ''}
</div>
<div class="flex-1 min-w-0">
<p class="text-sm"><strong>${a.user}</strong> ${a.action} ${a.target ? `<span class="text-[var(--accent)]">${a.target}</span>` : ''}</p>
<p class="text-xs text-[var(--fg-muted)]">${a.time}</p>
</div>
</div>
`).join('');
}
function renderConflicts() {
if (conflicts.length === 0) {
conflictsList.innerHTML = `
<div class="text-center py-8 text-[var(--fg-muted)]">
<svg class="w-12 h-12 mx-auto mb-3 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<p>No conflicts detected</p>
</div>
`;
return;
}
conflictsList.innerHTML = conflicts.map(c => `
<div class="p-4 rounded-xl bg-[var(--conflict)]/10 border border-[var(--conflict)]/20">
<div class="flex items-center gap-2 mb-2">
<svg class="w-5 h-5 text-[var(--conflict)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
<span class="font-medium">${c.section}</span>
</div>
<p class="text-sm text-[var(--fg-muted)] mb-3">Conflicting edits by ${c.users.join(' and ')}</p>
<button onclick="openConflictModal()" class="w-full py-2 rounded-lg bg-[var(--conflict)] text-white text-sm font-medium hover:bg-[var(--conflict)]/90 transition-colors">
Resolve Conflict
</button>
</div>
`).join('');
// Show conflict button in header
conflictBtn.classList.remove('hidden');
document.getElementById('conflictCount').textContent = conflicts.length;
}
// ===== Interactions =====
function openConflictModal() {
conflictModal.classList.remove('hidden');
conflictModal.classList.add('flex');
}
function closeConflictModal() {
conflictModal.classList.add('hidden');
conflictModal.classList.remove('flex');
}
function openVersionSidebar() {
versionSidebar.classList.remove('-translate-x-full');
mobileOverlay.classList.remove('hidden');
}
function closeVersionSidebar() {
versionSidebar.classList.add('-translate-x-full');
mobileOverlay.classList.add('hidden');
}
function switchTab(tab) {
if (tab === 'activity') {
tabActivity.classList.add('border-[var(--accent)]', 'text-[var(--fg)]');
tabActivity.classList.remove('border-transparent', 'text-[var(--fg-muted)]');
tabConflicts.classList.remove('border-[var(--accent)]', 'text-[var(--fg)]');
tabConflicts.classList.add('border-transparent', 'text-[var(--fg-muted)]');
activityPanel.classList.remove('hidden');
conflictsPanel.classList.add('hidden');
} else {
tabConflicts.classList.add('border-[var(--accent)]', 'text-[var(--fg)]');
tabConflicts.classList.remove('border-transparent', 'text-[var(--fg-muted)]');
tabActivity.classList.remove('border-[var(--accent)]', 'text-[var(--fg)]');
tabActivity.classList.add('border-transparent', 'text-[var(--fg-muted)]');
conflictsPanel.classList.remove('hidden');
activityPanel.classList.add('hidden');
}
}
function restoreVersion(id) {
const version = versions.find(v => v.id === id);
if (version) {
alert(`Restoring version from ${version.date} by ${version.author}\n\nChanges: ${version.changes}`);
}
}
// ===== Simulated Real-time Behavior =====
function simulateCollaboration() {
// Randomly change collaborator status
setInterval(() => {
const randomUser = collaborators[Math.floor(Math.random() * (collaborators.length - 1)) + 1];
const statuses = ['viewing', 'typing', 'idle', 'editing'];
randomUser.status = statuses[Math.floor(Math.random() * statuses.length)];
renderPresenceAvatars();
renderTypingIndicator();
}, 3000);
}
// ===== Event Listeners =====
closeModalBtn.addEventListener('click', closeConflictModal);
conflictModal.addEventListener('click', (e) => {
if (e.target === conflictModal) closeConflictModal();
});
openVersionBtn.addEventListener('click', openVersionSidebar);
closeVersionBtn.addEventListener('click', closeVersionSidebar);
mobileOverlay.addEventListener('click', closeVersionSidebar);
tabActivity.addEventListener('click', () => switchTab('activity'));
tabConflicts.addEventListener('click', () => switchTab('conflicts'));
timeSlider.addEventListener('input', (e) => {
const versionIndex = parseInt(e.target.value);
const version = versions[versions.length - 1 - versionIndex];
if (version) {
document.getElementById('currentDate').textContent = version.date;
}
});
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
closeConflictModal();
closeVersionSidebar();
}
});
// ===== Initialize =====
function init() {
renderPresenceAvatars();
renderTypingIndicator();
renderEditorBlocks();
renderVersionTimeline();
renderActivityFeed();
renderConflicts();
// Start simulation
simulateCollaboration();
// Intersection Observer for scroll animations
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
}
});
}, { threshold: 0.1 });
document.querySelectorAll('.animate-slide-up').forEach(el => {
observer.observe(el);
});
}
init();
</script>
</body>
</html>
Key Design Decisions
Presence System
- Avatar Stack - Overlapping avatars with status indicators (pulsing dots for active editors)
- Real-time Cursors - Colored caret indicators showing exact edit positions
- Typing Indicators - Animated dots with user attribution in the status bar
- Hover Cards - Rich tooltips showing detailed presence info
Conflict Resolution
- Visual Diff View - Side-by-side comparison of conflicting versions
- Three-way Merge Options - Keep yours, accept theirs, or merge both
- Inline Indicators - Pink-highlighted regions with one-click resolution
- Conflict Counter Badge - Alert in header when conflicts exist
Version Storytelling
- Timeline Visualization - Connected nodes showing document evolution
- Significant Edit Markers - Labels for major vs. minor changes
- Time Travel Slider - Scrub through document history
- Author Attribution - Each version shows who made changes
Interactions
- Conflict Modal - Full resolution interface with merge options
- Version Restore - Click any timeline node to restore
- Tab Switching - Activity feed vs. conflicts panel
- Mobile Sidebar - Slide-out version history on mobile
- Simulated Real-time - Dynamic presence updates every 3 seconds