UserList.js 814 B

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