CaptionedText.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { VerticallyCenteredFlex } from "@ente/shared/components/Container";
  2. import { ButtonProps, Typography } from "@mui/material";
  3. interface Iprops {
  4. mainText: string;
  5. subText?: string;
  6. subIcon?: React.ReactNode;
  7. color?: ButtonProps["color"];
  8. }
  9. const getSubTextColor = (color: ButtonProps["color"]) => {
  10. switch (color) {
  11. case "critical":
  12. return "critical.main";
  13. default:
  14. return "text.faint";
  15. }
  16. };
  17. export const CaptionedText = (props: Iprops) => {
  18. return (
  19. <VerticallyCenteredFlex gap={"4px"}>
  20. <Typography> {props.mainText}</Typography>
  21. <Typography variant="small" color={getSubTextColor(props.color)}>
  22. {"•"}
  23. </Typography>
  24. {props.subText ? (
  25. <Typography
  26. variant="small"
  27. color={getSubTextColor(props.color)}
  28. >
  29. {props.subText}
  30. </Typography>
  31. ) : (
  32. <Typography
  33. variant="small"
  34. color={getSubTextColor(props.color)}
  35. >
  36. {props.subIcon}
  37. </Typography>
  38. )}
  39. </VerticallyCenteredFlex>
  40. );
  41. };