Titlebar.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { FlexWrapper } from "@ente/shared/components/Container";
  2. import ArrowBack from "@mui/icons-material/ArrowBack";
  3. import Close from "@mui/icons-material/Close";
  4. import { Box, IconButton, Typography } from "@mui/material";
  5. interface Iprops {
  6. title: string;
  7. caption?: string;
  8. onClose: () => void;
  9. backIsClose?: boolean;
  10. onRootClose?: () => void;
  11. actionButton?: JSX.Element;
  12. }
  13. export default function Titlebar({
  14. title,
  15. caption,
  16. onClose,
  17. backIsClose,
  18. actionButton,
  19. onRootClose,
  20. }: Iprops): JSX.Element {
  21. return (
  22. <>
  23. <FlexWrapper
  24. height={48}
  25. alignItems={"center"}
  26. justifyContent="space-between"
  27. >
  28. <IconButton
  29. onClick={onClose}
  30. color={backIsClose ? "secondary" : "primary"}
  31. >
  32. {backIsClose ? <Close /> : <ArrowBack />}
  33. </IconButton>
  34. <Box display={"flex"} gap="4px">
  35. {actionButton && actionButton}
  36. {!backIsClose && (
  37. <IconButton onClick={onRootClose} color={"secondary"}>
  38. <Close />
  39. </IconButton>
  40. )}
  41. </Box>
  42. </FlexWrapper>
  43. <Box py={0.5} px={2}>
  44. <Typography variant="h3" fontWeight={"bold"}>
  45. {title}
  46. </Typography>
  47. <Typography
  48. variant="small"
  49. color="text.muted"
  50. sx={{ wordBreak: "break-all", minHeight: "17px" }}
  51. >
  52. {caption}
  53. </Typography>
  54. </Box>
  55. </>
  56. );
  57. }