import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import {
grayLighter,
} from '@bufferapp/ui/style/colors';
import Label from './Label';
import Item from './Item';
import Channels from './Channels';
import NewsLink from './NewsLink';
import FeedbackLink from './FeedbackLink';
import AccountManagement from './AccountManagement';
const Sidebar = styled.div`
display: flex;
flex-direction: column;
padding: 0.75rem 0;
height: 100%;
width: 200px;
background: ${grayLighter};
box-sizing: border-box;
`;
const bottomSectionStyle = {
marginTop: 'auto',
};
const Group = styled.div`
margin: 0 0 1.5rem;
`;
const NavSidebar = props => (
<div>
{props.channels.length > 0 && <Sidebar>
<Group>
<Item href="/" {...props}>Home</Item>
</Group>
<Channels {...props} />
<div>
<Label>Tools</Label>
<Item href="/aggregates/" {...props}>Aggregates</Item>
<Item href="/reports/" {...props}>Reports</Item>
</div>
<div style={bottomSectionStyle}>
<AccountManagement {...props} />
<NewsLink>What's New</NewsLink>
<FeedbackLink email="hello+analyze@buffer.com">Send Feedback</FeedbackLink>
</div>
</Sidebar>}
</div>
);
NavSidebar.propTypes = {
channels: PropTypes.arrayOf(PropTypes.shape({
service: PropTypes.string,
})).isRequired,
};
const mapStateToProps = state => ({
channels: state.navSidebar.channels,
selectedProfileId: state.profiles.selectedProfile ? state.profiles.selectedProfile.id : '',
});
export default connect(
mapStateToProps,
)(NavSidebar);
|