2020-08-06 20:59:22 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Link } from 'react-router';
|
|
|
|
import styled from 'styled-components';
|
2020-08-07 19:09:17 +02:00
|
|
|
import { remSize, prop, common } from '../../theme';
|
|
|
|
import Header from './Header';
|
|
|
|
import IconButton from './IconButton';
|
|
|
|
import { ExitIcon } from '../../common/icons';
|
2020-08-06 20:59:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
const SidebarWrapper = styled.div`
|
|
|
|
height: 100%;
|
|
|
|
width: ${remSize(180)};
|
|
|
|
|
2020-08-11 18:00:36 +02:00
|
|
|
position: fixed;
|
2020-08-06 20:59:22 +02:00
|
|
|
z-index: 2;
|
|
|
|
left: 0;
|
|
|
|
|
|
|
|
background: white;
|
|
|
|
box-shadow: 0 6px 6px 0 rgba(0,0,0,0.10);
|
|
|
|
`;
|
|
|
|
|
2020-08-07 19:09:17 +02:00
|
|
|
const Sidebar = ({ title, onPressClose, children }) => (
|
2020-08-06 20:59:22 +02:00
|
|
|
<SidebarWrapper>
|
|
|
|
{title &&
|
2020-08-06 21:24:47 +02:00
|
|
|
<Header slim title={title} fixed={false}>
|
2020-08-07 23:32:50 +02:00
|
|
|
<IconButton onClick={onPressClose} icon={ExitIcon} aria-label="Return to ide view" />
|
2020-08-06 20:59:22 +02:00
|
|
|
</Header>}
|
2020-08-07 19:09:17 +02:00
|
|
|
{children}
|
2020-08-06 20:59:22 +02:00
|
|
|
</SidebarWrapper>
|
|
|
|
);
|
|
|
|
|
|
|
|
Sidebar.propTypes = {
|
|
|
|
title: PropTypes.string,
|
2020-08-07 19:09:17 +02:00
|
|
|
onPressClose: PropTypes.func,
|
|
|
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]),
|
2020-08-06 20:59:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Sidebar.defaultProps = {
|
|
|
|
title: null,
|
2020-08-07 19:09:17 +02:00
|
|
|
children: [],
|
|
|
|
onPressClose: () => {}
|
2020-08-06 20:59:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default Sidebar;
|