diff --git a/frontend/components/connections/HostCard.vue b/frontend/components/connections/HostCard.vue index 4dbb4c0..5ee5cd3 100644 --- a/frontend/components/connections/HostCard.vue +++ b/frontend/components/connections/HostCard.vue @@ -34,6 +34,36 @@ function formatLastConnected(ts: string | null): string { if (diffDays < 30) return `${diffDays}d ago` return d.toLocaleDateString() } + +function recencyClass(ts: string | null): string { + if (!ts) return 'text-gray-600' + const diffDays = Math.floor((Date.now() - new Date(ts).getTime()) / 86400000) + if (diffDays === 0) return 'text-emerald-400' + if (diffDays <= 7) return 'text-amber-400' + return 'text-gray-600' +} + +// Deterministic tag color from string hash +const TAG_COLORS = [ + 'bg-teal-900/40 text-teal-300 border-teal-700/50', + 'bg-amber-900/40 text-amber-300 border-amber-700/50', + 'bg-violet-900/40 text-violet-300 border-violet-700/50', + 'bg-rose-900/40 text-rose-300 border-rose-700/50', + 'bg-emerald-900/40 text-emerald-300 border-emerald-700/50', + 'bg-sky-900/40 text-sky-300 border-sky-700/50', + 'bg-orange-900/40 text-orange-300 border-orange-700/50', + 'bg-indigo-900/40 text-indigo-300 border-indigo-700/50', +] + +function tagColor(tag: string): string { + let hash = 0 + for (let i = 0; i < tag.length; i++) hash = ((hash << 5) - hash + tag.charCodeAt(i)) | 0 + return TAG_COLORS[Math.abs(hash) % TAG_COLORS.length] +} + +function defaultStrip(protocol: string): string { + return protocol === 'rdp' ? '#a855f7' : '#5c7cfa' +}