robosats/frontend/src/App.tsx
Reckless_Satoshi 227610c84a
Add Nav Bar, Settings Page, large refactor (#308)
commit a5b63aed93
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Sun Oct 30 10:46:05 2022 -0700

    Small fixes

commit d64adfc2bf
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Sun Oct 30 06:02:06 2022 -0700

    wip work on federation settings

commit ca35d6b3d2
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Sun Oct 30 04:05:33 2022 -0700

    Refactor confirmation Dialogs

commit c660a5b0d1
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Sat Oct 29 13:36:59 2022 -0700

    refactor login (clean separation robot/info. Style navbar.

commit b9dc7f7c95
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Fri Oct 28 09:54:38 2022 -0700

    Add size slider and settings widget

commit 20b2b3dcd6
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Fri Oct 28 05:41:48 2022 -0700

    Add show more and Dialogs

commit da8b70091b
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Thu Oct 27 16:26:07 2022 -0700

    Add sliding pages

commit 6dd90aa118
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Thu Oct 27 06:34:58 2022 -0700

    Add settings forms

commit d3d0f3ee1a
Author: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Date:   Wed Oct 26 04:16:06 2022 -0700

    Refactor utils
2022-10-30 12:13:01 -07:00

75 lines
2.0 KiB
TypeScript

import React, { Suspense, useState, useEffect } from 'react';
import ReactDOM from 'react-dom/client';
import Main from './basic/Main';
import { CssBaseline } from '@mui/material';
import { ThemeProvider, createTheme, Theme } from '@mui/material/styles';
import UnsafeAlert from './components/UnsafeAlert';
import TorConnection from './components/TorConnection';
import { I18nextProvider } from 'react-i18next';
import i18n from './i18n/Web';
import { systemClient } from './services/System';
import { Settings, defaultSettings } from './models';
const defaultTheme: Theme = createTheme({
palette: {
mode: defaultSettings.mode,
background: {
default: defaultSettings.mode === 'dark' ? '#070707' : '#fff',
},
},
typography: { fontSize: defaultSettings.fontSize },
});
const App = (): JSX.Element => {
const [theme, setTheme] = useState<Theme>(defaultTheme);
const [settings, setSettings] = useState<Settings>(defaultSettings);
const updateTheme = function () {
setTheme(
createTheme({
palette: {
mode: settings.mode,
background: {
default: settings.mode === 'dark' ? '#070707' : '#fff',
},
},
typography: { fontSize: settings.fontSize },
}),
);
};
useEffect(() => {
updateTheme();
}, [settings.fontSize, settings.mode]);
useEffect(() => {
i18n.changeLanguage(settings.language);
}, []);
return (
<Suspense fallback='loading language'>
<I18nextProvider i18n={i18n}>
<ThemeProvider theme={theme}>
<CssBaseline />
<TorConnection />
<UnsafeAlert className='unsafeAlert' />
<Main settings={settings} setSettings={setSettings} />
</ThemeProvider>
</I18nextProvider>
</Suspense>
);
};
const loadApp = () => {
if (systemClient.loading) {
setTimeout(loadApp, 200);
} else {
const root = ReactDOM.createRoot(document.getElementById('app') ?? new HTMLElement());
root.render(<App />);
}
};
loadApp();