setting-comp.tsx 882 B

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