InfoItem.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { FlexWrapper } from "@ente/shared/components/Container";
  2. import Edit from "@mui/icons-material/Edit";
  3. import { Box, IconButton, Typography } from "@mui/material";
  4. import { SmallLoadingSpinner } from "../styledComponents/SmallLoadingSpinner";
  5. interface Iprops {
  6. icon: JSX.Element;
  7. title?: string;
  8. caption?: string | JSX.Element;
  9. openEditor?: any;
  10. loading?: boolean;
  11. hideEditOption?: any;
  12. customEndButton?: any;
  13. children?: any;
  14. }
  15. export default function InfoItem({
  16. icon,
  17. title,
  18. caption,
  19. openEditor,
  20. loading,
  21. hideEditOption,
  22. customEndButton,
  23. children,
  24. }: Iprops): JSX.Element {
  25. return (
  26. <FlexWrapper justifyContent="space-between">
  27. <Box display={"flex"} alignItems="flex-start" gap={0.5} pr={1}>
  28. <IconButton
  29. color="secondary"
  30. sx={{ "&&": { cursor: "default", m: 0.5 } }}
  31. disableRipple
  32. >
  33. {icon}
  34. </IconButton>
  35. <Box py={0.5}>
  36. {children ? (
  37. children
  38. ) : (
  39. <>
  40. <Typography sx={{ wordBreak: "break-all" }}>
  41. {title}
  42. </Typography>
  43. <Typography variant="small" color="text.muted">
  44. {caption}
  45. </Typography>
  46. </>
  47. )}
  48. </Box>
  49. </Box>
  50. {customEndButton
  51. ? customEndButton
  52. : !hideEditOption && (
  53. <IconButton onClick={openEditor} color="secondary">
  54. {!loading ? <Edit /> : <SmallLoadingSpinner />}
  55. </IconButton>
  56. )}
  57. </FlexWrapper>
  58. );
  59. }