Rect.jsx 890 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React, { memo } from "react";
  2. import styled, { css } from "styled-components";
  3. const StyledShape = styled.div`
  4. ${({ width, height, color }) => css`
  5. width: ${width}px;
  6. height: ${height}px;*
  7. box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px,
  8. rgba(60, 64, 67, 0.15) 0px 1px 3px 1px;
  9. background-color: ${color};
  10. display: flex;
  11. justify-content: center;
  12. align-items: center;
  13. & span {
  14. z-index: 0;
  15. }
  16. `}
  17. `;
  18. const Rect = ({
  19. width = 50,
  20. height = 50,
  21. color = "#ccc",
  22. text = "",
  23. textColor = "#000",
  24. fontSize = "16",
  25. }) => {
  26. return (
  27. <StyledShape width={width} height={height} color={color}>
  28. {text && (
  29. <span
  30. style={{
  31. textColor,
  32. fontSize: fontSize + "px",
  33. }}
  34. >
  35. {text}
  36. </span>
  37. )}
  38. </StyledShape>
  39. );
  40. };
  41. export default memo(Rect);