Skip to content

Commit

Permalink
Add diff scrub button
Browse files Browse the repository at this point in the history
  • Loading branch information
mantovanig committed Jan 5, 2018
1 parent 87d0e0a commit 8a94839
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
7 changes: 7 additions & 0 deletions compare/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ export const closeModal = value => {
value
}
}

export const toggleScrubberMode = value => {
return {
type: 'TOGGLE_SCRUBBER_MODE',
value
}
}
48 changes: 38 additions & 10 deletions compare/src/components/ecosystems/ScrubberModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { connect } from 'react-redux'
import styled from 'styled-components'
import Modal from 'react-modal'
import { closeModal } from '../../actions'
import { closeModal, toggleScrubberMode } from '../../actions'

// styles & icons
import { colors, fonts, shadows } from '../../styles'
Expand All @@ -20,9 +20,9 @@ const Wrapper = styled.div`
const ButtonClose = styled.button`
position: absolute;
right: 60px;
top: 25px;
width: 40px;
height: 40px;
top: 35px;
width: 30px;
height: 30px;
background-image: url(${iconClose});
background-size: 100%;
background-repeat: no-repeat;
Expand All @@ -38,6 +38,26 @@ const ButtonClose = styled.button`
}
`

const ButtonToggleView = styled.button`
display: block;
margin: 0 auto;
border: none;
border-radius: 3px;
background-color: ${colors.lightGray};
text-align: center;
padding: 12px 40px;
color: ${colors.secondaryText};
font-size: 16px;
&:hover {
cursor: pointer;
}
&:focus {
outline: none;
}
`

const customStyles = {
content: {
width: '100%',
Expand All @@ -57,25 +77,30 @@ class ScrubberModal extends React.Component {
}

render() {
let { reference: refImage, test: testImage } = this.props.scrubber.test
let { visible } = this.props.scrubber
const { reference: refImage, test: testImage } = this.props.scrubber.test
const { visible, mode } = this.props.scrubber
const { closeModal, handleButtonMode } = this.props

return (
<Wrapper>
<Modal
isOpen={visible}
/* onAfterOpen={this.afterOpenModal} */
onRequestClose={this.props.closeModal}
onRequestClose={closeModal}
style={customStyles}
contentLabel="Example Modal"
>
<ButtonClose onClick={this.props.closeModal} />
<ButtonClose onClick={closeModal} />
<Logo />
<ButtonToggleView onClick={handleButtonMode}>
DIFF / SCRUB
</ButtonToggleView>
{/* <div style={{ paddingTop: '20px', paddingLeft: '5px' }}>
<TextDetails {...this.props} />
</div> */}

<ImageScrubber testImage={testImage} refImage={refImage} />
{mode === 'scrub' && (
<ImageScrubber testImage={testImage} refImage={refImage} />
)}
</Modal>
</Wrapper>
)
Expand All @@ -92,6 +117,9 @@ const mapDispatchToProps = dispatch => {
return {
closeModal: () => {
dispatch(closeModal(false))
},
handleButtonMode: mode => {
dispatch(toggleScrubberMode(mode))
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions compare/src/reducers/scrubber.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const scrubber = (state = {}, action) => {
test: {}
})

case 'TOGGLE_SCRUBBER_MODE':
return Object.assign({}, state, {
mode: state.mode === 'scrub' ? 'diff' : 'scrub'
})

default:
return state
}
Expand Down
1 change: 1 addition & 0 deletions compare/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const defaultState = {
],
scrubber: {
visible: false,
mode: 'scrub',
test: {}
},
layoutSettings: {
Expand Down

0 comments on commit 8a94839

Please sign in to comment.