gab-social/app/javascript/gabsocial/components/sidebar_header.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-02-22 23:26:23 +00:00
import { Fragment } from 'react'
2020-02-08 06:12:01 +00:00
import { NavLink } from 'react-router-dom'
2020-02-05 22:45:48 +00:00
import ImmutablePropTypes from 'react-immutable-proptypes'
import ImmutablePureComponent from 'react-immutable-pure-component'
import { me } from '../initial_state'
import { makeGetAccount } from '../selectors'
2020-02-25 16:04:44 +00:00
import GabLogo from '../assets/gab_logo'
2020-02-22 23:26:23 +00:00
import SidebarSectionItem from './sidebar_section_item'
2019-08-15 04:04:03 +01:00
const mapStateToProps = state => {
2020-02-05 22:45:48 +00:00
const getAccount = makeGetAccount()
2019-08-15 04:04:03 +01:00
return {
account: getAccount(state, me),
2020-02-05 22:45:48 +00:00
}
}
2019-08-15 04:04:03 +01:00
2020-02-28 15:20:47 +00:00
export default
@connect(mapStateToProps)
2020-02-22 23:26:23 +00:00
class SidebarHeader extends ImmutablePureComponent {
2019-08-15 04:04:03 +01:00
static propTypes = {
account: ImmutablePropTypes.map,
2020-02-08 06:12:01 +00:00
}
render() {
2020-02-22 23:26:23 +00:00
const { account } = this.props
2020-02-08 06:12:01 +00:00
return (
2020-02-22 23:26:23 +00:00
<Fragment>
<h1 className={[_s.default].join(' ')}>
<NavLink to='/' aria-label='Gab' className={[_s.default, _s.noSelect, _s.noUnderline, _s.height50PX, _s.justifyContentCenter, _s.cursorPointer, _s.paddingHorizontal10PX].join(' ')}>
<GabLogo />
</NavLink>
</h1>
{
(!!me && !!account) &&
<SidebarSectionItem
image={account.get('avatar')}
title={account.get('acct')}
to={`/${account.get('acct')}`}
/>
}
</Fragment>
2020-02-08 06:12:01 +00:00
)
}
}