mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-10 16:21:36 +00:00
Refactor ordering of constructing theme
This commit is contained in:
parent
8108c4146b
commit
eb923b4e6f
@ -12,23 +12,8 @@ import i18n from './i18n/Web';
|
||||
import { systemClient } from './services/System';
|
||||
import { Settings } from './models';
|
||||
|
||||
const defaultTheme: Theme = createTheme({
|
||||
palette: {
|
||||
mode: new Settings().mode,
|
||||
background: {
|
||||
default: new Settings().mode === 'dark' ? '#070707' : '#fff',
|
||||
},
|
||||
},
|
||||
typography: { fontSize: new Settings().fontSize },
|
||||
});
|
||||
|
||||
const App = (): JSX.Element => {
|
||||
const [theme, setTheme] = useState<Theme>(defaultTheme);
|
||||
const [settings, setSettings] = useState<Settings>(new Settings());
|
||||
|
||||
const updateTheme = function () {
|
||||
setTheme(
|
||||
createTheme({
|
||||
const makeTheme = function (settings: Settings) {
|
||||
const theme: Theme = createTheme({
|
||||
palette: {
|
||||
mode: settings.mode,
|
||||
background: {
|
||||
@ -36,12 +21,17 @@ const App = (): JSX.Element => {
|
||||
},
|
||||
},
|
||||
typography: { fontSize: settings.fontSize },
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
return theme;
|
||||
};
|
||||
|
||||
const App = (): JSX.Element => {
|
||||
const [theme, setTheme] = useState<Theme>(makeTheme(new Settings()));
|
||||
const [settings, setSettings] = useState<Settings>(new Settings());
|
||||
|
||||
useEffect(() => {
|
||||
updateTheme();
|
||||
setTheme(makeTheme(settings));
|
||||
}, [settings.fontSize, settings.mode]);
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user