From 4cbfe7c5fe87bee99d04c8d9cac52c558a0b335a Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 3 Dec 2021 01:19:00 +0100 Subject: [PATCH] move thememodule init to react land --- .../src/lib/remix-ui-theme-module.tsx | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/libs/remix-ui/theme-module/src/lib/remix-ui-theme-module.tsx b/libs/remix-ui/theme-module/src/lib/remix-ui-theme-module.tsx index 734a524d49..cf79d113e7 100644 --- a/libs/remix-ui/theme-module/src/lib/remix-ui-theme-module.tsx +++ b/libs/remix-ui/theme-module/src/lib/remix-ui-theme-module.tsx @@ -10,6 +10,7 @@ export interface RemixUiThemeModuleProps { export function RemixUiThemeModule({ themeModule }: RemixUiThemeModuleProps) { const [themeName, setThemeName] = useState('') + const themeRef = useRef(null) useEffect(() => { themeModule.switchTheme() @@ -20,22 +21,27 @@ export function RemixUiThemeModule({ themeModule }: RemixUiThemeModuleProps) { const linkRef = useRef(null) function initTheme (callback: () => void) { // const theme = yo`` - if (themeModule.active) { - setNextTheme(themeModule.themes[themeModule.active]) // Theme - document.documentElement.style.setProperty('--theme', nextTheme.quality) + if (themeModule.active) { + setNextTheme(themeModule.themes[themeModule.active]) // Theme + document.documentElement.style.setProperty('--theme', nextTheme.quality) + } } - } - useEffect(() => { - const callback = () => { - setTimeout(() => { - document.body.removeChild(self._view.splashScreen) - self._view.el.style.visibility = 'visible' - }, 1500) - addEventListener('load', () => { + useEffect(() => { + const shell = document.querySelector('div[data-id="remixIDE"]') as any + const splashScreen = document.querySelector('div[data-id="remixIDESplash"]') as Node + const callback = () => { + // setTimeout(() => { + // document.body.removeChild(splashScreen) + // // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + // shell!.style.visibility = 'visible' + // }, 1500) + } + document.addEventListener('load', () => { if (callback) callback() }) document.head.insertBefore(linkRef.current, document.head.firstChild) - }, []) + }, []) + return ( )