Added ability to click to enlarge profile, cover photo on profile
• Added: - ability to click to enlarge profile, cover photo on profile
This commit is contained in:
parent
50169fcd7d
commit
de5a1f93b8
@ -84,7 +84,11 @@ class Avatar extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { account, size } = this.props
|
const {
|
||||||
|
account,
|
||||||
|
expandOnClick,
|
||||||
|
size,
|
||||||
|
} = this.props
|
||||||
const { hovering, sameImg } = this.state
|
const { hovering, sameImg } = this.state
|
||||||
|
|
||||||
const isPro = !!account ? account.get('is_pro') : false
|
const isPro = !!account ? account.get('is_pro') : false
|
||||||
@ -110,6 +114,7 @@ class Avatar extends ImmutablePureComponent {
|
|||||||
alt={alt}
|
alt={alt}
|
||||||
imageRef={this.setRef}
|
imageRef={this.setRef}
|
||||||
className={classes.join(' ')}
|
className={classes.join(' ')}
|
||||||
|
expandOnClick={expandOnClick}
|
||||||
{...options}
|
{...options}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@ -130,6 +135,7 @@ Avatar.propTypes = {
|
|||||||
account: ImmutablePropTypes.map,
|
account: ImmutablePropTypes.map,
|
||||||
noHover: PropTypes.bool,
|
noHover: PropTypes.bool,
|
||||||
openUserInfoPopover: PropTypes.func.isRequired,
|
openUserInfoPopover: PropTypes.func.isRequired,
|
||||||
|
expandOnClick: PropTypes.bool,
|
||||||
size: PropTypes.number,
|
size: PropTypes.number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { CX } from '../constants'
|
import { connect } from 'react-redux'
|
||||||
|
import {
|
||||||
|
CX,
|
||||||
|
MODAL_MEDIA,
|
||||||
|
} from '../constants'
|
||||||
|
import { openModal } from '../actions/modal'
|
||||||
|
|
||||||
class Image extends React.PureComponent {
|
class Image extends React.PureComponent {
|
||||||
|
|
||||||
@ -12,6 +17,10 @@ class Image extends React.PureComponent {
|
|||||||
this.setState({ error: true })
|
this.setState({ error: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleOnClick = () => {
|
||||||
|
this.props.onOpenMediaModal()
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
alt,
|
alt,
|
||||||
@ -21,6 +30,7 @@ class Image extends React.PureComponent {
|
|||||||
nullable,
|
nullable,
|
||||||
isLazy,
|
isLazy,
|
||||||
imageRef,
|
imageRef,
|
||||||
|
expandOnClick,
|
||||||
...otherProps
|
...otherProps
|
||||||
} = this.props
|
} = this.props
|
||||||
const { error } = this.state
|
const { error } = this.state
|
||||||
@ -37,9 +47,7 @@ class Image extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!src) {
|
if (!src) {
|
||||||
return (
|
return <div className={classes} />
|
||||||
<div className={classes} />
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -50,6 +58,7 @@ class Image extends React.PureComponent {
|
|||||||
ref={imageRef}
|
ref={imageRef}
|
||||||
src={src}
|
src={src}
|
||||||
onError={this.handleOnError}
|
onError={this.handleOnError}
|
||||||
|
onClick={expandOnClick ? this.handleOnClick : undefined}
|
||||||
loading={isLazy ? 'lazy' : undefined}
|
loading={isLazy ? 'lazy' : undefined}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@ -57,6 +66,15 @@ class Image extends React.PureComponent {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch, { alt, src }) => ({
|
||||||
|
onOpenMediaModal() {
|
||||||
|
dispatch(openModal(MODAL_MEDIA, {
|
||||||
|
alt,
|
||||||
|
src,
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
Image.propTypes = {
|
Image.propTypes = {
|
||||||
alt: PropTypes.string.isRequired,
|
alt: PropTypes.string.isRequired,
|
||||||
isLazy: PropTypes.string,
|
isLazy: PropTypes.string,
|
||||||
@ -73,6 +91,8 @@ Image.propTypes = {
|
|||||||
nullable: PropTypes.bool,
|
nullable: PropTypes.bool,
|
||||||
lazy: PropTypes.bool,
|
lazy: PropTypes.bool,
|
||||||
imageRef: PropTypes.func,
|
imageRef: PropTypes.func,
|
||||||
|
expandOnClick: PropTypes.bool,
|
||||||
|
onOpenMedia: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
Image.defaultProps = {
|
Image.defaultProps = {
|
||||||
@ -80,4 +100,4 @@ Image.defaultProps = {
|
|||||||
fit: 'cover',
|
fit: 'cover',
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Image
|
export default connect(null, mapDispatchToProps)(Image)
|
@ -25,22 +25,32 @@ class MediaModal extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSwipe = (index) => {
|
handleSwipe = (index) => {
|
||||||
|
if (!this.props.media) return
|
||||||
|
|
||||||
this.setState({ index: index % this.props.media.size })
|
this.setState({ index: index % this.props.media.size })
|
||||||
}
|
}
|
||||||
|
|
||||||
handleNextClick = () => {
|
handleNextClick = () => {
|
||||||
|
if (!this.props.media) return
|
||||||
|
|
||||||
this.setState({ index: (this.getIndex() + 1) % this.props.media.size })
|
this.setState({ index: (this.getIndex() + 1) % this.props.media.size })
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePrevClick = () => {
|
handlePrevClick = () => {
|
||||||
|
if (!this.props.media) return
|
||||||
|
|
||||||
this.setState({ index: (this.props.media.size + this.getIndex() - 1) % this.props.media.size })
|
this.setState({ index: (this.props.media.size + this.getIndex() - 1) % this.props.media.size })
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChangeIndex = (i) => {
|
handleChangeIndex = (i) => {
|
||||||
|
if (!this.props.media) return
|
||||||
|
|
||||||
this.setState({ index: i % this.props.media.size })
|
this.setState({ index: i % this.props.media.size })
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyDown = (e) => {
|
handleKeyDown = (e) => {
|
||||||
|
if (!this.props.media) return
|
||||||
|
|
||||||
switch (e.key) {
|
switch (e.key) {
|
||||||
case 'ArrowLeft':
|
case 'ArrowLeft':
|
||||||
this.handlePrevClick()
|
this.handlePrevClick()
|
||||||
@ -101,6 +111,8 @@ class MediaModal extends ImmutablePureComponent {
|
|||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
media,
|
media,
|
||||||
|
src,
|
||||||
|
alt,
|
||||||
status,
|
status,
|
||||||
intl,
|
intl,
|
||||||
onClose,
|
onClose,
|
||||||
@ -109,7 +121,14 @@ class MediaModal extends ImmutablePureComponent {
|
|||||||
|
|
||||||
const index = this.getIndex()
|
const index = this.getIndex()
|
||||||
|
|
||||||
const content = media.map((image) => {
|
const content = !media ?
|
||||||
|
<ImageLoader
|
||||||
|
previewSrc={src}
|
||||||
|
src={src}
|
||||||
|
alt={alt}
|
||||||
|
key={src}
|
||||||
|
/> :
|
||||||
|
media.map((image) => {
|
||||||
const width = image.getIn(['meta', 'original', 'width']) || null
|
const width = image.getIn(['meta', 'original', 'width']) || null
|
||||||
const height = image.getIn(['meta', 'original', 'height']) || null
|
const height = image.getIn(['meta', 'original', 'height']) || null
|
||||||
|
|
||||||
@ -215,7 +234,7 @@ class MediaModal extends ImmutablePureComponent {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{
|
{
|
||||||
media.size > 1 &&
|
!!media && media.size > 1 &&
|
||||||
<Button
|
<Button
|
||||||
tabIndex='0'
|
tabIndex='0'
|
||||||
backgroundColor='black'
|
backgroundColor='black'
|
||||||
@ -228,7 +247,7 @@ class MediaModal extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
media.size > 1 &&
|
!!media && media.size > 1 &&
|
||||||
<Button
|
<Button
|
||||||
tabIndex='0'
|
tabIndex='0'
|
||||||
backgroundColor='black'
|
backgroundColor='black'
|
||||||
@ -253,7 +272,7 @@ class MediaModal extends ImmutablePureComponent {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{
|
{
|
||||||
media.size > 1 &&
|
!!media && media.size > 1 &&
|
||||||
<div className={[_s.d, _s.posAbs, _s.bottom0, _s.mb15].join(' ')}>
|
<div className={[_s.d, _s.posAbs, _s.bottom0, _s.mb15].join(' ')}>
|
||||||
<div className={[_s.d, _s.saveAreaInsetMB, _s.bgBlackOpaque, _s.circle, _s.py10, _s.px15].join(' ')}>
|
<div className={[_s.d, _s.saveAreaInsetMB, _s.bgBlackOpaque, _s.circle, _s.py10, _s.px15].join(' ')}>
|
||||||
<Pagination
|
<Pagination
|
||||||
|
@ -179,6 +179,7 @@ class ProfileHeader extends ImmutablePureComponent {
|
|||||||
alt={intl.formatMessage(messages.headerPhoto)}
|
alt={intl.formatMessage(messages.headerPhoto)}
|
||||||
className={[_s.topRightRadiusSmall, _s.topLeftRadiusSmall, _s.h100PC].join(' ')}
|
className={[_s.topRightRadiusSmall, _s.topLeftRadiusSmall, _s.h100PC].join(' ')}
|
||||||
src={headerSrc}
|
src={headerSrc}
|
||||||
|
expandOnClick
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@ -191,7 +192,7 @@ class ProfileHeader extends ImmutablePureComponent {
|
|||||||
|
|
||||||
<div className={[_s.d, _s.aiCenter, _s.px15, _s.mb5].join(' ')}>
|
<div className={[_s.d, _s.aiCenter, _s.px15, _s.mb5].join(' ')}>
|
||||||
<div className={mobileAvatarContainerClasses}>
|
<div className={mobileAvatarContainerClasses}>
|
||||||
<Avatar size={100} account={account} noHover />
|
<Avatar size={100} account={account} noHover expandOnClick />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={[_s.d, _s.flexRow, _s.flexNormal, _s.py10].join(' ')}>
|
<div className={[_s.d, _s.flexRow, _s.flexNormal, _s.py10].join(' ')}>
|
||||||
@ -285,6 +286,7 @@ class ProfileHeader extends ImmutablePureComponent {
|
|||||||
alt={intl.formatMessage(messages.headerPhoto)}
|
alt={intl.formatMessage(messages.headerPhoto)}
|
||||||
className={_s.h100PC}
|
className={_s.h100PC}
|
||||||
src={headerSrc}
|
src={headerSrc}
|
||||||
|
expandOnClick
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@ -299,7 +301,7 @@ class ProfileHeader extends ImmutablePureComponent {
|
|||||||
<div className={avatarContainerClasses}>
|
<div className={avatarContainerClasses}>
|
||||||
{
|
{
|
||||||
account &&
|
account &&
|
||||||
<Avatar size={avatarSize} account={account} noHover />
|
<Avatar size={avatarSize} account={account} noHover expandOnClick />
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
!account &&
|
!account &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user