(props: SkipRowProps)
| 16 | } |
| 17 | |
| 18 | export function SkipRow(props: SkipRowProps) { |
| 19 | const {expandLines, header, onShowMore, isSelected, ...range} = props; |
| 20 | const {numRows} = range; |
| 21 | const showAll = (e: React.MouseEvent) => { |
| 22 | e.preventDefault(); |
| 23 | onShowMore(range, numRows); |
| 24 | }; |
| 25 | const arrows = |
| 26 | numRows <= expandLines ? ( |
| 27 | <span className="skip right" title={`show ${numRows} skipped lines`} onClick={showAll}> |
| 28 | ↕ |
| 29 | </span> |
| 30 | ) : ( |
| 31 | <> |
| 32 | <span |
| 33 | className="skip right expand-up" |
| 34 | title={`show ${expandLines} more lines above`} |
| 35 | onClick={() => { |
| 36 | onShowMore(range, -expandLines); |
| 37 | }}> |
| 38 | ∨ EXPAND |
| 39 | </span> |
| 40 | <span |
| 41 | className="skip right expand-down" |
| 42 | title={`show ${expandLines} more lines below`} |
| 43 | onClick={() => { |
| 44 | onShowMore(range, expandLines); |
| 45 | }}> |
| 46 | ∧ EXPAND |
| 47 | </span> |
| 48 | </> |
| 49 | ); |
| 50 | const headerHTML = header ? <span className="hunk-header">{header}</span> : ''; |
| 51 | |
| 52 | const rowRef = React.useRef<HTMLTableRowElement>(null); |
| 53 | React.useEffect(() => { |
| 54 | if (isSelected && rowRef.current) { |
| 55 | scrollIntoViewIfNeeded(rowRef.current); |
| 56 | } |
| 57 | }, [isSelected]); |
| 58 | return ( |
| 59 | <tr ref={rowRef} className={'skip-row' + (isSelected ? ` selected` : '')}> |
| 60 | <td colSpan={4} className="skip code"> |
| 61 | {arrows} |
| 62 | <a href="#" onClick={showAll} className="show-more"> |
| 63 | ↕ Show {numRows} more lines |
| 64 | </a>{' '} |
| 65 | {headerHTML} |
| 66 | </td> |
| 67 | </tr> |
| 68 | ); |
| 69 | } |
nothing calls this directly
no test coverage detected