diff --git a/src/components/DockviewLayoutManager.tsx b/src/components/DockviewLayoutManager.tsx index 681e809..cf4b8ec 100644 --- a/src/components/DockviewLayoutManager.tsx +++ b/src/components/DockviewLayoutManager.tsx @@ -1,10 +1,10 @@ -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useRef, useState, useMemo } from 'react'; import { DockviewReact, DockviewReadyEvent, DockviewApi, - themeAbyss, themeLight, + themeDark, } from 'dockview'; import { useMantineColorScheme, useComputedColorScheme } from '@mantine/core'; import { useDockviewStore } from '../stores/useDockviewStore'; @@ -23,6 +23,24 @@ export function DockviewLayoutManager() { getInitialValueInEffect: true, }); + // 🧱 Layout por defecto + const createDefaultLayout = (api: DockviewApi) => { + // ✅ El primer panel no debe tener "position" + api.addPanel({ + id: 'welcome', + component: 'welcome', + title: 'Bienvenido', + }); + + // ✅ Los siguientes sí pueden usar dirección + api.addPanel({ + id: 'toggle', + component: 'toggle', + title: 'Cambiar tema', + position: { direction: 'right' }, + }); + }; + // ⚡ Inicializa Dockview al estar listo const onReady = (event: DockviewReadyEvent) => { const api = event.api; @@ -46,41 +64,17 @@ export function DockviewLayoutManager() { }); }; - // 🌗 Sincroniza Dockview con el tema de Mantine automáticamente - useEffect(() => { - const el = hostRef.current; - if (!el) return; + // 🌗 Determina el tema actual y aplica estilos personalizados + const isDark = computedScheme === 'dark'; + const dockviewTheme = isDark ? themeDark : themeLight; - // Remueve las clases anteriores - el.classList.remove('dockview-theme-dark', 'dockview-theme-light'); - - // Aplica el tema adecuado - const isDark = computedScheme === 'dark'; - el.classList.add(isDark ? 'dockview-theme-dark' : 'dockview-theme-light'); - el.style.backgroundColor = isDark ? '#1A1B1E' : '#f5f6f7'; - }, [computedScheme]); - - // 🧱 Layout inicial por defecto - const createDefaultLayout = (api: DockviewApi) => { - const welcome = api.addPanel({ - id: 'welcome', - component: 'welcome', - title: 'Welcome', - }); - - api.addPanel({ - id: 'toggle', - component: 'toggle', - title: 'Theme', - position: { - referencePanel: welcome, - direction: 'right', - }, - }); - }; - - // ⚙️ Tema de Dockview sincronizado con Mantine - const dockviewTheme = computedScheme === 'dark' ? themeAbyss : themeLight; + // 🎨 Personalización Dockview mediante variables CSS + const dockviewCustomTheme = useMemo(() => { + const baseTheme = isDark ? themeDark : themeLight; + return { + ...baseTheme, + }; + }, [isDark]); return (