From 50385cf3ef27d31d1f39e5b72e77c31736167489 Mon Sep 17 00:00:00 2001 From: olekon Date: Sat, 9 Oct 2021 13:31:19 +0700 Subject: [PATCH] Fix contract card buttons --- src/components/contract/ContractForm.jsx | 2 +- src/components/contract/ContractsList.jsx | 43 ++++++++++------------ src/components/contract/ContractsList.scss | 8 ++++ src/scripts/contractLogic.js | 4 +- webpack.config.js | 22 ++--------- 5 files changed, 35 insertions(+), 44 deletions(-) diff --git a/src/components/contract/ContractForm.jsx b/src/components/contract/ContractForm.jsx index 96511f7..8409efe 100644 --- a/src/components/contract/ContractForm.jsx +++ b/src/components/contract/ContractForm.jsx @@ -41,7 +41,7 @@ class ContractForm extends React.Component { this.formRef.current.validateFields(); } - handleSubmit(values) { + handleSubmit(values) { this.props.onAddContract( values.name, values.address, diff --git a/src/components/contract/ContractsList.jsx b/src/components/contract/ContractsList.jsx index c19e37c..6ce5377 100644 --- a/src/components/contract/ContractsList.jsx +++ b/src/components/contract/ContractsList.jsx @@ -24,7 +24,7 @@ class ContractsList extends React.Component { this.closeModal = this.closeModal.bind(this); this.handleAddButton = this.handleAddButton.bind(this); this.handleDeleteButton = this.handleDeleteButton.bind(this); - this.renderTitle = this.renderTitle.bind(this); + this.renderCardControls = this.renderCardControls.bind(this); this.showConfirmationModal = this.showConfirmationModal.bind(this); this.closeConfirmationModal = this.closeConfirmationModal.bind(this); this.onConfirmedDelete = this.onConfirmedDelete.bind(this); @@ -85,28 +85,23 @@ class ContractsList extends React.Component { }); } - renderTitle(contract) { + renderCardControls(contract) { return ( <> - {contract.name} - - + +
+ + +
); } @@ -138,11 +133,11 @@ class ContractsList extends React.Component { [styles.contractCard]: true, })} key={contract.address} + extra={this.renderCardControls(contract)} > } - title={this.renderTitle(contract)} + title={contract.name} description={shortenEthAddress(contract.address, 4)} /> @@ -159,7 +154,7 @@ class ContractsList extends React.Component { onCancel={this.closeConfirmationModal} maskClosable={false} > -

{`Really delete '${this.state.deletingContract? this.state.deletingContract.name: ""}'?`}

+

{`Really delete '${this.state.deletingContract ? this.state.deletingContract.name : ''}'?`}

); diff --git a/src/components/contract/ContractsList.scss b/src/components/contract/ContractsList.scss index 54a1125..4a28a0f 100644 --- a/src/components/contract/ContractsList.scss +++ b/src/components/contract/ContractsList.scss @@ -12,6 +12,14 @@ background-color: #f0f0f0; opacity: 1; } + + :global(.ant-card-extra) { + display: flex; + align-items: center; + justify-content: space-between; + margin-left: 0; + width: 100%; + } } .addButton { diff --git a/src/scripts/contractLogic.js b/src/scripts/contractLogic.js index 10dd7b6..c48bdae 100644 --- a/src/scripts/contractLogic.js +++ b/src/scripts/contractLogic.js @@ -71,12 +71,14 @@ export const editContract = function ( networkId, abiString ) { - const current = getContract(contractList, contract.name, networkId); + console.log(networkId); + const current = getContract(contractList, contract.name, contract.networkId); current.name = name; current.address = address; current.networkId = networkId; current.abi = JSON.parse(abiString); storage.saveContracts(contractList); + console.log(current); return contractList; }; diff --git a/webpack.config.js b/webpack.config.js index 4ae023d..8021124 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,9 +3,7 @@ const fs = require('fs'); const webpack = require('webpack'); const lessToJs = require('less-vars-to-js'); -const themeVariables = lessToJs( - fs.readFileSync(path.join(__dirname, './ant-override.less'), 'utf8') -); +const themeVariables = lessToJs(fs.readFileSync(path.join(__dirname, './ant-override.less'), 'utf8')); module.exports = { resolve: { @@ -82,39 +80,27 @@ module.exports = { loader: 'css-loader', options: { modules: true, - localIdentName: - '[name]__[local]__[contenthash:base64:5]', + localIdentName: '[name]__[local]__[contenthash:base64:5]', }, }, ], }, { - test: /\.scss$/, - exclude: /app\.scss$/, + test: /\.scss$/, use: [ 'style-loader', { loader: 'css-loader', options: { modules: true, - localIdentName: - '[name]__[local]__[contenthash:base64:5]', + localIdentName: '[name]__[local]__[contenthash:base64:5]', }, }, { loader: 'sass-loader', - // options: { - // modules: true, - // localIdentName: - // '[name]__[local]__[contenthash:base64:5]', - // }, }, ], }, - { - test: /app\.scss$/, - use: ['style-loader', 'css-loader', 'sass-loader'], - }, { test: /\.less$/, use: [