AvatarStub.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from "react";
  2. const r = () => Math.floor(Math.random() * 256);
  3. const g = () => Math.floor(Math.random() * 256);
  4. const b = () => Math.floor(Math.random() * 256);
  5. export const color = () => {
  6. return "#" + r().toString(16) + g().toString(16) + b().toString(16);
  7. };
  8. export const AvatarStub = (props) => {
  9. return (
  10. <div className="stubAvatar" style={{ backgroundColor: props.color }}>
  11. <p className="chatAvatarText" >
  12. {props.login
  13. .split(" ")
  14. .map(function (item) {
  15. return item[0];
  16. })
  17. .join("")}
  18. </p>
  19. </div>
  20. );
  21. };
  22. export const AvatarStubHeader = (props) => {
  23. return (
  24. <div
  25. className="stubAvatarHeader"
  26. style={{ backgroundColor: props.color }}
  27. >
  28. {/* <p className="chatAvatarTextHeader">
  29. {props?.login
  30. .split(" ")
  31. .map(function (item) {
  32. return item[0];
  33. })
  34. .join("")}
  35. </p> */}
  36. </div>
  37. );
  38. };