Skip to content

Commit

Permalink
Make the "Expand diff" button wider (refined-github#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
donocode authored and fregante committed Jan 7, 2018
1 parent 40ff307 commit b8d782c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ GitHub Enterprise is also supported. More info in the options.
- Shows the reactions popover on hover instead of click
- Changes the default sort order of milestones to "Closest due date"
- Changes the default sort order of issues/PRs to "Recently updated"
- [Makes the "Expand diff" button wider](https://user-images.githubusercontent.com/6978877/34470024-eee4f43e-ef20-11e7-9036-65094bd58960.png)

And [lots](source/content.css) [more...](source/content.js)

Expand Down
9 changes: 9 additions & 0 deletions source/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,15 @@ body > .footer li a {
padding: 8px 0 !important;
}

/* For 'extend-diff-expander' feature */
.js-expandable-line:hover .diff-expander,
.js-expandable-line:hover .blob-code {
border-color: #0366d6;
color: #fff;
background: #0366d6;
cursor: pointer;
}

/* Lighten deletions in Markdown */
.markdown-body del {
color: #6a737d;
Expand Down
2 changes: 2 additions & 0 deletions source/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import embedGistInline from './features/embed-gist-inline';
import expandCollapseOutdatedComments from './features/expand-collapse-outdated-comments';
import addJumpToBottomLink from './features/add-jump-to-bottom-link';
import addQuickReviewButtons from './features/add-quick-review-buttons';
import extendDiffExpander from './features/extend-diff-expander';
import sortIssuesByUpdateTime from './features/sort-issues-by-update-time';
import shortenLinks from './features/shorten-links';

Expand Down Expand Up @@ -212,6 +213,7 @@ function ajaxedPagesHandler() {

if (pageDetect.isPRFiles()) {
enableFeature(addQuickReviewButtons);
enableFeature(extendDiffExpander);
}

if (pageDetect.isSingleFile()) {
Expand Down
13 changes: 13 additions & 0 deletions source/features/extend-diff-expander.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import select from 'select-dom';
import delegate from 'delegate';

function expandDiff(event) {
// Skip if the user clicked directly on the icon
if (!event.target.closest('.js-expand')) {
select('.js-expand', event.delegateTarget).click();
}
}

export default function () {
delegate('.diff-view', '.js-expandable-line', 'click', expandDiff);
}

0 comments on commit b8d782c

Please sign in to comment.