AvatarStub.js 553 B

12345678910111213141516
  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">{((props.login).split(' ').map(function(item){return item[0]}).join(''))}</p>
  12. </div>
  13. );
  14. };