diff --git a/apps/web/src/lib/components/chat/ChatList.svelte b/apps/web/src/lib/components/chat/ChatList.svelte index 23fea2b..625d8ab 100644 --- a/apps/web/src/lib/components/chat/ChatList.svelte +++ b/apps/web/src/lib/components/chat/ChatList.svelte @@ -9,6 +9,7 @@ import NewConversationModal from './NewConversationModal.svelte'; import { Search, Plus, MessageSquare, Users, UsersRound } from 'lucide-svelte'; import type { Id, Doc } from '@sgse-app/backend/convex/_generated/dataModel'; + import { obterCoresDoTema } from '$lib/utils/temas'; const client = useConvexClient(); @@ -23,6 +24,57 @@ let searchQuery = $state(''); let activeTab = $state<'usuarios' | 'conversas'>('usuarios'); + + // Obter cores do tema atual (reativo) + let coresTema = $state(obterCoresDoTema()); + + // Atualizar cores quando o tema mudar + $effect(() => { + if (typeof window === 'undefined') return; + + const atualizarCores = () => { + coresTema = obterCoresDoTema(); + }; + + atualizarCores(); + + window.addEventListener('themechange', atualizarCores); + + const observer = new MutationObserver(atualizarCores); + const htmlElement = document.documentElement; + observer.observe(htmlElement, { + attributes: true, + attributeFilter: ['data-theme'] + }); + + return () => { + window.removeEventListener('themechange', atualizarCores); + observer.disconnect(); + }; + }); + + // Função para obter rgba da cor primária + function obterPrimariaRgba(alpha: number = 1) { + const primary = coresTema.primary; + if (primary.startsWith('rgba')) { + const match = primary.match(/rgba?\(([^)]+)\)/); + if (match) { + const values = match[1].split(','); + return `rgba(${values[0]}, ${values[1]}, ${values[2]}, ${alpha})`; + } + } + if (primary.startsWith('#')) { + const hex = primary.replace('#', ''); + const r = parseInt(hex.substring(0, 2), 16); + const g = parseInt(hex.substring(2, 4), 16); + const b = parseInt(hex.substring(4, 6), 16); + return `rgba(${r}, ${g}, ${b}, ${alpha})`; + } + if (primary.startsWith('hsl')) { + return primary.replace(/\)$/, `, ${alpha})`).replace('hsl', 'hsla'); + } + return `rgba(102, 126, 234, ${alpha})`; + } // Debug: monitorar carregamento de dados $effect(() => { @@ -263,7 +315,7 @@
@@ -1366,7 +1449,7 @@
{notificationMsg.conteudo}
-Clique para abrir
+Clique para abrir