Browse Source

fix(channelform): final MVP design touches

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
150341463e
  1. 10
      app/app.global.scss
  2. 9
      app/components/ChannelForm/ChannelForm.js
  3. 43
      app/components/ChannelForm/Footer.js
  4. 2
      app/components/ChannelForm/StepThree.scss
  5. 2
      app/components/ChannelForm/StepTwo.scss
  6. 6
      app/reducers/channelform.js
  7. 6
      app/reducers/channels.js
  8. 7
      app/routes/channels/containers/ChannelsContainer.js

10
app/app.global.scss

@ -106,6 +106,16 @@ body {
} }
} }
.buttonPrimary.inactive {
opacity: 0.5;
cursor: auto;
}
.buttonPrimary.inactive:active {
box-shadow: 0 3px 0 0 darken($main, 10%);
transform: none;
}
.buttonSecondary { .buttonSecondary {
background-color: $secondary; background-color: $secondary;
box-shadow: 0 3px 0 0 darken($secondary, 10%); box-shadow: 0 3px 0 0 darken($secondary, 10%);

9
app/components/ChannelForm/ChannelForm.js

@ -14,6 +14,7 @@ import styles from './ChannelForm.scss'
const ChannelForm = ({ const ChannelForm = ({
channelform, channelform,
openChannel,
closeChannelForm, closeChannelForm,
changeStep, changeStep,
setNodeKey, setNodeKey,
@ -21,6 +22,7 @@ const ChannelForm = ({
setPushAmount, setPushAmount,
channelFormHeader, channelFormHeader,
channelFormProgress, channelFormProgress,
stepTwoIsValid,
peers peers
}) => { }) => {
const renderStep = () => { const renderStep = () => {
@ -61,7 +63,12 @@ const ChannelForm = ({
{renderStep()} {renderStep()}
</div> </div>
<Footer step={channelform.step} changeStep={changeStep} /> <Footer
step={channelform.step}
changeStep={changeStep}
stepTwoIsValid={stepTwoIsValid}
submit={() => openChannel({ pubkey: channelform.node_key, local_amt: channelform.local_amt, push_amt: channelform.push_amt })}
/>
</ReactModal> </ReactModal>
) )
} }

43
app/components/ChannelForm/Footer.js

@ -3,42 +3,43 @@ import PropTypes from 'prop-types'
import { FaArrowLeft, FaArrowRight, FaCheck } from 'react-icons/lib/fa' import { FaArrowLeft, FaArrowRight, FaCheck } from 'react-icons/lib/fa'
import styles from './Footer.scss' import styles from './Footer.scss'
const Footer = ({ step, changeStep }) => { const Footer = ({ step, changeStep, stepTwoIsValid, submit }) => {
if ( step === 1 ) { return null } if ( step === 1 ) { return null }
if (step === 4 ) { // See if the next button on step 2 should be active
return ( const nextIsInactive = step === 2 && !stepTwoIsValid
<div className={styles.footer}>
<div className='buttonContainer'> // Function that's called when the user clicks "next" in the form
<div className='buttonPrimary'onClick={() => changeStep(step - 1)}> const nextFunc = () => {
Back if (nextIsInactive) { return }
</div>
</div> changeStep(step + 1)
<div className='buttonContainer' onClick={() => console.log('create this mf channel baby')}>
<div className='buttonPrimary'>
Submit
</div>
</div>
</div>
)
} }
const rightButtonText = step === 4 ? 'Submit' : 'Next'
const rightButtonOnClick = step === 4 ? () => submit() : nextFunc
return ( return (
<div className={styles.footer}> <div className={styles.footer}>
<div className='buttonContainer'> <div className='buttonContainer'>
<div className='buttonPrimary'onClick={() => changeStep(step - 1)}> <div className='buttonPrimary' onClick={() => changeStep(step - 1)}>
Back Back
</div> </div>
</div> </div>
<div className='buttonContainer' onClick={() => changeStep(step + 1)}> <div className='buttonContainer' onClick={rightButtonOnClick}>
<div className='buttonPrimary'> <div className={`buttonPrimary ${nextIsInactive && 'inactive'}`}>
Next {rightButtonText}
</div> </div>
</div> </div>
</div> </div>
) )
} }
Footer.propTypes = {} Footer.propTypes = {
step: PropTypes.number.isRequired,
changeStep: PropTypes.func.isRequired,
stepTwoIsValid: PropTypes.bool.isRequired,
submit: PropTypes.func.isRequired
}
export default Footer export default Footer

2
app/components/ChannelForm/StepThree.scss

@ -10,7 +10,7 @@
border-bottom: 1px solid $lightgrey; border-bottom: 1px solid $lightgrey;
h2 { h2 {
margin: 10px 0 20px 0; margin: 0 0 20px 0;
font-size: 28px; font-size: 28px;
} }

2
app/components/ChannelForm/StepTwo.scss

@ -10,7 +10,7 @@
border-bottom: 1px solid $lightgrey; border-bottom: 1px solid $lightgrey;
h2 { h2 {
margin: 10px 0 20px 0; margin: 0 0 20px 0;
font-size: 28px; font-size: 28px;
} }

6
app/reducers/channelform.js

@ -90,6 +90,7 @@ const ACTION_HANDLERS = {
const channelFormSelectors = {} const channelFormSelectors = {}
const channelFormStepSelector = state => state.channelform.step const channelFormStepSelector = state => state.channelform.step
const channelFormLocalAmountSelector = state => state.channelform.local_amt
channelFormSelectors.channelFormHeader = createSelector( channelFormSelectors.channelFormHeader = createSelector(
channelFormStepSelector, channelFormStepSelector,
@ -112,6 +113,11 @@ channelFormSelectors.channelFormProgress = createSelector(
step => ((step - 1) / 3) * 100 step => ((step - 1) / 3) * 100
) )
channelFormSelectors.stepTwoIsValid = createSelector(
channelFormLocalAmountSelector,
local_amt => local_amt > 0
)
export { channelFormSelectors } export { channelFormSelectors }
// ------------------------------------ // ------------------------------------

6
app/reducers/channels.js

@ -1,5 +1,6 @@
import { createSelector } from 'reselect' import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import { btc } from 'utils'
import { setError } from './error' import { setError } from './error'
// ------------------------------------ // ------------------------------------
// Constants // Constants
@ -77,7 +78,10 @@ export const fetchChannels = () => async (dispatch) => {
export const receiveChannels = (event, { channels, pendingChannels }) => dispatch => dispatch({ type: RECEIVE_CHANNELS, channels, pendingChannels }) export const receiveChannels = (event, { channels, pendingChannels }) => dispatch => dispatch({ type: RECEIVE_CHANNELS, channels, pendingChannels })
// Send IPC event for opening a channel // Send IPC event for opening a channel
export const openChannel = ({ pubkey, localamt, pushamt }) => (dispatch) => { export const openChannel = ({ pubkey, local_amt, push_amt }) => (dispatch) => {
const localamt = btc.btcToSatoshis(local_amt)
const pushamt = btc.btcToSatoshis(push_amt)
dispatch(openingChannel()) dispatch(openingChannel())
ipcRenderer.send('lnd', { msg: 'openChannel', data: { pubkey, localamt, pushamt } }) ipcRenderer.send('lnd', { msg: 'openChannel', data: { pubkey, localamt, pushamt } })
} }

7
app/routes/channels/containers/ChannelsContainer.js

@ -3,6 +3,7 @@ import { connect } from 'react-redux'
import { import {
fetchChannels, fetchChannels,
openChannel,
channelsSelectors channelsSelectors
} from 'reducers/channels' } from 'reducers/channels'
@ -25,6 +26,7 @@ import Channels from '../components/Channels'
const mapDispatchToProps = { const mapDispatchToProps = {
fetchChannels, fetchChannels,
openChannel,
openChannelForm, openChannelForm,
closeChannelForm, closeChannelForm,
@ -46,11 +48,13 @@ const mapStateToProps = state => ({
allChannels: channelsSelectors.allChannels(state), allChannels: channelsSelectors.allChannels(state),
currentTicker: tickerSelectors.currentTicker(state), currentTicker: tickerSelectors.currentTicker(state),
channelFormHeader: channelFormSelectors.channelFormHeader(state), channelFormHeader: channelFormSelectors.channelFormHeader(state),
channelFormProgress: channelFormSelectors.channelFormProgress(state) channelFormProgress: channelFormSelectors.channelFormProgress(state),
stepTwoIsValid: channelFormSelectors.stepTwoIsValid(state)
}) })
const mergeProps = (stateProps, dispatchProps, ownProps) => { const mergeProps = (stateProps, dispatchProps, ownProps) => {
const channelFormProps = { const channelFormProps = {
openChannel: dispatchProps.openChannel,
closeChannelForm: dispatchProps.closeChannelForm, closeChannelForm: dispatchProps.closeChannelForm,
changeStep: dispatchProps.changeStep, changeStep: dispatchProps.changeStep,
setNodeKey: dispatchProps.setNodeKey, setNodeKey: dispatchProps.setNodeKey,
@ -60,6 +64,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
channelform: stateProps.channelform, channelform: stateProps.channelform,
channelFormHeader: stateProps.channelFormHeader, channelFormHeader: stateProps.channelFormHeader,
channelFormProgress: stateProps.channelFormProgress, channelFormProgress: stateProps.channelFormProgress,
stepTwoIsValid: stateProps.stepTwoIsValid,
peers: stateProps.peers.peers peers: stateProps.peers.peers
} }

Loading…
Cancel
Save