mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
refactor: ts path alias
This commit is contained in:
33
src/components/setting/mods/theme-mode-switch.tsx
Normal file
33
src/components/setting/mods/theme-mode-switch.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button, ButtonGroup } from "@mui/material";
|
||||
|
||||
type ThemeValue = CmdType.VergeConfig["theme_mode"];
|
||||
|
||||
interface Props {
|
||||
value?: ThemeValue;
|
||||
onChange?: (value: ThemeValue) => void;
|
||||
}
|
||||
|
||||
const ThemeModeSwitch = (props: Props) => {
|
||||
const { value, onChange } = props;
|
||||
const { t } = useTranslation();
|
||||
|
||||
const modes = ["light", "dark", "system"] as const;
|
||||
|
||||
return (
|
||||
<ButtonGroup size="small">
|
||||
{modes.map((mode) => (
|
||||
<Button
|
||||
key={mode}
|
||||
variant={mode === value ? "contained" : "outlined"}
|
||||
onClick={() => onChange?.(mode)}
|
||||
sx={{ textTransform: "capitalize" }}
|
||||
>
|
||||
{t(`theme.${mode}`)}
|
||||
</Button>
|
||||
))}
|
||||
</ButtonGroup>
|
||||
);
|
||||
};
|
||||
|
||||
export default ThemeModeSwitch;
|
||||
Reference in New Issue
Block a user