-
Notifications
You must be signed in to change notification settings - Fork 60
Create priced button component - Closes #583 #585
Conversation
src/constants/fees.js
Outdated
export default { | ||
setSecondPassphrase: 5e8, | ||
send: 1e7, | ||
registerDelegate: 25e8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vote: 1e8.
is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
src/components/pricedButton/index.js
Outdated
} | ||
<Button label={props.label} | ||
primary={true} raised={true} | ||
className='next-button' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be more flexible, e.g. className={props.className}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments.
src/constants/fees.js
Outdated
@@ -0,0 +1,6 @@ | |||
export default { | |||
setSecondPassphrase: 5e8, | |||
send: 1e7, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer 0.1e8
for uniformity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
transition: all 0.3s cubic-bezier(0.55, 0, 0.55, 0.2); | ||
} | ||
.error { | ||
color: #dd2c00 !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to avoid the !important
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need. Preferred is that states override modules. https://smacss.com/
import PricedButton from './index'; | ||
|
||
chai.use(sinonChai); | ||
chai.use(chaiEnzyme()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you guys do this in every file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fee: 5e8, | ||
onClick: sinon.spy(), | ||
}; | ||
const insufficientBalance = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer the largest possible insufficient balance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
it('allows to click on Button', () => { | ||
wrapper.find(Button).simulate('click'); | ||
expect(props.onClick).to.have.been.calledWith(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer .calledWithExactly
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component is not supposed to pass anything to it's click handler. what's the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component is not passing anything. this is about the difference of calling with different arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with calledWithExactly
.
src/components/pricedButton/index.js
Outdated
import { fromRawLsk } from '../../utils/lsk'; | ||
import styles from './pricedButton.css'; | ||
|
||
const PricedButton = (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A pattern I like is to destructure props out here for less verbosity in the component body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/components/pricedButton/index.js
Outdated
<div className='primary-button'> | ||
{ | ||
props.fee && | ||
<span className={`${styles.fee} ${hasFunds ? '' : styles.error}`}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer parentheses around span
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is a better solution to change classnames
based on the state https://github.com/JedWatson/classnames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/components/pricedButton/index.js
Outdated
</span> | ||
} | ||
<Button label={props.label} | ||
primary={true} raised={true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer separate lines for separate props.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/components/pricedButton/index.js
Outdated
primary={true} raised={true} | ||
className={`next-button ${props.customClassName}`} | ||
disabled={props.disabled || (props.fee && !hasFunds)} | ||
onClick={props.onClick.bind(this)}/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is binding doing anything here? Seems like it should be the responsibility of whatever is passing the function down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
binding is the repressibility of presentational component. I believe it's the right place for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you expecting the value of this
to be?
expect(wrapper.find(Button)).to.have.length(1); | ||
}); | ||
|
||
describe('Sufficient credit', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sufficient funds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
}); | ||
}); | ||
|
||
describe('Insufficient credit', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insufficient funds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
text-align: right; | ||
margin: 0 16px; | ||
transition: all 0.3s cubic-bezier(0.55, 0, 0.55, 0.2); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space between selectors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/components/pricedButton/index.js
Outdated
<span className={`${styles.fee} ${hasFunds ? '' : styles.error}`}> | ||
{ | ||
hasFunds ? `Fee: ${fromRawLsk(props.fee)} LSK` : | ||
`Not enough credit to pay ${fromRawLsk(props.fee)} LSK fee` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insufficient funds for ${fromRawLsk(props.fee)} LSK fee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/components/pricedButton/index.js
Outdated
primary={true} raised={true} | ||
className={`next-button ${props.customClassName}`} | ||
disabled={props.disabled || (props.fee && !hasFunds)} | ||
onClick={props.onClick.bind(this)}/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onClick={props.onClick.bind(this)} />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Closes #583