Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 28f69ff

Browse files
refactor: diff mini map props commonized in viewer component
1 parent 4412ba6 commit 28f69ff

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

‎src/components/DiffViewer/components/VirtualizedDiffViewer.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ export const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps> = ({
156156
[leftView, rightView, handleExpand, searchState.term, inlineDiffOptions],
157157
);
158158

159+
const minimapProps = {
160+
leftDiff: leftView,
161+
rightDiff: rightView,
162+
height,
163+
miniMapWidth,
164+
currentScrollTop: scrollTop,
165+
searchResults: searchState.results,
166+
currentMatchIndex: searchState.currentIndex,
167+
onScroll: (scrollTop: number) => listRef.current?.scrollTo(scrollTop),
168+
};
169+
159170
return (
160171
<div className={`diff-viewer-container${className ? ` ${className}` : ""}`}>
161172
{/* Header & Search */}
@@ -213,29 +224,12 @@ export const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps> = ({
213224
<div className="minimap-overlay">
214225
<div className="half left-map-holder">
215226
{!showSingleMinimap && (
216-
<DiffMinimap
217-
leftDiff={leftView}
218-
rightDiff={rightView}
219-
height={height}
220-
miniMapWidth={miniMapWidth}
221-
currentScrollTop={scrollTop}
222-
searchResults={searchState.results}
223-
currentMatchIndex={searchState.currentIndex}
224-
onScroll={scrollTop => listRef.current?.scrollTo(scrollTop)}
225-
/>
227+
<DiffMinimap {...minimapProps} />
228+
226229
)}
227230
</div>
228231
<div className="half right-map-holder">
229-
<DiffMinimap
230-
leftDiff={leftView}
231-
rightDiff={rightView}
232-
height={height}
233-
miniMapWidth={miniMapWidth}
234-
currentScrollTop={scrollTop}
235-
searchResults={searchState.results}
236-
currentMatchIndex={searchState.currentIndex}
237-
onScroll={scrollTop => listRef.current?.scrollTo(scrollTop)}
238-
/>
232+
<DiffMinimap {...minimapProps} />
239233
</div>
240234
</div>
241235
</div>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /