(props: Props)
| 15 | |
| 16 | /** A widget to toggle between image diff modes (blink or side-by-side). */ |
| 17 | export 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 | } |
nothing calls this directly
no test coverage detected