]>
cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/account/components/header.js
1 import React
from 'react';
2 import ImmutablePropTypes
from 'react-immutable-proptypes';
3 import PropTypes
from 'prop-types';
4 import { defineMessages
, injectIntl
, FormattedMessage
} from 'react-intl';
5 import IconButton
from '../../../components/icon_button';
6 import Motion
from '../../ui/util/optional_motion';
7 import spring
from 'react-motion/lib/spring';
8 import ImmutablePureComponent
from 'react-immutable-pure-component';
9 import { autoPlayGif
, me
} from '../../../initial_state';
11 const messages
= defineMessages({
12 unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
13 follow: { id: 'account.follow', defaultMessage: 'Follow' },
14 requested: { id: 'account.requested', defaultMessage: 'Awaiting approval. Click to cancel follow request' },
17 class Avatar
extends ImmutablePureComponent
{
20 account: ImmutablePropTypes
.map
.isRequired
,
27 handleMouseOver
= () => {
28 if (this.state
.isHovered
) return;
29 this.setState({ isHovered: true });
32 handleMouseOut
= () => {
33 if (!this.state
.isHovered
) return;
34 this.setState({ isHovered: false });
38 const { account
} = this.props
;
39 const { isHovered
} = this.state
;
42 <Motion defaultStyle
={{ radius: 90 }} style
={{ radius: spring(isHovered
? 30 : 90, { stiffness: 180, damping: 12 }) }}>
45 href
={account
.get('url')}
46 className
='account__header__avatar'
50 style
={{ borderRadius: `${radius}px`, backgroundImage: `url(${autoPlayGif || isHovered ? account.get('avatar') : account.get('avatar_static')})` }}
51 onMouseOver
={this.handleMouseOver
}
52 onMouseOut
={this.handleMouseOut
}
53 onFocus
={this.handleMouseOver
}
54 onBlur
={this.handleMouseOut
}
56 <span style
={{ display: 'none' }}>{account
.get('acct')}</span
>
66 export default class Header
extends ImmutablePureComponent
{
69 account: ImmutablePropTypes
.map
,
70 onFollow: PropTypes
.func
.isRequired
,
71 intl: PropTypes
.object
.isRequired
,
75 const { account
, intl
} = this.props
;
85 if (me
!== account
.get('id') && account
.getIn(['relationship', 'followed_by'])) {
86 info
= <span className
='account--follows-info'><FormattedMessage id
='account.follows_you' defaultMessage
='Follows you' /></span>;
89 if (me
!== account
.get('id')) {
90 if (account
.getIn(['relationship', 'requested'])) {
92 <div className
='account--action-button'>
93 <IconButton size
={26} active icon
='hourglass' title
={intl
.formatMessage(messages
.requested
)} onClick
={this.props
.onFollow
} />
96 } else if (!account
.getIn(['relationship', 'blocking'])) {
98 <div className
='account--action-button'>
99 <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
} />
105 if (account
.get('locked')) {
106 lockedIcon
= <i className
='fa fa-lock' />;
109 const content
= { __html: account
.get('note_emojified') };
110 const displayNameHtml
= { __html: account
.get('display_name_html') };
113 <div className
='account__header' style
={{ backgroundImage: `url(${account.get('header')})` }}>
115 <Avatar account
={account
} />
117 <span className
='account__header__display-name' dangerouslySetInnerHTML
={displayNameHtml
} />
118 <span className
='account__header__username'>@{account
.get('acct')} {lockedIcon
}</span
>
119 <div className
='account__header__content' dangerouslySetInnerHTML
={content
} />
This page took 0.129862 seconds and 5 git commands to generate.