Round.jsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React, { memo } from "react";
  2. import styled, { css } from "styled-components";
  3. const StyledRound = styled.div`
  4. ${({ radius = 50 }) => css`
  5. border-radius: 100%;
  6. width: ${radius}px;
  7. height: ${radius}px;
  8. display: flex;
  9. align-items: center;
  10. justify-content: center;
  11. box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px,
  12. rgba(60, 64, 67, 0.15) 0px 1px 3px 1px;
  13. display: flex;
  14. justify-content: center;
  15. align-items: center;
  16. position: relative;
  17. & svg {
  18. position: absolute;
  19. top: 0;
  20. left: 0;
  21. right: 0;
  22. bottom: 0;
  23. }
  24. & span {
  25. z-index: 0;
  26. }
  27. `}
  28. `;
  29. const Round = ({
  30. size,
  31. radius = size,
  32. color = "#ccc",
  33. text = "",
  34. textColor = "#000",
  35. fontSize = "16",
  36. }) => {
  37. return (
  38. <StyledRound radius={radius}>
  39. <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  40. <circle
  41. cx="50"
  42. cy="50"
  43. r="50"
  44. style={{
  45. fill: color,
  46. }}
  47. />
  48. </svg>
  49. {text && (
  50. <span
  51. style={{
  52. color: textColor,
  53. fontSize: fontSize + "px",
  54. }}
  55. >
  56. {text}
  57. </span>
  58. )}
  59. </StyledRound>
  60. );
  61. };
  62. export default memo(Round);