Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring. Swap UI. Swap deposit window: different token standards / evm coins #4549

Merged
merged 15 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/core/swap.app/constants/COINS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ export const COIN_MODEL = Object.freeze({
AB: 'AB' // Account/Balance model
})

// TODO: change this structure
// 1) here isn't only coins (rename it?)
// 2) we can't add currencies with identical names
// example: identical tokens but on different blockchains
export const COIN_DATA = {
'BTC': {
ticker: 'BTC',
Expand Down
3 changes: 2 additions & 1 deletion src/front/client/scss/config/vars/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ $notice-color: #8e9aa3;
$color-brand: #6144e5;
$color-f-brightest: #fff;
$color-f-error: #e32950;
$color-good: #4dd3ab;
$color-success: #0CCF14;
$color-good: #3de25b;
$color-bad: #f56e85;
$color-warning: #ffba00;
$color-link: #007bff;
9 changes: 0 additions & 9 deletions src/front/shared/components/modal/Modal/Modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,8 @@
}

.closeButton {
width: 20px;
height: 20px;
opacity: 0.5;
transition: opacity 0.33s $ease-out-quadratic;
position: absolute;
right: 20px;

&:hover {
opacity: 1;
transition: none;
}
}

@keyframes delayClose {
Expand Down
3 changes: 1 addition & 2 deletions src/front/shared/components/modal/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ export default class Modal extends Component<ModalProps, null> {
<div styleName={titleStyleName} role="title">{title}</div>
{
showCloseButton && !disableClose && (
//@ts-ignore
<CloseIcon styleName={`closeButton${delayClose ? ' delayClose' : ''}`} onClick={this.close} data-testid="modalCloseIcon" />
<CloseIcon styleName={`closeButton ${delayClose ? 'delayClose' : ''}`} onClick={this.close} data-testid="modalCloseIcon" />
)
}
</WidthContainer>
Expand Down
9 changes: 1 addition & 8 deletions src/front/shared/components/modal/ModalBox/ModalBox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,10 @@
}

.closeButton {
width: 20px;
height: 20px;
opacity: 0.5;
transition: opacity 0.33s $ease-out-quadratic;
position: absolute;
right: 20px;
&:hover {
opacity: 1;
transition: none;
}
}

@keyframes delayClose {
0% {
opacity: 0;
Expand Down
3 changes: 1 addition & 2 deletions src/front/shared/components/modal/ModalBox/ModalBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export default class ModalBox extends Component<any, any> {
//@ts-ignore */}
<WidthContainer styleName="headerContent">
<div styleName="title">{title}</div>
{/*
//@ts-ignore */}

<CloseIcon styleName="closeButton" onClick={onClose} />
</WidthContainer>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/front/shared/components/modals/Alert/AlertModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
position: relative;
}

.closeButton {
position: absolute;
right: 0.4em;
width: 1em;
height: 1em;
}

.title {
width: 100%;
padding: 0 64px;
line-height: 18px;
font-size: 20px;
font-weight: 700;
Expand Down
21 changes: 16 additions & 5 deletions src/front/shared/components/modals/Alert/AlertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Button } from 'components/controls'
import { injectIntl, IntlShape, defineMessages } from 'react-intl'
import { constants } from 'helpers'
import WidthContainer from 'components/layout/WidthContainer/WidthContainer'
import CloseIcon from 'components/ui/CloseIcon/CloseIcon'

const isDark = localStorage.getItem(constants.localStorage.isDark)

Expand All @@ -32,6 +33,7 @@ type AlertModalProps = {
dashboardModalsAllowed
onClose: () => void
data: {
canClose: boolean
dontClose: boolean
okButtonAutoWidth: boolean
onClose: () => void
Expand All @@ -48,7 +50,7 @@ type AlertModalProps = {
}))
@cssModules(styles)
class AlertModal extends React.Component<AlertModalProps, null> {
handleClose = () => {
closeWithCustomAction = () => {
const {
name,
data,
Expand All @@ -71,27 +73,33 @@ class AlertModal extends React.Component<AlertModalProps, null> {
actions.modals.close(name)
}

closeModal = () => {
const { name } = this.props

actions.modals.close(name)
}

handleOk = () => {
const {
name,
data: {
callbackOk,
},
} = this.props

if (typeof callbackOk === `function`) {
if (callbackOk()) {
actions.modals.close(name)
this.closeModal()
}
} else {
this.handleClose()
this.closeWithCustomAction()
}
}

render() {
const {
intl,
data: {
canClose,
title,
message,
labelOk,
Expand All @@ -111,7 +119,6 @@ class AlertModal extends React.Component<AlertModalProps, null> {
return (
<div className={cx({
[styles['modal-overlay']]: true,
[styles['modal-overlay_dashboardView']]: dashboardModalsAllowed
})}>
<div className={cx({
[styles.modal]: true,
Expand All @@ -123,6 +130,10 @@ class AlertModal extends React.Component<AlertModalProps, null> {
//@ts-ignore */}
<WidthContainer styleName="headerContent">
<div styleName="title">{labels.title}</div>

{canClose && (
<CloseIcon styleName="closeButton" onClick={this.closeModal} />
)}
</WidthContainer>
</div>
<div styleName="content">
Expand Down
4 changes: 1 addition & 3 deletions src/front/shared/components/modals/AlertWindow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class AlertWindow extends Component<any, any> {
const { locale } = intl

if (actionType === 'deposit') {
//@ts-ignore: strictNullChecks
actions.modals.open(constants.modals.ReceiveModal, {
currency,
address,
Expand Down Expand Up @@ -94,8 +93,7 @@ class AlertWindow extends Component<any, any> {
//@ts-ignore */}
<WidthContainer styleName="headerContent">
<div styleName="title">{labels.title}</div>
{/*
//@ts-ignore */}

{canClose && (<CloseIcon styleName="closeButton" onClick={this.handleClosePopup} />)}
</WidthContainer>
</div>
Expand Down
14 changes: 3 additions & 11 deletions src/front/shared/components/modals/AlertWindow/styles.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
.header {
padding: 16px 0;
}
padding: 16px 0;
}

.closeButton {
width: 20px;
height: 20px;
opacity: 0.5;
transition: opacity 0.33s $ease-out-quadratic;
position: absolute;
right: 20px;

&:hover {
opacity: 1;
transition: none;
}
}

.headerContent {
height: 100%;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class ConnectWalletModal extends React.Component<any, null> {
<div
className={cx({
[styles['modal-overlay']]: true,
[styles['modal-overlay_dashboardView']]: dashboardModalsAllowed,
})}
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,9 @@
}

.closeButton {
width: 20px;
height: 20px;
opacity: 0.5;
transition: opacity .33s $ease-out-quadratic;
position: absolute;
right: 33px;
top: 32px;

&:hover {
opacity: 1;
transition: none;
}
}

.modal-overlay {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class CurrencyAction extends React.Component<any, any> {
return (
<div styleName={cx({
"modal-overlay": true,
"modal-overlay_dashboardView": dashboardView,
"dark": isDark,
})}>
<div styleName={cx({
Expand All @@ -104,8 +103,7 @@ class CurrencyAction extends React.Component<any, any> {
})}>
<div styleName="header">
<p styleName="title">{context}</p>
{/*
//@ts-ignore */}

<CloseIcon styleName="closeButton" onClick={this.handleClose} data-testid="modalCloseIcon" />
</div>
<div styleName={cx({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const langs = defineMessages({
})

@connect(
({ user: { activeFiat }, user }) => ({ activeFiat, user })
({ user }) => ({ user })
)
@withRouter
@cssModules({ ...styles, ...ownStyles }, { allowMultiple: true })
Expand Down
53 changes: 9 additions & 44 deletions src/front/shared/components/ui/CloseIcon/CloseIcon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
background: none;
border: 0;
outline: none;
-webkit-tap-highlight-color: transparent;
width: 20px;
height: 20px;
opacity: 0.5;
transition: opacity .33s $ease-out-quadratic;

&:hover {
opacity: 1;
transition: none;
}

&.dark {
.icon {
Expand All @@ -12,49 +20,6 @@
background-color: white;
}
}

}

&.whiteColor {
.icon {
&::before,
&::after {
background-color: #fff;
}
}

&:hover {

.icon {

&::before,
&::after {
background-color: $color-brand;
}
}
}
}

&.brandColor {

.icon {

&::before,
&::after {
background-color: $color-brand;
}
}

&:hover {

.icon {

&::before,
&::after {
background-color: #000;
}
}
}
}
}

Expand Down
19 changes: 8 additions & 11 deletions src/front/shared/components/ui/CloseIcon/CloseIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import React from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'
import { constants } from 'helpers'

import cssModules from 'react-css-modules'
import styles from './CloseIcon.scss'


const isDark = localStorage.getItem(constants.localStorage.isDark)

const CloseIcon = ({ whiteColor, brandColor, onClick, ...rest }) => {
type ComponentProps = {
onClick: (...args: any) => void
styleName: string
}

const CloseIcon = (props: ComponentProps) => {
const { onClick, styleName: externalName, ...rest } = props

const styleName = cx('button', {
'whiteColor': whiteColor,
'brandColor': brandColor,
'dark': isDark,
})

Expand All @@ -23,10 +26,4 @@ const CloseIcon = ({ whiteColor, brandColor, onClick, ...rest }) => {
)
}

CloseIcon.propTypes = {
whiteColor: PropTypes.bool,
brandColor: PropTypes.bool,
}


export default cssModules(CloseIcon, styles, { allowMultiple: true })
2 changes: 1 addition & 1 deletion src/front/shared/components/ui/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ThemeTooltip from './ThemeTooltip'
import styles from './Tooltip.scss'


const Tooltip = ({ mark = true, children, id, dontHideMobile = null, place = null }) => (
const Tooltip = ({ mark = true, children, id, dontHideMobile = false, place = null }) => (
<Fragment>
{mark ?
<span data-tip data-for={id} styleName={`tooltip isMark ${dontHideMobile ? 'tooltip_truesight' : ''}`}>
Expand Down
Loading