UserCircle.jsx 946 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import React from "react";
  2. import styled from "styled-components";
  3. const StyledUserCircle = styled.div`
  4. background-color: ${({ color }) => color};
  5. width: 38px;
  6. min-width: 38px;
  7. height: 38px;
  8. margin: 2px;
  9. border-radius: 100%;
  10. text-align: center;
  11. line-height: 38px;
  12. text-transform: capitalize;
  13. ${({ isSelf }) => (isSelf ? "text-decoration: underline;" : "")};
  14. ${({ isSelf }) =>
  15. isSelf ? "border: 3px solid #777; line-height: 32px;" : ""};
  16. cursor: ${({ isSelf }) => (isSelf ? "pointer" : "default")};
  17. &:hover {
  18. ${({ isSelf }) => (isSelf ? "filter: brightness(125%);" : "")}
  19. }
  20. @media screen and (max-width: 640px) {
  21. & {
  22. font-size: 0.5em;
  23. width: 20px;
  24. height: 20px;
  25. line-height: 20px;
  26. }
  27. }
  28. `;
  29. const UserCircle = ({ name, ...rest }) => {
  30. let pre = name.slice(0, 2).toLowerCase();
  31. return <StyledUserCircle {...rest}>{pre}</StyledUserCircle>;
  32. };
  33. export default UserCircle;