Skip to content

Commit 5b1f1c2

Browse files
committed
doc: add documentation
1 parent 293063a commit 5b1f1c2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/Shared/Components/DiffViewer/DiffViewer.component.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,44 @@ import { DiffViewerProps, DiffViewTitleWrapperProps } from './types'
44

55
const DiffViewTitleWrapper = ({ title }: DiffViewTitleWrapperProps) => <div>{title}</div>
66

7+
/**
8+
* Component for showing diff between two string or object.
9+
*
10+
* Note: Pass down the object as stringified for optimized performance.
11+
*
12+
* @example Usage
13+
*
14+
* ```tsx
15+
* <DiffViewer
16+
* oldValue={oldValue}
17+
* newValue={newValue}
18+
* />
19+
* ```
20+
*
21+
* @example With left/right title for lhs/rhs
22+
*
23+
* ```tsx
24+
* <DiffViewer
25+
* oldValue={oldValue}
26+
* newValue={newValue}
27+
* leftTitle="Title for LHS"
28+
* rightTitle={
29+
* <span>Title for RHS</span>
30+
* }
31+
* />
32+
* ```
33+
*
34+
* @example With custom message for folded code
35+
* Note: the entire section would be clickable
36+
*
37+
* ```tsx
38+
* <DiffViewer
39+
* oldValue={oldValue}
40+
* newValue={newValue}
41+
* codeFoldMessageRenderer={(totalFoldedLines, leftStartLineNumber, rightStartLineNumber) => <span>Custom text</span>}
42+
* />
43+
* ```
44+
*/
745
const DiffViewer = ({ oldValue, newValue, leftTitle, rightTitle, ...props }: DiffViewerProps) => (
846
<ReactDiffViewer
947
{...props}

0 commit comments

Comments
 (0)