setting-comp.tsx 829 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from "react";
  2. import {
  3. Box,
  4. List,
  5. ListItem,
  6. ListItemText,
  7. ListSubheader,
  8. } from "@mui/material";
  9. interface ItemProps {
  10. label: React.ReactNode;
  11. extra?: React.ReactNode;
  12. }
  13. export const SettingItem: React.FC<ItemProps> = (props) => {
  14. const { label, extra, children } = props;
  15. const primary = !extra ? (
  16. label
  17. ) : (
  18. <Box sx={{ display: "flex", alignItems: "center" }}>
  19. <span>{label}</span>
  20. {extra}
  21. </Box>
  22. );
  23. return (
  24. <ListItem sx={{ pt: "5px", pb: "5px" }}>
  25. <ListItemText primary={primary} />
  26. {children}
  27. </ListItem>
  28. );
  29. };
  30. export const SettingList: React.FC<{ title: string }> = (props) => (
  31. <List>
  32. <ListSubheader sx={{ background: "transparent" }} disableSticky>
  33. {props.title}
  34. </ListSubheader>
  35. {props.children}
  36. </List>
  37. );