UserList.js 845 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import UserPicture from '../User/UserPicture';
  4. export default class UserList extends React.Component {
  5. isSeenUserListShown() {
  6. const userCount = this.props.users.length;
  7. if (0 < userCount && userCount <= 10) {
  8. return true;
  9. }
  10. return false;
  11. }
  12. render() {
  13. if (!this.isSeenUserListShown()) {
  14. return null;
  15. }
  16. const users = this.props.users.map((user) => {
  17. return (
  18. <a key={user._id} data-user-id={user._id} href={'/user/' + user.username} title={user.name}>
  19. <UserPicture user={user} size="xs" />
  20. </a>
  21. );
  22. });
  23. return (
  24. <p className="seen-user-list">
  25. {users}
  26. </p>
  27. );
  28. }
  29. }
  30. UserList.propTypes = {
  31. users: PropTypes.array,
  32. };
  33. UserList.defaultProps = {
  34. users: [],
  35. };