~cytrogen/masto-fe

ref: 8f66126b1010e0aaaa8b5f2a2f4ea8a28824e2b7 masto-fe/app/javascript/mastodon/features/picture_in_picture/components/header.jsx -rw-r--r-- 1.5 KiB
8f66126b — Renaud Chaput Use the new JSX transform (#25064) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { connect } from 'react-redux';
import ImmutablePureComponent from 'react-immutable-pure-component';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { IconButton } from 'mastodon/components/icon_button';
import { Link } from 'react-router-dom';
import { Avatar } from 'mastodon/components/avatar';
import { DisplayName } from 'mastodon/components/display_name';
import { defineMessages, injectIntl } from 'react-intl';

const messages = defineMessages({
  close: { id: 'lightbox.close', defaultMessage: 'Close' },
});

const mapStateToProps = (state, { accountId }) => ({
  account: state.getIn(['accounts', accountId]),
});

class Header extends ImmutablePureComponent {

  static propTypes = {
    accountId: PropTypes.string.isRequired,
    statusId: PropTypes.string.isRequired,
    account: ImmutablePropTypes.map.isRequired,
    onClose: PropTypes.func.isRequired,
    intl: PropTypes.object.isRequired,
  };

  render () {
    const { account, statusId, onClose, intl } = this.props;

    return (
      <div className='picture-in-picture__header'>
        <Link to={`/@${account.get('acct')}/${statusId}`} className='picture-in-picture__header__account'>
          <Avatar account={account} size={36} />
          <DisplayName account={account} />
        </Link>

        <IconButton icon='times' onClick={onClose} title={intl.formatMessage(messages.close)} />
      </div>
    );
  }

}

export default connect(mapStateToProps)(injectIntl(Header));