diff --git a/app/soapbox/components/avatar.js b/app/soapbox/components/avatar.js index a4358332b..e909c44df 100644 --- a/app/soapbox/components/avatar.js +++ b/app/soapbox/components/avatar.js @@ -1,54 +1,25 @@ import React from 'react'; -import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import { getSettings } from 'soapbox/actions/settings'; +import classNames from 'classnames'; +import StillImage from 'soapbox/components/still_image'; -const mapStateToProps = state => ({ - animate: getSettings(state).get('autoPlayGif'), -}); - -export class Avatar extends React.PureComponent { +export default class Avatar extends React.PureComponent { static propTypes = { account: ImmutablePropTypes.map, size: PropTypes.number, style: PropTypes.object, inline: PropTypes.bool, - animate: PropTypes.bool, }; static defaultProps = { inline: false, }; - state = { - hovering: false, - }; - - handleMouseEnter = () => { - if (this.props.animate) return; - this.setState({ hovering: true }); - } - - handleMouseLeave = () => { - if (this.props.animate) return; - this.setState({ hovering: false }); - } - render() { - const { account, size, animate, inline } = this.props; + const { account, size, inline } = this.props; if (!account) return null; - const { hovering } = this.state; - - const src = account.get('avatar'); - const staticSrc = account.get('avatar_static'); - - let className = 'account__avatar'; - - if (inline) { - className = className + ' account__avatar-inline'; - } // : TODO : remove inline and change all avatars to be sized using css const style = !size ? {} : { @@ -56,22 +27,14 @@ export class Avatar extends React.PureComponent { height: `${size}px`, }; - if (hovering || animate) { - style.backgroundImage = `url(${src})`; - } else { - style.backgroundImage = `url(${staticSrc})`; - } - return ( -
); } } - -export default connect(mapStateToProps)(Avatar); diff --git a/app/soapbox/components/avatar_composite.js b/app/soapbox/components/avatar_composite.js index 06607cacd..c6d1eb8cc 100644 --- a/app/soapbox/components/avatar_composite.js +++ b/app/soapbox/components/avatar_composite.js @@ -1,24 +1,16 @@ import React from 'react'; -import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import { getSettings } from 'soapbox/actions/settings'; +import StillImage from 'soapbox/components/still_image'; -const mapStateToProps = state => ({ - animate: getSettings(state).get('autoPlayGif'), -}); - -export default @connect(mapStateToProps) -class AvatarComposite extends React.PureComponent { +export default class AvatarComposite extends React.PureComponent { static propTypes = { accounts: ImmutablePropTypes.list.isRequired, - animate: PropTypes.bool, size: PropTypes.number.isRequired, }; renderItem(account, size, index) { - const { animate } = this.props; let width = 50; let height = 100; @@ -76,12 +68,10 @@ class AvatarComposite extends React.PureComponent { bottom: bottom, width: `${width}%`, height: `${height}%`, - backgroundSize: 'cover', - backgroundImage: `url(${account.get(animate ? 'avatar' : 'avatar_static')})`, }; return ( - +