Commit d5679be5 authored by Jeff Reiner's avatar Jeff Reiner

refactor transaction details modal into expanding panel

parent ff628445
@import '../../variables.scss'; @import "../../variables.scss";
.contextual-info { .contextual-info {
&__summary-wrapper { &__summary-wrapper {
background-color: $concrete-gray; color: $dove-gray;
border-top-left-radius: 1rem; font-size: 0.75rem;
border-top-right-radius: 1rem;
padding: 1rem;
color: #737373;
font-size: .75rem;
text-align: center; text-align: center;
cursor: pointer; margin-top: 1rem;
padding-top: 1rem;
} }
&--error { &--error {
color: $salmon-red; color: $salmon-red;
} }
&__summary-modal { &__details {
background-color: $white; background-color: $concrete-gray;
position: relative; padding: 1.5rem;
bottom: 12rem; border-radius: 1rem;
min-height: 12rem; font-size: 0.75rem;
max-height: 12rem; margin-top: 1rem;
z-index: 2000;
padding: 1rem;
border-top-left-radius: 1rem;
border-top-right-radius: 1rem;
transition: 250ms ease-in-out;
@media only screen and (min-width : 768px) {
max-width: 560px;
position: absolute;
margin-left: auto;
margin-right: auto;
border-radius: 1rem;
padding-bottom: 1rem;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin-top: 4rem;
}
.swap__open-details-container {
padding: 0.5rem 0;
margin-bottom: 1rem;
cursor: pointer;
}
} }
&__open-details-container { &__open-details-container {
cursor: pointer;
@extend %row-nowrap; @extend %row-nowrap;
align-items: center; align-items: center;
justify-content: space-between; justify-content: center;
font-size: .75rem; font-size: 0.75rem;
color: $royal-blue; color: $royal-blue;
img { span {
height: .75rem; margin-right: 12px;
width: .75rem;
} }
}
&__modal-button { img {
padding: 0.5rem 0; height: 0.75rem;
margin-bottom: 1rem; width: 0.75rem;
}
} }
} }
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import c from 'classnames'; import c from 'classnames';
import { CSSTransitionGroup } from "react-transition-group";
import Modal from '../Modal';
import DropdownBlue from "../../assets/images/dropdown-blue.svg"; import DropdownBlue from "../../assets/images/dropdown-blue.svg";
import DropupBlue from "../../assets/images/dropup-blue.svg"; import DropupBlue from "../../assets/images/dropup-blue.svg";
import './contextual-info.scss'; import './contextual-info.scss';
class ContextualInfo extends Component { class ContextualInfo extends Component {
static propTypes = { static propTypes = {
openModalText: PropTypes.string, openDetailsText: PropTypes.string,
renderTransactionDetails: PropTypes.func, renderTransactionDetails: PropTypes.func,
contextualInfo: PropTypes.string, contextualInfo: PropTypes.string,
modalClass: PropTypes.string,
isError: PropTypes.bool, isError: PropTypes.bool,
}; };
static defaultProps = { static defaultProps = {
openModalText: 'Transaction Details', openDetailsText: 'Transaction Details',
closeDetailsText: 'Hide Details',
renderTransactionDetails() {}, renderTransactionDetails() {},
contextualInfo: '', contextualInfo: '',
modalClass: '',
isError: false, isError: false,
}; };
state = { state = {
showDetailModal: false, showDetails: false,
}; };
renderModal() { renderDetails() {
if (!this.state.showDetailModal) { if (!this.state.showDetails) {
return null; return null;
} }
const { modalClass } = this.props;
return ( return (
<Modal key="modal" onClose={() => this.setState({ showDetailModal: false })}> <div className="contextual-info__details">
<CSSTransitionGroup {this.props.renderTransactionDetails()}
transitionName="summary-modal" </div>
transitionAppear={true} )
transitionLeave={true}
transitionAppearTimeout={200}
transitionLeaveTimeout={200}
transitionEnterTimeout={200}
>
<div className={c('contextual-info__summary-modal', modalClass)}>
<div
key="open-details"
className="contextual-info__open-details-container contextual-info__modal-button"
onClick={() => this.setState({showDetailModal: false})}
>
<span>Transaction Details</span>
<img src={DropupBlue} />
</div>
{this.props.renderTransactionDetails()}
</div>
</CSSTransitionGroup>
</Modal>
);
} }
render() { render() {
const { const {
openModalText, openDetailsText,
closeDetailsText,
contextualInfo, contextualInfo,
isError, isError,
} = this.props; } = this.props;
...@@ -81,12 +58,23 @@ class ContextualInfo extends Component { ...@@ -81,12 +58,23 @@ class ContextualInfo extends Component {
<div <div
key="open-details" key="open-details"
className="contextual-info__summary-wrapper contextual-info__open-details-container" className="contextual-info__summary-wrapper contextual-info__open-details-container"
onClick={() => this.setState({showDetailModal: true})} onClick={() => this.setState((prevState) => {
return { showDetails: !prevState.showDetails }
})}
> >
<span>{openModalText}</span> {!this.state.showDetails ? (
<img src={DropdownBlue} /> <>
<span>{openDetailsText}</span>
<img src={DropdownBlue} />
</>
) : (
<>
<span>{closeDetailsText}</span>
<img src={DropupBlue} />
</>
)}
</div>, </div>,
this.renderModal() this.renderDetails()
] ]
} }
} }
......
...@@ -559,6 +559,7 @@ class AddLiquidity extends Component { ...@@ -559,6 +559,7 @@ class AddLiquidity extends Component {
<OversizedPanel hideBottom> <OversizedPanel hideBottom>
{ this.renderInfo() } { this.renderInfo() }
</OversizedPanel> </OversizedPanel>
{ this.renderSummary(inputError, outputError) }
<div className="pool__cta-container"> <div className="pool__cta-container">
<button <button
className={classnames('pool__cta-btn', { className={classnames('pool__cta-btn', {
...@@ -571,8 +572,7 @@ class AddLiquidity extends Component { ...@@ -571,8 +572,7 @@ class AddLiquidity extends Component {
Add Liquidity Add Liquidity
</button> </button>
</div> </div>
</div>, </div>
this.renderSummary(inputError, outputError)
]; ];
} }
} }
......
...@@ -149,7 +149,7 @@ class CreateExchange extends Component { ...@@ -149,7 +149,7 @@ class CreateExchange extends Component {
if (errorMessage) { if (errorMessage) {
return ( return (
<div className="create-exchange__summary-panel"> <div className="create-exchange__summary-panel">
<div className="create-exchange__summary-text">{errorMessage}</div> <div className="create-exchange__summary-text create-exchange--error">{errorMessage}</div>
</div> </div>
) )
} }
...@@ -200,6 +200,7 @@ class CreateExchange extends Component { ...@@ -200,6 +200,7 @@ class CreateExchange extends Component {
</div> </div>
</div> </div>
</OversizedPanel> </OversizedPanel>
{ this.renderSummary() }
<div className="pool__cta-container"> <div className="pool__cta-container">
<button <button
className={classnames('pool__cta-btn', { className={classnames('pool__cta-btn', {
...@@ -211,7 +212,6 @@ class CreateExchange extends Component { ...@@ -211,7 +212,6 @@ class CreateExchange extends Component {
Create Exchange Create Exchange
</button> </button>
</div> </div>
{ this.renderSummary() }
</div> </div>
); );
} }
......
...@@ -377,6 +377,7 @@ class RemoveLiquidity extends Component { ...@@ -377,6 +377,7 @@ class RemoveLiquidity extends Component {
</div> </div>
</OversizedPanel> </OversizedPanel>
{ this.renderOutput() } { this.renderOutput() }
{ this.renderSummary(errorMessage) }
<div className="pool__cta-container"> <div className="pool__cta-container">
<button <button
className={classnames('pool__cta-btn', { className={classnames('pool__cta-btn', {
...@@ -389,8 +390,7 @@ class RemoveLiquidity extends Component { ...@@ -389,8 +390,7 @@ class RemoveLiquidity extends Component {
Remove Liquidity Remove Liquidity
</button> </button>
</div> </div>
</div>, </div>
this.renderSummary(errorMessage)
]; ];
} }
} }
......
...@@ -113,7 +113,9 @@ ...@@ -113,7 +113,9 @@
} }
&__item { &__item {
margin-bottom: .5rem; &:not(:last-child) {
margin-bottom: .5rem;
}
} }
} }
} }
...@@ -173,20 +175,18 @@ ...@@ -173,20 +175,18 @@
.create-exchange { .create-exchange {
&__summary-panel { &__summary-panel {
position: absolute; color: $dove-gray;
bottom: 0;
left: 0;
background-color: $concrete-gray;
width: 100%;
text-align: center; text-align: center;
border-top-left-radius: .625rem; margin-top: 1rem;
border-top-right-radius: .625rem; padding-top: 1rem;
} }
&__summary-text { &__summary-text {
padding: .75rem;
font-size: .75rem; font-size: .75rem;
color: $dove-gray; }
&--error {
color: $salmon-red;
} }
} }
......
...@@ -770,6 +770,7 @@ class Send extends Component { ...@@ -770,6 +770,7 @@ class Send extends Component {
onChange={address => this.setState({recipient: address})} onChange={address => this.setState({recipient: address})}
/> />
{ this.renderExchangeRate() } { this.renderExchangeRate() }
{ this.renderSummary(inputError, outputError) }
<div className="swap__cta-container"> <div className="swap__cta-container">
<button <button
className={classnames('swap__cta-btn', { className={classnames('swap__cta-btn', {
...@@ -782,7 +783,6 @@ class Send extends Component { ...@@ -782,7 +783,6 @@ class Send extends Component {
</button> </button>
</div> </div>
</div> </div>
{ this.renderSummary(inputError, outputError) }
</div> </div>
); );
} }
......
...@@ -743,6 +743,7 @@ class Swap extends Component { ...@@ -743,6 +743,7 @@ class Swap extends Component {
disableUnlock disableUnlock
/> />
{ this.renderExchangeRate() } { this.renderExchangeRate() }
{ this.renderSummary(inputError, outputError) }
<div className="swap__cta-container"> <div className="swap__cta-container">
<button <button
className={classnames('swap__cta-btn', { className={classnames('swap__cta-btn', {
...@@ -755,7 +756,6 @@ class Swap extends Component { ...@@ -755,7 +756,6 @@ class Swap extends Component {
</button> </button>
</div> </div>
</div> </div>
{ this.renderSummary(inputError, outputError) }
</div> </div>
); );
} }
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
&__cta-container { &__cta-container {
display: flex; display: flex;
margin-top: 1.5rem; margin-top: 1rem;
} }
&__cta-btn { &__cta-btn {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment