Files
clash-proxy/src/components/setting/mods/setting-comp.tsx

49 lines
940 B
TypeScript
Raw Normal View History

import React, { ReactNode } from "react";
2022-08-06 03:48:03 +08:00
import {
Box,
List,
ListItem,
ListItemText,
ListSubheader,
} from "@mui/material";
2022-01-16 03:22:37 +08:00
2022-08-06 03:48:03 +08:00
interface ItemProps {
label: ReactNode;
extra?: ReactNode;
children?: ReactNode;
secondary?: ReactNode;
2022-08-06 03:48:03 +08:00
}
export const SettingItem: React.FC<ItemProps> = (props) => {
const { label, extra, children, secondary } = props;
2022-08-06 03:48:03 +08:00
const primary = !extra ? (
label
) : (
<Box sx={{ display: "flex", alignItems: "center" }}>
2022-11-23 17:42:01 +08:00
<span>{label}</span>
2022-08-06 03:48:03 +08:00
{extra}
</Box>
);
return (
<ListItem sx={{ pt: "5px", pb: "5px" }}>
<ListItemText primary={primary} secondary={secondary} />
2022-08-06 03:48:03 +08:00
{children}
</ListItem>
);
};
2022-01-16 03:22:37 +08:00
export const SettingList: React.FC<{
title: string;
children: ReactNode;
}> = (props) => (
2022-01-16 03:22:37 +08:00
<List>
<ListSubheader sx={{ background: "transparent" }} disableSticky>
{props.title}
</ListSubheader>
{props.children}
</List>
);