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

Function ImageDiffModeSelector

ts/ImageDiffModeSelector.tsx:17–53  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

15
16/** A widget to toggle between image diff modes (blink or side-by-side). */
17export function ImageDiffModeSelector(props: Props) {
18 if (isOneSided(props.filePair)) {
19 return null; // Only "side-by-side" makes sense for one-sided diffs.
20 }
21
22 // Returns the text, optionally wrapped in a link and/or <b> tag.
23 const linkOrB = (isLink: boolean, isBold: boolean, val: ImageDiffMode, text: string) => {
24 const inner = isBold ? <b>{text}</b> : text;
25 if (isLink) {
26 return (
27 <a
28 href="#"
29 onClick={() => {
30 props.changeImageDiffMode(val);
31 }}>
32 {inner}
33 </a>
34 );
35 } else {
36 return inner;
37 }
38 };
39
40 const mode = props.imageDiffMode;
41 const isBlink = mode == 'blink';
42 const isSxS = mode == 'side-by-side';
43 const isOnion = mode == 'onion-skin';
44 const isSwipe = mode == 'swipe';
45 return (
46 <span>
47 <span className="mode">{linkOrB(!isSxS, isSxS, 'side-by-side', 'Side by Side (s)')}</span>
48 <span className="mode">{linkOrB(true, isBlink, 'blink', 'Blink (b)')}</span>
49 <span className="mode">{linkOrB(!isOnion, isOnion, 'onion-skin', 'Onion Skin')}</span>
50 <span className="mode">{linkOrB(!isSwipe, isSwipe, 'swipe', 'Swipe')}</span>
51 </span>
52 );
53}

Callers

nothing calls this directly

Calls 2

isOneSidedFunction · 0.90
linkOrBFunction · 0.85

Tested by

no test coverage detected