User Settings: move darker dark mode to theme

This commit is contained in:
Sidney Alcantara
2021-10-18 17:34:14 +11:00
parent 1dac3c889b
commit d4d16d164b
3 changed files with 54 additions and 42 deletions

View File

@@ -29,23 +29,6 @@ export default function Personalization({
return (
<>
<FormControlLabel
control={
<Checkbox
checked={settings.theme?.dark?.palette?.darker}
onChange={(e) => {
updateSettings({
theme: _merge(settings.theme, {
dark: { palette: { darker: e.target.checked } },
}),
});
}}
/>
}
label="Darker dark theme"
sx={{ my: -10 / 8 }}
/>
<FormControlLabel
control={
<Checkbox
@@ -62,7 +45,7 @@ export default function Personalization({
/>
}
label="Customize theme colors"
style={{ marginLeft: -11, marginBottom: -10 }}
style={{ marginLeft: -11, marginBottom: -10, marginTop: -10 }}
/>
<Collapse in={customizedThemeColor} style={{ marginTop: 0 }}>

View File

@@ -1,39 +1,68 @@
import { IUserSettingsChildProps } from "pages/Settings/UserSettings";
import _merge from "lodash/merge";
import {
FormControl,
RadioGroup,
FormControlLabel,
Radio,
Divider,
Checkbox,
} from "@mui/material";
import { useAppContext } from "contexts/AppContext";
export default function Theme() {
export default function Theme({
settings,
updateSettings,
}: IUserSettingsChildProps) {
const { theme, themeOverridden, setTheme, setThemeOverridden } =
useAppContext();
return (
<FormControl component="fieldset" variant="standard" sx={{ my: -10 / 8 }}>
<legend style={{ fontSize: 0 }}>Theme</legend>
<>
<FormControl component="fieldset" variant="standard" sx={{ my: -10 / 8 }}>
<legend style={{ fontSize: 0 }}>Theme</legend>
<RadioGroup
value={themeOverridden ? theme : "system"}
onChange={(e) => {
if (e.target.value === "system") {
setThemeOverridden(false);
} else {
setTheme(e.target.value as typeof theme);
setThemeOverridden(true);
}
}}
>
<FormControlLabel
control={<Radio />}
value="system"
label="Match system theme"
/>
<FormControlLabel control={<Radio />} value="light" label="Light" />
<FormControlLabel control={<Radio />} value="dark" label="Dark" />
</RadioGroup>
</FormControl>
<RadioGroup
value={themeOverridden ? theme : "system"}
onChange={(e) => {
if (e.target.value === "system") {
setThemeOverridden(false);
} else {
setTheme(e.target.value as typeof theme);
setThemeOverridden(true);
}
}}
>
<FormControlLabel
control={<Radio />}
value="system"
label="Match system theme"
/>
<FormControlLabel control={<Radio />} value="light" label="Light" />
<FormControlLabel control={<Radio />} value="dark" label="Dark" />
</RadioGroup>
</FormControl>
<Divider />
<FormControlLabel
control={
<Checkbox
checked={settings.theme?.dark?.palette?.darker}
onChange={(e) => {
updateSettings({
theme: _merge(settings.theme, {
dark: { palette: { darker: e.target.checked } },
}),
});
}}
/>
}
label="Darker dark theme"
style={{ marginLeft: -11, marginBottom: -10, marginTop: 13 }}
/>
</>
);
}

View File

@@ -48,7 +48,7 @@ export default function UserSettingsPage() {
const sections = [
{ title: "Account", Component: Account, props: childProps },
{ title: "Theme", Component: Theme },
{ title: "Theme", Component: Theme, props: childProps },
{ title: "Personalization", Component: Personalization, props: childProps },
];