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

Gas price dropdown #61

Merged
merged 10 commits into from
Jul 20, 2017
Merged

Gas price dropdown #61

merged 10 commits into from
Jul 20, 2017

Conversation

skubakdj
Copy link
Contributor

Implements the gas price slider in the header. I'm very new to React, Redux, and Flow, so please point out anything silly I might have done 😄

@skubakdj skubakdj requested review from dternyak and crptm July 19, 2017 03:09
@@ -1,6 +1,7 @@
// @flow
import React, { Component } from 'react';
import Navigation from './components/Navigation';
import GasPriceDropdown from './components/GasPriceDropdown.jsx';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip extensions pls

nodeSelection: Object.keys(NODES)[0]
nodeSelection: Object.keys(NODES)[0],
gasPriceGwei: 21,
gasPriceMaxGwei: 60,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if min/max values do not change during app lifetime, we probably dont want to have them in state

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to add new fields to type State

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch with the types! I'll make that change.

Yep, min/max values shouldn't change, so I'll move them out of state. I'll make them constants in the component, unless there's a better place for them to live 😄

import './GasPriceDropdown.scss';

export default class GasPriceDropdown extends Component {
constructor(props) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like i am the only one, but i think code w/o constructors (where they not needed) are easier to read.

Here you can delete whole consturctor thing and replace it with
export default class GasPriceDropdown extends Component { state = { expanded: false }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I definitely agree that's easier to read. I'll add that in 😄

Copy link
Contributor

@wbobeirne wbobeirne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Mostly just notes about styling.


render() {
// col-xs-4 applies padding not observed in MEWv3, this overrides
const paddingReset = { paddingLeft: '0px', paddingRight: '0px' };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've got an scss file, it would be better served to do styling in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree the scss file is underutilized at the moment. I'll move the styling over as suggested 😄

{this.state.expanded &&
<ul
className="dropdown-menu"
style={{ padding: '.5rem', minWidth: '300px' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to scss

whiteSpace: 'normal',
fontWeight: '300',
margin: '2rem 0 0'
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to scss

@@ -0,0 +1,17 @@
@import "../../../../common/sass/variables";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just to @import "common/sass/variables";, it looks from the top of the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Webstorm was throwing a warning with this path, but indeed it seems to work fine 👍

};

updateGasPrice = (e: SyntheticInputEvent) => {
this.props.changeGasPrice(e.currentTarget.valueAsNumber);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you call a prop function without checking for it first, you'll need to make the propType PropTypes.func.isRequired

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets get rid of proptypes :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah they do nothing in production anyway.

@skubakdj
Copy link
Contributor Author

@crptm & @wbobeirne, I think I addressed both of your comments with this latest round of commits. Let me know if I missed anything 👍

};

render() {
const gasPriceMinGwei = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can hoist it to module OR move to config/{something}

@@ -47,6 +50,11 @@ export default class Header extends Component {
Open-Source & Client-Side Ether Wallet · v3.6.0
</span>

<GasPriceDropdown
gasPriceGwei={this.props.gasPriceGwei}
changeGasPrice={this.props.changeGasPrice}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer value & onChange here

@crptm
Copy link
Contributor

crptm commented Jul 20, 2017

🚢 it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants