2020-05-07 05:03:34 +01:00
|
|
|
import { withRouter } from 'react-router-dom'
|
|
|
|
import { me } from '../initial_state'
|
2020-05-10 04:26:58 +01:00
|
|
|
import { CX } from '../constants'
|
2020-05-06 05:33:54 +01:00
|
|
|
import Button from './button'
|
|
|
|
|
2020-05-15 23:27:06 +01:00
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
notificationCount: state.getIn(['notifications', 'unread']),
|
2020-05-29 23:30:31 +01:00
|
|
|
homeItemsQueueCount: state.getIn(['timelines', 'home', 'totalQueuedItemsCount']),
|
2020-05-15 23:27:06 +01:00
|
|
|
})
|
|
|
|
|
2020-05-06 05:33:54 +01:00
|
|
|
export default
|
|
|
|
@withRouter
|
2020-05-15 23:27:06 +01:00
|
|
|
@connect(mapStateToProps)
|
2020-05-06 05:33:54 +01:00
|
|
|
class FooterBar extends PureComponent {
|
|
|
|
|
2020-05-10 04:26:58 +01:00
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
|
|
|
}
|
|
|
|
|
2020-05-15 23:27:06 +01:00
|
|
|
static propTypes = {
|
|
|
|
notificationCount: PropTypes.number.isRequired,
|
|
|
|
}
|
|
|
|
|
2020-05-06 05:33:54 +01:00
|
|
|
render() {
|
2020-05-29 23:30:31 +01:00
|
|
|
const {
|
|
|
|
notificationCount,
|
|
|
|
homeItemsQueueCount,
|
|
|
|
} = this.props
|
2020-05-07 05:03:34 +01:00
|
|
|
if (!me) return false
|
2020-05-06 05:33:54 +01:00
|
|
|
|
2020-05-10 04:26:58 +01:00
|
|
|
const noRouter = !this.context.router
|
|
|
|
const currentPathname = noRouter ? '' : this.context.router.route.location.pathname
|
|
|
|
|
|
|
|
const buttons = [
|
|
|
|
{
|
|
|
|
to: '/home',
|
|
|
|
icon: 'home',
|
|
|
|
title: 'Home',
|
|
|
|
active: currentPathname === '/home',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
to: '/notifications',
|
|
|
|
icon: 'notifications',
|
|
|
|
title: 'Notifications',
|
|
|
|
active: currentPathname === '/notifications',
|
|
|
|
},
|
|
|
|
{
|
2020-05-16 04:22:49 +01:00
|
|
|
to: '/groups',
|
|
|
|
icon: 'group',
|
|
|
|
title: 'Groups',
|
|
|
|
active: currentPathname === '/groups',
|
2020-05-10 04:26:58 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
href: 'https://trends.gab.com',
|
|
|
|
icon: 'trends',
|
|
|
|
title: 'Trends',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2020-05-06 05:33:54 +01:00
|
|
|
return (
|
2020-05-07 05:03:34 +01:00
|
|
|
<div className={[_s.default, _s.z4, _s.heightMin58PX, _s.width100PC].join(' ')}>
|
|
|
|
<div className={[_s.default, _s.posFixed, _s.left0, _s.right0, _s.bottom0, _s.heightMin58PX, _s.width100PC, _s.bgPrimary, _s.borderTop1PX, _s.borderColorSecondary].join(' ')}>
|
2020-05-14 22:47:33 +01:00
|
|
|
<div className={[_s.default, _s.flexRow, _s.alignItemsCenter, _s.height100PC, _s.heightMin58PX, _s.saveAreaInsetPB, _s.justifyContentSpaceAround].join(' ')}>
|
2020-05-10 04:26:58 +01:00
|
|
|
{
|
|
|
|
buttons.map((props) => {
|
|
|
|
const classes = CX({
|
|
|
|
borderTop2PX: 1,
|
|
|
|
borderColorTransparent: !props.active,
|
|
|
|
borderColorBrand: props.active,
|
|
|
|
height100PC: 1,
|
|
|
|
heightMin58PX: 1,
|
|
|
|
px15: 1,
|
|
|
|
flexGrow1: 1,
|
|
|
|
alignItemsCenter: 1,
|
|
|
|
justifyContentCenter: 1,
|
|
|
|
})
|
|
|
|
|
|
|
|
const color = props.active ? 'brand' : 'secondary'
|
2020-05-29 23:30:31 +01:00
|
|
|
let childIcon;
|
|
|
|
if (props.to === '/notifications' && notificationCount > 0) {
|
|
|
|
childIcon = (
|
|
|
|
<div className={[_s.posAbs, _s.ml5, _s.top0, _s.pt5, _s.pl20].join(' ')}>
|
|
|
|
<span className={[_s.bgRed, _s.colorWhite, _s.circle, _s.py2, _s.px2, _s.minWidth14PX, _s.displayBlock].join(' ')} style={{fontSize: '12px'}}>
|
|
|
|
{notificationCount}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
} else if (props.to === '/home' && homeItemsQueueCount > 0) {
|
|
|
|
childIcon = (
|
|
|
|
<div className={[_s.posAbs, _s.ml5, _s.top0, _s.pt2, _s.pl20].join(' ')}>
|
|
|
|
<span className={[_s.colorBrand, _s.circle, _s.py2, _s.px2, _s.minWidth14PX, _s.displayBlock].join(' ')} style={{fontSize: '18px'}}>
|
|
|
|
•
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2020-05-10 04:26:58 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
isText
|
|
|
|
backgroundColor='none'
|
|
|
|
iconSize='20px'
|
|
|
|
color={color}
|
|
|
|
to={props.to}
|
|
|
|
icon={props.icon}
|
|
|
|
href={props.href}
|
|
|
|
title={props.title}
|
|
|
|
className={classes}
|
2020-05-15 23:27:06 +01:00
|
|
|
>
|
|
|
|
{childIcon}
|
|
|
|
</Button>
|
2020-05-10 04:26:58 +01:00
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
2020-05-06 05:33:54 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|