1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-18 09:12:55 +00:00
seahub/frontend/src/components/side-panel.js

50 lines
1.6 KiB
JavaScript
Raw Normal View History

import React from 'react';
2018-10-16 10:19:51 +00:00
import PropTypes from 'prop-types';
import classnames from 'classnames';
import Logo from './logo';
import MainSideNav from './main-side-nav';
import { SIDE_PANEL_FOLDED_WIDTH } from '../constants';
2018-10-16 10:19:51 +00:00
const propTypes = {
isSidePanelClosed: PropTypes.bool,
currentTab: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onCloseSidePanel: PropTypes.func,
tabItemClick: PropTypes.func,
children: PropTypes.object,
showLogoOnlyInMobile: PropTypes.bool,
isSidePanelFolded: PropTypes.bool,
toggleFoldSideNav: PropTypes.func
2018-10-16 10:19:51 +00:00
};
class SidePanel extends React.Component {
render() {
const { children, isSidePanelFolded, showLogoOnlyInMobile = false } = this.props;
const style = isSidePanelFolded ? { flexBasis: SIDE_PANEL_FOLDED_WIDTH } : {};
return (
<div className={classnames('side-panel', { 'side-panel-folded': isSidePanelFolded, 'left-zero': !this.props.isSidePanelClosed })} style={style}>
<div className={'side-panel-north'}>
<Logo
onCloseSidePanel={this.props.onCloseSidePanel}
showLogoOnlyInMobile={showLogoOnlyInMobile}
/>
</div>
<div className="side-panel-center">
{children ? children : (
<MainSideNav
tabItemClick={this.props.tabItemClick}
currentTab={this.props.currentTab}
isSidePanelFolded={isSidePanelFolded}
toggleFoldSideNav={this.props.toggleFoldSideNav}
/>
)}
</div>
</div>
);
}
}
2018-10-16 10:19:51 +00:00
SidePanel.propTypes = propTypes;
export default SidePanel;