Skip to content

Commit

Permalink
ImagePreview
Browse files Browse the repository at this point in the history
  • Loading branch information
mantovanig committed Oct 17, 2017
1 parent 6e8c418 commit dda3fc0
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions compare/src/components/atoms/ImagePreview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import styled from 'styled-components';

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

const Image = styled.img`
width: auto;
max-height: 150px;
`;

const Wrapper = styled.div`
flex: 1 1 auto;
padding: 0 25px;
text-align: center;
`;

const Label = styled.span`
text-align: center;
font-family: ${fonts.latoRegular};
color: ${colors.secondaryText};
display: block;
margin: 0 auto;
text-transform: uppercase;
padding: 5px 0;
padding-bottom: 15px;
font-size: 12px;
`;

export default class ImagePreview extends React.Component {

render () {
let { hidden } = this.props;

return (
<Wrapper hidden={hidden} >
<Label>{this.props.label}</Label>
<Image {...this.props} />
</Wrapper>
);
}
}
72 changes: 72 additions & 0 deletions compare/src/components/molecules/TestImages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import styled from 'styled-components';
import { connect } from 'react-redux';

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

// atoms
import ImagePreview from '../atoms/ImagePreview';

const ImagesWrapper = styled.div`
position: relative;
display: flex;
padding-top: 20px;
`;

class TestImages extends React.Component {

constructor(props) {
super(props);

this.state = {
images: []
};
}

render () {
let { reference, test } = this.props.info;
let { status, settings } = this.props;

this.state.images = [
{
id: "refImage",
label: "Reference",
src: reference,
visible: settings.refImage
},
{
id: "testImage",
label: "Test",
src: test,
visible: settings.testImage
}
];

if(status !== 'pass') {
this.state.images.push({
id: "diffImage",
label: "Diff",
src: this.props.info.diffImage,
visible: settings.diffImage
})
}

return (
<ImagesWrapper>
{this.state.images.map((img, i) =>
<ImagePreview src={img.src} id={img.id} label={img.label} key={i} hidden={!img.visible} />
)}
</ImagesWrapper>
);
}
}

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

const TestImagesContainer = connect(mapStateToProps)(TestImages);

export default TestImagesContainer
4 changes: 4 additions & 0 deletions compare/src/components/organisms/TestCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { colors, shadows } from '../../styles';
// atoms
import TextDetails from '../atoms/TextDetails';

// molecules
import TestImages from '../molecules/TestImages';

const CardWrapper = styled.div`
position: relative;
margin: 10px auto;
Expand Down Expand Up @@ -33,6 +36,7 @@ export default class TestCard extends React.Component {
return (
<CardWrapper status={status} >
<TextDetails info={info} />
<TestImages info={info} status={status} />
</CardWrapper>
);
}
Expand Down

0 comments on commit dda3fc0

Please sign in to comment.