Skip to content

Commit 815e74f

Browse files
authored
Merge pull request #102 from KevinHu2014/feat/add_decoration
Add Decoration to DiffView
2 parents af73984 + b9a80cf commit 815e74f

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

src/__tests__/__snapshots__/App.spec.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
exports[`renders without crashing 1`] = `
44
<div>
55
<div
6-
class="sc-jWBwVP eMzqrb"
6+
class="sc-cMljjf kjukSP"
77
>
88
<div
9-
class="ant-card sc-brqgnP jqshtE ant-card-bordered"
9+
class="ant-card sc-jAaTju jExkfr ant-card-bordered"
1010
>
1111
<div
1212
class="ant-card-body"
1313
>
1414
<div
15-
class="sc-cMljjf bqDeCs"
15+
class="sc-jDwBTQ iPrvAS"
1616
>
1717
<img
1818
alt="React Native upgrade helper logo"
19-
class="sc-jAaTju iQnFlP"
19+
class="sc-gPEVay isecjX"
2020
src="logo.svg"
2121
title="React Native upgrade helper logo"
2222
/>
2323
<a
2424
href="https://react-native-community.github.io/upgrade-helper"
2525
>
2626
<h1
27-
class="sc-jDwBTQ kdxkQr"
27+
class="sc-iRbamj fwveLy"
2828
>
2929
React Native upgrade helper
3030
</h1>
3131
</a>
3232
<div
33-
class="sc-gPEVay bKLGYK"
33+
class="sc-jlyJG dRjxEc"
3434
>
3535
<div>
3636
ReactGitHubBtn -

src/__tests__/components/__snapshots__/Home.spec.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
exports[`renders without crashing 1`] = `
44
<div>
55
<div
6-
class="sc-jWBwVP eMzqrb"
6+
class="sc-cMljjf kjukSP"
77
>
88
<div
9-
class="ant-card sc-brqgnP jqshtE ant-card-bordered"
9+
class="ant-card sc-jAaTju jExkfr ant-card-bordered"
1010
>
1111
<div
1212
class="ant-card-body"
1313
>
1414
<div
15-
class="sc-cMljjf bqDeCs"
15+
class="sc-jDwBTQ iPrvAS"
1616
>
1717
<img
1818
alt="React Native upgrade helper logo"
19-
class="sc-jAaTju iQnFlP"
19+
class="sc-gPEVay isecjX"
2020
src="logo.svg"
2121
title="React Native upgrade helper logo"
2222
/>
2323
<a
2424
href="https://react-native-community.github.io/upgrade-helper"
2525
>
2626
<h1
27-
class="sc-jDwBTQ kdxkQr"
27+
class="sc-iRbamj fwveLy"
2828
>
2929
React Native upgrade helper
3030
</h1>
3131
</a>
3232
<div
33-
class="sc-gPEVay bKLGYK"
33+
class="sc-jlyJG dRjxEc"
3434
>
3535
<div>
3636
ReactGitHubBtn -

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)