The code powering m.abunchtell.com https://m.abunchtell.com
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

92 wiersze
3.9 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import emojify from '../../../emoji';
  4. import escapeTextContentForBrowser from 'escape-html';
  5. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  6. import IconButton from '../../../components/icon_button';
  7. const messages = defineMessages({
  8. unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
  9. follow: { id: 'account.follow', defaultMessage: 'Follow' },
  10. requested: { id: 'account.requested', defaultMessage: 'Awaiting approval' }
  11. });
  12. const Header = React.createClass({
  13. propTypes: {
  14. account: ImmutablePropTypes.map,
  15. me: React.PropTypes.number.isRequired,
  16. onFollow: React.PropTypes.func.isRequired,
  17. intl: React.PropTypes.object.isRequired
  18. },
  19. mixins: [PureRenderMixin],
  20. render () {
  21. const { account, me, intl } = this.props;
  22. if (!account) {
  23. return null;
  24. }
  25. let displayName = account.get('display_name');
  26. let info = '';
  27. let actionBtn = '';
  28. let lockedIcon = '';
  29. if (displayName.length === 0) {
  30. displayName = account.get('username');
  31. }
  32. if (me !== account.get('id') && account.getIn(['relationship', 'followed_by'])) {
  33. info = <span className='account--follows-info' style={{ position: 'absolute', top: '10px', right: '10px', opacity: '0.7', display: 'inline-block', verticalAlign: 'top', background: 'rgba(0, 0, 0, 0.4)', textTransform: 'uppercase', fontSize: '11px', fontWeight: '500', padding: '4px', borderRadius: '4px' }}><FormattedMessage id='account.follows_you' defaultMessage='Follows you' /></span>
  34. }
  35. if (me !== account.get('id')) {
  36. if (account.getIn(['relationship', 'requested'])) {
  37. actionBtn = (
  38. <div style={{ position: 'absolute', top: '10px', left: '20px' }}>
  39. <IconButton size={26} disabled={true} icon='hourglass' title={intl.formatMessage(messages.requested)} />
  40. </div>
  41. );
  42. } else if (!account.getIn(['relationship', 'blocking'])) {
  43. actionBtn = (
  44. <div style={{ position: 'absolute', top: '10px', left: '20px' }}>
  45. <IconButton size={26} icon={account.getIn(['relationship', 'following']) ? 'user-times' : 'user-plus'} active={account.getIn(['relationship', 'following'])} title={intl.formatMessage(account.getIn(['relationship', 'following']) ? messages.unfollow : messages.follow)} onClick={this.props.onFollow} />
  46. </div>
  47. );
  48. }
  49. }
  50. if (account.get('locked')) {
  51. lockedIcon = <i className='fa fa-lock' />;
  52. }
  53. const content = { __html: emojify(account.get('note')) };
  54. const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
  55. return (
  56. <div className='account__header' style={{ backgroundImage: `url(${account.get('header')})` }}>
  57. <div style={{ padding: '20px 10px' }}>
  58. <a href={account.get('url')} target='_blank' rel='noopener' style={{ display: 'block', color: 'inherit', textDecoration: 'none' }}>
  59. <div className='account__header__avatar' style={{ width: '90px', margin: '0 auto', marginBottom: '10px' }}>
  60. <img src={account.get('avatar')} alt='' style={{ display: 'block', width: '90px', height: '90px', borderRadius: '90px' }} />
  61. </div>
  62. <span style={{ display: 'inline-block', fontSize: '20px', lineHeight: '27px', fontWeight: '500' }} className='account__header__display-name' dangerouslySetInnerHTML={displayNameHTML} />
  63. </a>
  64. <span className='account__header__username' style={{ fontSize: '14px', fontWeight: '400', display: 'block', marginBottom: '10px' }}>@{account.get('acct')} {lockedIcon}</span>
  65. <div style={{ fontSize: '14px' }} className='account__header__content' dangerouslySetInnerHTML={content} />
  66. {info}
  67. {actionBtn}
  68. </div>
  69. </div>
  70. );
  71. }
  72. });
  73. export default injectIntl(Header);