Skip to content

Commit e73329f

Browse files
author
KevinHu2014
committed
Add Decoration to DiffView
This fixes #101
1 parent af73984 commit e73329f

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/components/common/Diff/Diff.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React, { useState } from 'react'
22
import styled from 'styled-components'
3-
import { Diff as RDiff, Hunk, markEdits, tokenize } from 'react-diff-view'
3+
import {
4+
Diff as RDiff,
5+
Hunk,
6+
markEdits,
7+
tokenize,
8+
Decoration as DiffDecoration
9+
} from 'react-diff-view'
410
import DiffHeader from './DiffHeader'
511
import { getComments } from './DiffComment'
612

@@ -11,6 +17,17 @@ const Container = styled.div`
1117
margin-top: 16px;
1218
`
1319

20+
const More = styled.div`
21+
background-color: #f1f8ff;
22+
margin-left: 30px;
23+
padding-left: 4px;
24+
color: '#1b1f23b3';
25+
`
26+
27+
const Decoration = styled(DiffDecoration)`
28+
background-color: #dbedff;
29+
`
30+
1431
const DiffView = styled(RDiff)`
1532
.diff-gutter-col {
1633
width: 30px;
@@ -122,14 +139,17 @@ const Diff = ({
122139

123140
const tokens = tokenize(hunks, options)
124141

125-
return hunks.map(hunk => (
142+
return hunks.map(hunk => [
143+
<Decoration key={'decoration-' + hunk.content}>
144+
<More>{hunk.content}</More>
145+
</Decoration>,
126146
<Hunk
127147
key={hunk.content}
128148
hunk={hunk}
129149
tokens={tokens}
130150
gutterEvents={{ onClick: onToggleChangeSelection }}
131151
/>
132-
))
152+
])
133153
}}
134154
</DiffView>
135155
)}

0 commit comments

Comments
 (0)