MCPcopy Create free account
hub / github.com/danvk/webdiff / SingleImage

Function SingleImage

ts/SingleImage.tsx:11–34  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

9}
10
11export function SingleImage(props: Props) {
12 const {filePair, side} = props;
13 if (!filePair[side]) {
14 return null; // or: return empty <img> same size as other image?
15 }
16
17 const url = side == 'a' ? '/a/image/' + filePair.a : '/b/image/' + filePair.b;
18 const im = _.clone(side === 'a' ? filePair.image_a : filePair.image_b);
19 let scaleDown = 1.0;
20 const {maxWidth} = props;
21 if (maxWidth !== null && maxWidth < im.width) {
22 scaleDown = maxWidth / im.width;
23 im.width *= scaleDown;
24 im.height *= scaleDown;
25 }
26 const diffBoxDiv = makePerceptualBoxDiv(props.pdiffMode, filePair, scaleDown);
27
28 return (
29 <div className="image-holder">
30 {diffBoxDiv}
31 <img className={'side-' + side} src={url} width={im.width} height={im.height} />
32 </div>
33 );
34}

Callers

nothing calls this directly

Calls 1

makePerceptualBoxDivFunction · 0.90

Tested by

no test coverage detected