ReserveIcons.jsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import * as React from "react";
  2. import { Lock, Public } from "@mui/icons-material";
  3. import { Box } from "@mui/material";
  4. export const PermissionReadWrite = React.forwardRef((props, ref) => <PermissionInternal icon={Public} ref={ref} {...props} />);
  5. export const PermissionDenyAll = React.forwardRef((props, ref) => <PermissionInternal icon={Lock} ref={ref} {...props} />);
  6. export const PermissionRead = React.forwardRef((props, ref) => <PermissionInternal icon={Public} text="R" ref={ref} {...props} />);
  7. export const PermissionWrite = React.forwardRef((props, ref) => <PermissionInternal icon={Public} text="W" ref={ref} {...props} />);
  8. const PermissionInternal = React.forwardRef((props, ref) => {
  9. const size = props.size ?? "medium";
  10. const Icon = props.icon;
  11. return (
  12. <Box
  13. ref={ref}
  14. {...props}
  15. style={{
  16. position: "relative",
  17. display: "inline-flex",
  18. verticalAlign: "middle",
  19. height: "24px",
  20. }}
  21. >
  22. <Icon fontSize={size} sx={{ color: "gray" }} />
  23. {props.text && (
  24. <Box
  25. sx={{
  26. position: "absolute",
  27. right: "-6px",
  28. bottom: "5px",
  29. fontSize: 10,
  30. fontWeight: 600,
  31. color: "gray",
  32. width: "8px",
  33. height: "8px",
  34. marginTop: "3px",
  35. }}
  36. >
  37. {props.text}
  38. </Box>
  39. )}
  40. </Box>
  41. );
  42. });