inline_account.jsx 866 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { PureComponent } from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import { connect } from 'react-redux';
  4. import { Avatar } from 'mastodon/components/avatar';
  5. import { makeGetAccount } from 'mastodon/selectors';
  6. const makeMapStateToProps = () => {
  7. const getAccount = makeGetAccount();
  8. const mapStateToProps = (state, { accountId }) => ({
  9. account: getAccount(state, accountId),
  10. });
  11. return mapStateToProps;
  12. };
  13. class InlineAccount extends PureComponent {
  14. static propTypes = {
  15. account: ImmutablePropTypes.record.isRequired,
  16. };
  17. render () {
  18. const { account } = this.props;
  19. return (
  20. <span className='inline-account'>
  21. <Avatar size={13} account={account} /> <strong>{account.get('username')}</strong>
  22. </span>
  23. );
  24. }
  25. }
  26. export default connect(makeMapStateToProps)(InlineAccount);