2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-02-28 15:20:47 +00:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
2020-05-09 03:17:19 +01:00
|
|
|
import { BREAKPOINT_EXTRA_SMALL } from '../constants'
|
2020-02-24 21:56:07 +00:00
|
|
|
import Sticky from 'react-stickynode'
|
2020-11-15 18:48:32 +00:00
|
|
|
import throttle from 'lodash.throttle'
|
2020-05-09 03:17:19 +01:00
|
|
|
import { me } from '../initial_state'
|
2020-11-15 18:48:32 +00:00
|
|
|
import {
|
|
|
|
CX,
|
|
|
|
LAZY_LOAD_SCROLL_OFFSET,
|
|
|
|
} from '../constants'
|
2020-09-02 00:13:11 +01:00
|
|
|
import DefaultNavigationBar from '../components/navigation_bar/default_navigation_bar'
|
2020-05-09 03:17:19 +01:00
|
|
|
import FooterBar from '../components/footer_bar'
|
2020-05-03 06:22:49 +01:00
|
|
|
import ProfileHeader from '../components/profile_header'
|
2020-05-14 07:03:22 +01:00
|
|
|
import FloatingActionButton from '../components/floating_action_button'
|
2020-09-02 00:13:11 +01:00
|
|
|
import ProfileNavigationBar from '../components/navigation_bar/profile_navigation_bar'
|
|
|
|
import LoggedOutNavigationBar from '../components/navigation_bar/logged_out_navigation_bar'
|
2020-08-12 23:52:46 +01:00
|
|
|
import Responsive from '../features/ui/util/responsive_component'
|
|
|
|
import Divider from '../components/divider'
|
|
|
|
import WrappedBundle from '../features/ui/util/wrapped_bundle'
|
|
|
|
import {
|
|
|
|
LinkFooter,
|
|
|
|
ProfileStatsPanel,
|
|
|
|
ProfileInfoPanel,
|
|
|
|
MediaGalleryPanel,
|
|
|
|
SignUpPanel,
|
2020-11-01 00:13:47 +00:00
|
|
|
SidebarXS,
|
2020-08-12 23:52:46 +01:00
|
|
|
} from '../features/ui/util/async_components'
|
2020-03-14 17:31:29 +00:00
|
|
|
|
2020-08-17 23:06:22 +01:00
|
|
|
class ProfileLayout extends ImmutablePureComponent {
|
2020-02-24 21:56:07 +00:00
|
|
|
|
2020-11-15 18:48:32 +00:00
|
|
|
state = {
|
|
|
|
lazyLoaded: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.window = window
|
|
|
|
this.documentElement = document.scrollingElement || document.documentElement
|
|
|
|
|
|
|
|
this.window.addEventListener('scroll', this.handleScroll)
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
this.detachScrollListener()
|
|
|
|
}
|
|
|
|
|
|
|
|
detachScrollListener = () => {
|
|
|
|
this.window.removeEventListener('scroll', this.handleScroll)
|
|
|
|
}
|
|
|
|
|
|
|
|
handleScroll = throttle(() => {
|
|
|
|
if (this.window) {
|
|
|
|
const { scrollTop } = this.documentElement
|
|
|
|
|
|
|
|
if (scrollTop > LAZY_LOAD_SCROLL_OFFSET && !this.state.lazyLoaded) {
|
|
|
|
this.setState({ lazyLoaded: true })
|
|
|
|
this.detachScrollListener()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 150, { trailing: true })
|
|
|
|
|
|
|
|
|
2020-02-24 21:56:07 +00:00
|
|
|
render() {
|
2020-04-11 23:29:19 +01:00
|
|
|
const {
|
|
|
|
account,
|
|
|
|
children,
|
2020-05-27 01:33:53 +01:00
|
|
|
titleHTML,
|
2020-05-10 04:26:58 +01:00
|
|
|
unavailable,
|
2020-06-09 00:39:35 +01:00
|
|
|
noSidebar,
|
2020-04-11 23:29:19 +01:00
|
|
|
} = this.props
|
2020-11-15 18:48:32 +00:00
|
|
|
const { lazyLoaded } = this.state
|
2020-02-28 15:20:47 +00:00
|
|
|
|
2020-06-09 00:39:35 +01:00
|
|
|
const mainContentClasses = CX({
|
2020-08-18 21:49:11 +01:00
|
|
|
d: 1,
|
2020-08-19 01:22:15 +01:00
|
|
|
w645PX: !noSidebar,
|
2020-08-18 21:43:06 +01:00
|
|
|
w1015PX: noSidebar,
|
2020-06-09 00:39:35 +01:00
|
|
|
z1: 1,
|
|
|
|
})
|
|
|
|
|
2020-02-24 21:56:07 +00:00
|
|
|
return (
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC, _s.minH100VH, _s.bgTertiary].join(' ')}>
|
2020-11-01 00:13:47 +00:00
|
|
|
|
|
|
|
<Responsive max={BREAKPOINT_EXTRA_SMALL}>
|
|
|
|
<WrappedBundle component={SidebarXS} />
|
|
|
|
</Responsive>
|
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
<Responsive max={BREAKPOINT_EXTRA_SMALL}>
|
|
|
|
{
|
|
|
|
!!me &&
|
2020-05-27 01:33:53 +01:00
|
|
|
<ProfileNavigationBar titleHTML={titleHTML} />
|
2020-05-09 03:17:19 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
!me &&
|
2020-07-25 00:59:46 +01:00
|
|
|
<LoggedOutNavigationBar isProfile />
|
2020-05-09 03:17:19 +01:00
|
|
|
}
|
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<main role='main' className={[_s.d, _s.w100PC].join(' ')}>
|
2020-05-09 03:17:19 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC, _s.flexRow, _s.pb15].join(' ')}>
|
2020-05-09 03:17:19 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC, _s.flexRow, _s.jcSpaceBetween].join(' ')}>
|
|
|
|
<div className={[_s.d, _s.z1, _s.w100PC, _s.aiCenter].join(' ')}>
|
2020-05-09 03:17:19 +01:00
|
|
|
|
2020-07-29 21:40:47 +01:00
|
|
|
<ProfileHeader account={account} isXS>
|
2020-08-13 00:39:50 +01:00
|
|
|
<WrappedBundle component={ProfileInfoPanel} componentParams={{ account, noPanel: true }} />
|
2020-05-09 03:17:19 +01:00
|
|
|
<Divider isSmall />
|
2020-08-13 00:39:50 +01:00
|
|
|
<WrappedBundle component={ProfileStatsPanel} componentParams={{ account, noPanel: true }} />
|
2020-05-09 03:17:19 +01:00
|
|
|
</ProfileHeader>
|
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC, , _s.flexRow, _s.jcEnd, _s.py15].join(' ')}>
|
|
|
|
<div className={[_s.d, _s.w100PC, _s.z1].join(' ')}>
|
2020-12-16 07:39:07 +00:00
|
|
|
<div className={[_s.d, _s.boxShadowNone].join(' ')}>
|
2020-05-09 03:17:19 +01:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2020-03-14 17:31:29 +00:00
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
</div>
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2020-05-14 07:03:22 +01:00
|
|
|
<FloatingActionButton />
|
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
</main>
|
|
|
|
|
2020-05-14 07:03:22 +01:00
|
|
|
<FooterBar />
|
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
</Responsive>
|
|
|
|
|
|
|
|
<Responsive min={BREAKPOINT_EXTRA_SMALL}>
|
|
|
|
{
|
|
|
|
me &&
|
2020-09-02 00:13:11 +01:00
|
|
|
<DefaultNavigationBar />
|
2020-05-09 03:17:19 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
!me &&
|
2020-07-25 00:59:46 +01:00
|
|
|
<LoggedOutNavigationBar isProfile />
|
2020-05-09 03:17:19 +01:00
|
|
|
}
|
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<main role='main' className={[_s.d, _s.w100PC].join(' ')}>
|
2020-05-09 03:17:19 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC, _s.flexRow, _s.pb15].join(' ')}>
|
2020-05-09 03:17:19 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC, _s.flexRow, _s.jcSpaceBetween].join(' ')}>
|
|
|
|
<div className={[_s.d, _s.z1, _s.w100PC, _s.aiCenter].join(' ')}>
|
2020-05-09 03:17:19 +01:00
|
|
|
|
|
|
|
<ProfileHeader account={account} />
|
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w1015PX, , _s.flexRow, _s.jcEnd, _s.py15].join(' ')}>
|
2020-06-09 00:39:35 +01:00
|
|
|
{
|
|
|
|
!noSidebar &&
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w340PX, _s.mr15].join(' ')}>
|
2020-06-09 00:39:35 +01:00
|
|
|
<Sticky top={63} enabled>
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w340PX].join(' ')}>
|
2020-08-12 23:52:46 +01:00
|
|
|
<WrappedBundle component={ProfileStatsPanel} componentParams={{ account }} />
|
|
|
|
<WrappedBundle component={ProfileInfoPanel} componentParams={{ account }} />
|
2020-11-15 18:48:32 +00:00
|
|
|
{ !unavailable && <WrappedBundle component={MediaGalleryPanel} componentParams={{ account, isLazy: true, shouldLoad: lazyLoaded }} />}
|
2020-08-12 23:52:46 +01:00
|
|
|
{ !me && <WrappedBundle component={SignUpPanel} /> }
|
|
|
|
<WrappedBundle component={LinkFooter} />
|
2020-06-09 00:39:35 +01:00
|
|
|
</div>
|
|
|
|
</Sticky>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
<div className={mainContentClasses}>
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={_s.d}>
|
2020-05-09 03:17:19 +01:00
|
|
|
{children}
|
2020-04-29 23:32:49 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-04-11 23:29:19 +01:00
|
|
|
</div>
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
</div>
|
2020-04-11 23:29:19 +01:00
|
|
|
</div>
|
2020-02-24 21:56:07 +00:00
|
|
|
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
</div>
|
2020-02-24 21:56:07 +00:00
|
|
|
|
2020-12-03 04:22:51 +00:00
|
|
|
<FloatingActionButton />
|
2020-05-15 23:49:54 +01:00
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
</main>
|
|
|
|
</Responsive>
|
2020-04-29 23:32:49 +01:00
|
|
|
|
|
|
|
</div>
|
2020-02-24 21:56:07 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-17 23:06:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ProfileLayout.propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
titleHTML: PropTypes.string,
|
|
|
|
unavailable: PropTypes.bool,
|
|
|
|
noSidebar: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ProfileLayout
|