Skip to content

Commit

Permalink
Add report settings
Browse files Browse the repository at this point in the history
Toggle text info
  • Loading branch information
mantovanig committed Oct 31, 2017
1 parent 559711c commit 470e836
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
21 changes: 16 additions & 5 deletions compare/src/components/atoms/ImagePreview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react'
import { connect } from 'react-redux'
import styled from 'styled-components'

import { colors, fonts } from '../../styles'

const Image = styled.img`
width: auto;
max-width: 100%;
max-height: 150px;
max-height: ${props => (props.settings.textInfo ? '150px' : '300px')};
&:hover {
cursor: pointer;
Expand All @@ -16,7 +17,7 @@ const Image = styled.img`
const Wrapper = styled.div`
flex: 1 1 auto;
padding: 0 25px;
padding-top: 20px;
padding-top: ${props => (props.withText ? '20px' : '60px')};
text-align: center;
`

Expand All @@ -32,15 +33,25 @@ const Label = styled.span`
font-size: 12px;
`

export default class ImagePreview extends React.Component {
class ImagePreview extends React.Component {
render() {
let { hidden } = this.props
let { hidden, settings } = this.props

return (
<Wrapper hidden={hidden}>
<Wrapper hidden={hidden} withText={settings.textInfo}>
<Label>{this.props.label}</Label>
<Image {...this.props} />
</Wrapper>
)
}
}

const mapStateToProps = state => {
return {
settings: state.layoutSettings
}
}

const ImagePreviewContainer = connect(mapStateToProps)(ImagePreview)

export default ImagePreviewContainer
18 changes: 15 additions & 3 deletions compare/src/components/atoms/TextDetails.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import { connect } from 'react-redux'
import styled from 'styled-components'

import { colors, fonts } from '../../styles'
Expand All @@ -24,12 +25,13 @@ const Value = styled.span`
padding-right: 20px;
`

export default class TextDetails extends React.Component {
class TextDetails extends React.Component {
render() {
let { label, fileName, selector, diff } = this.props.info
const { label, fileName, selector, diff } = this.props.info
const { settings } = this.props

return (
<WrapperDetails>
<WrapperDetails hidden={!settings.textInfo}>
<Row>
<Label>label: </Label>
<Value>{label}</Value>
Expand All @@ -52,3 +54,13 @@ export default class TextDetails extends React.Component {
)
}
}

const mapStateToProps = state => {
return {
settings: state.layoutSettings
}
}

const TextDetailsContainer = connect(mapStateToProps)(TextDetails)

export default TextDetailsContainer
11 changes: 10 additions & 1 deletion compare/src/components/molecules/SettingsPopup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { connect } from 'react-redux'
import styled from 'styled-components'
import { updateSettings, toggleAllImages } from '../../actions'
import { updateSettings, toggleAllImages, toggleTextInfo } from '../../actions'

import { colors, fonts, shadows } from '../../styles'

Expand Down Expand Up @@ -69,6 +69,12 @@ class SettingsPopup extends React.Component {

return (
<PopupWrapper>
<SettingOption
id="textInfo"
label="Text info"
value={settings.textInfo}
onToggle={this.onToggle.bind(this, 'textInfo')}
/>
<SettingOption
id="hideAll"
label="Hide all images"
Expand Down Expand Up @@ -111,6 +117,9 @@ const mapDispatchToProps = dispatch => {
},
toggleAll: value => {
dispatch(toggleAllImages(value))
},
toogleTextInfo: value => {
dispatch(toggleTextInfo(value))
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions compare/src/components/molecules/TestImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class TestImages extends React.Component {
}

onImageClick() {
console.log('click on image')

let { openModal } = this.props

openModal(this.props.info)
Expand Down
14 changes: 5 additions & 9 deletions compare/src/reducers/layoutSettings.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
function toggleAll(obj, val) {
let res = Object.assign({}, obj)

for (let key in res) res[key] = val

return res
}

const visibilityFilter = (state = {}, action) => {
switch (action.type) {
case 'UPDATE_SETTINGS':
Expand All @@ -14,7 +6,11 @@ const visibilityFilter = (state = {}, action) => {
})

case 'TOGGLE_ALL_IMAGES':
return Object.assign({}, state, toggleAll(state, action.value))
return Object.assign({}, state, {
refImage: action.value,
testImage: action.value,
diffImage: action.value
})

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 @@ -33,6 +33,7 @@ const defaultState = {
test: {}
},
layoutSettings: {
textInfo: true,
refImage: true,
testImage: true,
diffImage: true
Expand Down

0 comments on commit 470e836

Please sign in to comment.