Skip to content

Commit

Permalink
Add ability to select lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Bento committed Jun 8, 2019
1 parent 7d2300a commit 7cbf274
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/components/common/Diff/Diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const DiffView = styled(RDiff)`
border-color: #bef5cb;
}
td.diff-gutter:hover {
cursor: pointer;
color: rgba(27, 31, 35, 0.6);
}
td.diff-code {
font-size: 12px;
color: #24292e;
Expand All @@ -53,7 +58,16 @@ const DiffView = styled(RDiff)`
const isDiffCollapsedByDefault = ({ type, hunks }) =>
type === 'delete' || hunks.length > 5

const Diff = ({ oldPath, newPath, type, hunks, fromVersion, toVersion }) => {
const Diff = ({
oldPath,
newPath,
type,
hunks,
fromVersion,
toVersion,
selectedChanges,
onToggleChangeSelection
}) => {
const [isDiffCollapsed, setIsDiffCollapsed] = useState(
isDiffCollapsedByDefault({ type, hunks })
)
Expand All @@ -75,6 +89,7 @@ const Diff = ({ oldPath, newPath, type, hunks, fromVersion, toVersion }) => {
diffType={type}
hunks={hunks}
widgets={getComments({ newPath, fromVersion, toVersion })}
selectedChanges={selectedChanges}
>
{hunks => {
const options = {
Expand All @@ -84,7 +99,12 @@ const Diff = ({ oldPath, newPath, type, hunks, fromVersion, toVersion }) => {
const tokens = tokenize(hunks, options)

return hunks.map(hunk => (
<Hunk key={hunk.content} hunk={hunk} tokens={tokens} />
<Hunk
key={hunk.content}
hunk={hunk}
tokens={tokens}
gutterEvents={{ onClick: onToggleChangeSelection }}
/>
))
}}
</DiffView>
Expand Down

0 comments on commit 7cbf274

Please sign in to comment.