-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2383 from desktop/kactus-image-diffs
Kactus' image diffs
- Loading branch information
Showing
28 changed files
with
940 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as React from 'react' | ||
|
||
import { Image } from '../../../models/diff' | ||
|
||
interface IImageProps { | ||
readonly image: Image | ||
|
||
readonly style?: React.CSSProperties | ||
|
||
readonly onElementLoad?: (img: HTMLImageElement) => void | ||
} | ||
|
||
export class DiffImage extends React.Component<IImageProps, {}> { | ||
public render() { | ||
const image = this.props.image | ||
const imageSource = `data:${image.mediaType};base64,${image.contents}` | ||
|
||
return ( | ||
<img src={imageSource} style={this.props.style} onLoad={this.onLoad} /> | ||
) | ||
} | ||
|
||
private onLoad = (e: React.SyntheticEvent<HTMLImageElement>) => { | ||
if (this.props.onElementLoad) { | ||
this.props.onElementLoad(e.currentTarget) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as React from 'react' | ||
import { DiffImage } from './diff-image' | ||
import { ICommonImageDiffProperties } from './modified-image-diff' | ||
|
||
export class DifferenceBlend extends React.Component< | ||
ICommonImageDiffProperties, | ||
{} | ||
> { | ||
public render() { | ||
const style: React.CSSProperties = { | ||
height: this.props.maxSize.height, | ||
width: this.props.maxSize.width, | ||
} | ||
|
||
const maxSize: React.CSSProperties = { | ||
maxHeight: this.props.maxSize.height, | ||
maxWidth: this.props.maxSize.width, | ||
} | ||
|
||
return ( | ||
<div className="image-diff-difference" ref={this.props.onContainerRef}> | ||
<div className="sizing-container"> | ||
<div className="image-container" style={style}> | ||
<div className="image-diff-previous"> | ||
<DiffImage | ||
image={this.props.previous} | ||
onElementLoad={this.props.onPreviousImageLoad} | ||
style={maxSize} | ||
/> | ||
</div> | ||
|
||
<div className="image-diff-current"> | ||
<DiffImage | ||
image={this.props.current} | ||
onElementLoad={this.props.onCurrentImageLoad} | ||
style={{ | ||
...maxSize, | ||
mixBlendMode: 'difference', | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { ModifiedImageDiff } from './modified-image-diff' | ||
export { NewImageDiff } from './new-image-diff' | ||
export { DeletedImageDiff } from './deleted-image-diff' |
Oops, something went wrong.