You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.8 KiB
71 lines
1.8 KiB
4 years ago
|
import React, { Component } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import ReactCSSTransitionGroup from 'react-transition-group/CSSTransitionGroup';
|
||
|
import CustomizeGas from '../gas-customization/gas-modal-page-container';
|
||
6 years ago
|
|
||
|
export default class Sidebar extends Component {
|
||
|
static propTypes = {
|
||
|
sidebarOpen: PropTypes.bool,
|
||
|
hideSidebar: PropTypes.func,
|
||
6 years ago
|
sidebarShouldClose: PropTypes.bool,
|
||
6 years ago
|
transitionName: PropTypes.string,
|
||
|
type: PropTypes.string,
|
||
6 years ago
|
sidebarProps: PropTypes.object,
|
||
6 years ago
|
onOverlayClose: PropTypes.func,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
4 years ago
|
renderOverlay() {
|
||
4 years ago
|
const { onOverlayClose } = this.props;
|
||
6 years ago
|
|
||
5 years ago
|
return (
|
||
|
<div
|
||
|
className="sidebar-overlay"
|
||
|
onClick={() => {
|
||
4 years ago
|
onOverlayClose?.();
|
||
|
this.props.hideSidebar();
|
||
5 years ago
|
}}
|
||
|
/>
|
||
4 years ago
|
);
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
renderSidebarContent() {
|
||
4 years ago
|
const { type, sidebarProps = {} } = this.props;
|
||
4 years ago
|
const { transaction = {}, onSubmit } = sidebarProps;
|
||
6 years ago
|
switch (type) {
|
||
6 years ago
|
case 'customize-gas':
|
||
4 years ago
|
return (
|
||
|
<div className="sidebar-left">
|
||
4 years ago
|
<CustomizeGas transaction={transaction} onSubmit={onSubmit} />
|
||
4 years ago
|
</div>
|
||
4 years ago
|
);
|
||
6 years ago
|
default:
|
||
4 years ago
|
return null;
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
componentDidUpdate(prevProps) {
|
||
6 years ago
|
if (!prevProps.sidebarShouldClose && this.props.sidebarShouldClose) {
|
||
4 years ago
|
this.props.hideSidebar();
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const { transitionName, sidebarOpen, sidebarShouldClose } = this.props;
|
||
6 years ago
|
|
||
|
return (
|
||
|
<div>
|
||
|
<ReactCSSTransitionGroup
|
||
|
transitionName={transitionName}
|
||
|
transitionEnterTimeout={300}
|
||
|
transitionLeaveTimeout={200}
|
||
|
>
|
||
4 years ago
|
{sidebarOpen && !sidebarShouldClose
|
||
|
? this.renderSidebarContent()
|
||
|
: null}
|
||
6 years ago
|
</ReactCSSTransitionGroup>
|
||
4 years ago
|
{sidebarOpen && !sidebarShouldClose ? this.renderOverlay() : null}
|
||
6 years ago
|
</div>
|
||
4 years ago
|
);
|
||
6 years ago
|
}
|
||
|
}
|