Token.jsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React from "react";
  2. import { darken } from "color2k";
  3. import styled, { css } from "styled-components";
  4. const StyledShape = styled.div`
  5. ${({ size }) => css`
  6. width: ${size}px;
  7. height: ${size}px;
  8. perspective: 300px;
  9. display: flex;
  10. justify-content: center;
  11. align-items: center;
  12. position: relative;
  13. & svg {
  14. position: absolute;
  15. top: 0;
  16. left: 0;
  17. right: 0;
  18. bottom: 0;
  19. }
  20. & span {
  21. transform: rotateX(25deg);
  22. padding-bottom: 0.2em;
  23. }
  24. `}
  25. `;
  26. const Token = ({
  27. size = 50,
  28. color = "#b3b3b3",
  29. text = "",
  30. textColor = "#000",
  31. fontSize = 24,
  32. }) => {
  33. const colorDarken1 = darken(color, 0.25);
  34. return (
  35. <StyledShape size={size}>
  36. <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  37. <ellipse
  38. ry="40"
  39. rx="49"
  40. cy="55"
  41. cx="50"
  42. id="ellipse2137"
  43. fill={colorDarken1}
  44. />
  45. <ellipse
  46. ry="40"
  47. rx="50"
  48. cy="45"
  49. cx="50"
  50. id="ellipse2139"
  51. fill={color}
  52. />
  53. </svg>
  54. {text && (
  55. <span
  56. style={{
  57. color: textColor,
  58. fontSize: fontSize + "px",
  59. }}
  60. >
  61. {text}
  62. </span>
  63. )}
  64. </StyledShape>
  65. );
  66. };
  67. export default Token;