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-08-06 06:00:28 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
2020-08-07 05:19:18 +01:00
|
|
|
import throttle from 'lodash.throttle'
|
2020-08-06 06:00:28 +01:00
|
|
|
import Sticky from 'react-stickynode'
|
2020-08-19 17:14:43 +01:00
|
|
|
import { me } from '../initial_state'
|
2020-08-06 06:00:28 +01:00
|
|
|
import { BREAKPOINT_EXTRA_SMALL } from '../constants'
|
|
|
|
import Layout from './layout'
|
|
|
|
import SidebarPanelGroup from '../components/sidebar_panel_group'
|
|
|
|
import Responsive from '../features/ui/util/responsive_component'
|
2020-08-12 23:52:46 +01:00
|
|
|
import WrappedBundle from '../features/ui/util/wrapped_bundle'
|
2020-08-06 06:00:28 +01:00
|
|
|
import Heading from '../components/heading'
|
2020-08-12 23:52:46 +01:00
|
|
|
import {
|
2020-08-13 00:39:50 +01:00
|
|
|
GroupsPanel,
|
2020-08-12 23:52:46 +01:00
|
|
|
SignUpLogInPanel,
|
2020-09-01 17:54:01 +01:00
|
|
|
UserSuggestionsPanel,
|
2020-08-12 23:52:46 +01:00
|
|
|
TrendsPanel,
|
|
|
|
} from '../features/ui/util/async_components'
|
2020-08-06 06:00:28 +01:00
|
|
|
|
2020-08-17 23:06:22 +01:00
|
|
|
class ExploreLayout extends ImmutablePureComponent {
|
2020-08-06 06:00:28 +01:00
|
|
|
|
2020-08-07 05:19:18 +01: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 > 25 && !this.state.lazyLoaded) {
|
|
|
|
this.setState({ lazyLoaded: true })
|
|
|
|
this.detachScrollListener()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 150, {
|
|
|
|
trailing: true,
|
|
|
|
})
|
|
|
|
|
2020-08-06 06:00:28 +01:00
|
|
|
render() {
|
|
|
|
const { children, title } = this.props
|
2020-08-07 05:19:18 +01:00
|
|
|
const { lazyLoaded } = this.state
|
2020-08-06 06:00:28 +01:00
|
|
|
|
|
|
|
const pageTitleBlock = (
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.pl15, _s.pb10].join(' ')}>
|
2020-08-06 06:00:28 +01:00
|
|
|
<Heading size='h2'>Popular posts across Gab</Heading>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
2020-08-19 17:14:43 +01:00
|
|
|
const layout = [
|
|
|
|
SignUpLogInPanel,
|
|
|
|
<WrappedBundle component={GroupsPanel} componentParams={{ groupType: 'featured' }} />,
|
|
|
|
]
|
|
|
|
if (!!me) {
|
2020-09-01 17:54:01 +01:00
|
|
|
layout.push(<WrappedBundle component={UserSuggestionsPanel} componentParams={{ suggestionType: 'verified' }} />)
|
2020-08-19 17:14:43 +01:00
|
|
|
}
|
|
|
|
layout.push(<WrappedBundle component={TrendsPanel} componentParams={{ isLazy: true, shouldLoad: lazyLoaded }} />)
|
|
|
|
|
2020-08-06 06:00:28 +01:00
|
|
|
return (
|
|
|
|
<Layout
|
|
|
|
showGlobalFooter
|
|
|
|
noRightSidebar
|
|
|
|
showLinkFooterInSidebar
|
|
|
|
page='explore'
|
|
|
|
title={title}
|
|
|
|
>
|
|
|
|
<Responsive max={BREAKPOINT_EXTRA_SMALL}>
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC].join(' ')}>
|
2020-08-06 06:00:28 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC, _s.z1].join(' ')}>
|
|
|
|
<div className={[_s.d, _s.mt15, _s.px10].join(' ')}>
|
2020-08-13 00:39:50 +01:00
|
|
|
<WrappedBundle component={SignUpLogInPanel} componentParams={{ isXS: true }} />
|
2020-08-06 06:00:28 +01:00
|
|
|
</div>
|
|
|
|
{pageTitleBlock}
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</Responsive>
|
|
|
|
|
|
|
|
<Responsive min={BREAKPOINT_EXTRA_SMALL}>
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w100PC, _s.pl15].join(' ')}>
|
2020-08-06 06:00:28 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.flexRow, _s.w100PC, _s.jcEnd].join(' ')}>
|
|
|
|
<div className={[_s.d, _s.w645PX, _s.z1].join(' ')}>
|
2020-08-06 06:00:28 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={_s.d}>
|
2020-08-06 06:00:28 +01:00
|
|
|
{pageTitleBlock}
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.ml15, _s.w340PX].join(' ')}>
|
2020-08-06 06:00:28 +01:00
|
|
|
<Sticky top={73} enabled>
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.w340PX].join(' ')}>
|
2020-08-06 06:00:28 +01:00
|
|
|
<SidebarPanelGroup
|
|
|
|
page='explore'
|
2020-08-19 17:14:43 +01:00
|
|
|
layout={layout}
|
2020-08-06 06:00:28 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Sticky>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Responsive>
|
|
|
|
</Layout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-17 23:06:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ExploreLayout.propTypes = {
|
|
|
|
actions: PropTypes.array,
|
|
|
|
children: PropTypes.node,
|
|
|
|
group: ImmutablePropTypes.map,
|
|
|
|
groupId: PropTypes.string,
|
|
|
|
layout: PropTypes.object,
|
|
|
|
relationships: ImmutablePropTypes.map,
|
|
|
|
title: PropTypes.string,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExploreLayout
|