From 509ddaeaa0428e7dc7a2772b90a9428c050cb312 Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Tue, 23 Oct 2018 15:19:49 -0700 Subject: [PATCH] Implement Add Liquidity (#77) * CSS fixes * Add Liquidity UI and Validation * Finish Add Liquidity --- .../CurrencyInputPanel/currency-panel.scss | 21 +- src/components/CurrencyInputPanel/index.js | 33 +++- src/components/Tab/tab.scss | 9 +- src/ducks/web3connect.js | 47 +++-- src/index.js | 2 +- src/pages/Pool/AddLiquidity.js | 183 ++++++++++++++++-- src/variables.scss | 1 + 7 files changed, 242 insertions(+), 54 deletions(-) diff --git a/src/components/CurrencyInputPanel/currency-panel.scss b/src/components/CurrencyInputPanel/currency-panel.scss index 73b347bfe4..032e8fdb0a 100644 --- a/src/components/CurrencyInputPanel/currency-panel.scss +++ b/src/components/CurrencyInputPanel/currency-panel.scss @@ -2,25 +2,26 @@ .currency-input-panel { @extend %col-nowrap; + box-shadow: 0 4px 8px 0 rgba($royal-blue, 0.1); + position: relative; + border-radius: 1.25rem; + z-index: 200; &__container { - position: relative; - z-index: 200; border-radius: 1.25rem; - border: 0.5px solid $mercury-gray; + box-shadow: 0 0 0 .5px $mercury-gray; background-color: $white; - box-shadow: 0px 4px 4px 2px rgba($royal-blue, 0.05); &--error { - border: 0.5px solid $salmon-red; + box-shadow: 0 0 0 .5px $salmon-red; } &:focus-within { - border-color: $royal-blue; + box-shadow: 0 0 .5px .5px $malibu-blue; } &--error:focus-within { - border-color: $salmon-red; + box-shadow: 0 0 .5px .5px $salmon-red; } } @@ -93,6 +94,12 @@ background-image: url(../../assets/images/dropdown.svg); } } + + &--disabled { + .currency-input-panel__dropdown-icon { + opacity: 0; + } + } } &__sub-currency-select { diff --git a/src/components/CurrencyInputPanel/index.js b/src/components/CurrencyInputPanel/index.js index d8d0f08e78..89d8aed821 100644 --- a/src/components/CurrencyInputPanel/index.js +++ b/src/components/CurrencyInputPanel/index.js @@ -45,10 +45,13 @@ class CurrencyInputPanel extends Component { selectedTokens: PropTypes.array.isRequired, errorMessage: PropTypes.string, selectedTokenAddress: PropTypes.string, + disableTokenSelect: PropTypes.bool, + filteredTokens: PropTypes.arrayOf(PropTypes.string), }; static defaultProps = { selectedTokens: [], + filteredTokens: [], onCurrencySelected() {}, onValueChange() {}, selectedTokenAddress: '', @@ -64,19 +67,20 @@ class CurrencyInputPanel extends Component { }; createTokenList = () => { + const { filteredTokens } = this.props; let tokens = this.props.tokenAddresses.addresses; let tokenList = [ { value: 'ETH', label: 'ETH', address: 'ETH' } ]; for (let i = 0; i < tokens.length; i++) { - let entry = { value: '', label: '' }; - entry.value = tokens[i][0]; - entry.label = tokens[i][0]; - entry.address = tokens[i][1]; - tokenList.push(entry); - TOKEN_ADDRESS_TO_LABEL[tokens[i][1]] = tokens[i][0]; + let entry = { value: '', label: '' }; + entry.value = tokens[i][0]; + entry.label = tokens[i][0]; + entry.address = tokens[i][1]; + tokenList.push(entry); + TOKEN_ADDRESS_TO_LABEL[tokens[i][1]] = tokens[i][0]; } - return tokenList; + return tokenList.filter(({ address }) => !filteredTokens.includes(address)); }; onTokenSelect = (address) => { @@ -122,7 +126,12 @@ class CurrencyInputPanel extends Component { renderTokenList() { const tokens = this.createTokenList(); const { searchQuery } = this.state; - const { selectedTokens } = this.props; + const { selectedTokens, disableTokenSelect } = this.props; + + if (disableTokenSelect) { + return; + } + let results; if (!searchQuery) { @@ -196,6 +205,7 @@ class CurrencyInputPanel extends Component { value, onValueChange, selectedTokenAddress, + disableTokenSelect, } = this.props; return ( @@ -232,8 +242,13 @@ class CurrencyInputPanel extends Component { @@ -219,6 +363,7 @@ export default drizzleConnect( isConnected: Boolean(state.web3connect.account), account: state.web3connect.account, balances: state.web3connect.balances, + web3: state.web3connect.web3, exchangeAddresses: state.addresses.exchangeAddresses, }), dispatch => ({ diff --git a/src/variables.scss b/src/variables.scss index 03ae02311a..33b4ee6cae 100644 --- a/src/variables.scss +++ b/src/variables.scss @@ -11,6 +11,7 @@ $mine-shaft-gray: #2B2B2B; // Blue $zumthor-blue: #EBF4FF; +$malibu-blue: #5CA2FF; $royal-blue: #2F80ED; // Purple