mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-26 11:56:27 -08:00
42 lines
950 B
TypeScript
42 lines
950 B
TypeScript
import { useLayoutEffect } from 'react';
|
|
import { useConfig } from './hooks/config';
|
|
import { Outlet, useNavigate } from 'react-router-dom';
|
|
|
|
export function AppLayout() {
|
|
const { config } = useConfig();
|
|
const navigate = useNavigate();
|
|
|
|
useLayoutEffect(() => {
|
|
if (!config) return;
|
|
if (config.theme !== undefined) {
|
|
document.documentElement.dataset.theme = config.theme;
|
|
}
|
|
|
|
if (config.fonts !== undefined) {
|
|
document.documentElement.style.setProperty(
|
|
'--font-name',
|
|
config.fonts.map((x) => `"${x}"`).join(',')
|
|
);
|
|
}
|
|
|
|
if (config.textSize !== undefined) {
|
|
document.documentElement.style.setProperty(
|
|
'--font-size',
|
|
`${config.textSize}rem`
|
|
);
|
|
}
|
|
}, [config]);
|
|
|
|
useLayoutEffect(() => {
|
|
if (config && !config.doneOnboarding) {
|
|
navigate('/onboarding/home');
|
|
}
|
|
}, [config?.doneOnboarding]);
|
|
|
|
return (
|
|
<>
|
|
<Outlet />
|
|
</>
|
|
);
|
|
}
|