Add component common/SidePanel
Change-Id: If5d1395b4c679717ffae4f68d0c5042adfce9c3f
This commit is contained in:
parent
2db689a16d
commit
f116bfe1f7
51
src/features/common/SidePanel.js
Normal file
51
src/features/common/SidePanel.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { NavLink } from 'react-router-dom';
|
||||||
|
import matrixLogo from '../../images/matrix-logo.svg';
|
||||||
|
import * as actions from './redux/actions';
|
||||||
|
|
||||||
|
export class SidePanel extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
common: PropTypes.object.isRequired,
|
||||||
|
actions: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="common-side-panel">
|
||||||
|
<div className="header">
|
||||||
|
<img src={matrixLogo} className="app-logo" alt="logo" />
|
||||||
|
</div>
|
||||||
|
<ul className="nav">
|
||||||
|
<li>
|
||||||
|
<NavLink to="/user-admin">Users</NavLink>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<NavLink to="/room-admin">Rooms</NavLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
function mapStateToProps(state) {
|
||||||
|
return {
|
||||||
|
common: state.common,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
function mapDispatchToProps(dispatch) {
|
||||||
|
return {
|
||||||
|
actions: bindActionCreators({ ...actions }, dispatch),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps,
|
||||||
|
)(SidePanel);
|
37
src/features/common/SidePanel.scss
Normal file
37
src/features/common/SidePanel.scss
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
@import '../../styles/mixins';
|
||||||
|
|
||||||
|
.common-side-panel {
|
||||||
|
position: fixed;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: auto;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
margin: 0;
|
||||||
|
width: 260px;
|
||||||
|
height: 100%;
|
||||||
|
background-color: #EEE;
|
||||||
|
|
||||||
|
.app-logo {
|
||||||
|
margin: 30px;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul,
|
||||||
|
li {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
padding: 8px;
|
||||||
|
padding-left: 24px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
a.active {
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #CCC;
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
export { default as PageNotFound } from './PageNotFound';
|
export { default as PageNotFound } from './PageNotFound';
|
||||||
|
export { default as SidePanel } from './SidePanel';
|
||||||
|
@ -1 +1,2 @@
|
|||||||
@import '../../styles/mixins';
|
@import '../../styles/mixins';
|
||||||
|
@import './SidePanel';
|
||||||
|
19
tests/features/common/SidePanel.test.js
Normal file
19
tests/features/common/SidePanel.test.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
import { SidePanel } from '../../../src/features/common/SidePanel';
|
||||||
|
|
||||||
|
describe('common/SidePanel', () => {
|
||||||
|
it('renders node with correct class name', () => {
|
||||||
|
const props = {
|
||||||
|
common: {},
|
||||||
|
actions: {},
|
||||||
|
};
|
||||||
|
const renderedComponent = shallow(
|
||||||
|
<SidePanel {...props} />
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
renderedComponent.find('.common-side-panel').length
|
||||||
|
).toBe(1);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user