Skip to content

Commit fe0068d

Browse files
authored
Merge pull request #58 from berzniz/improve_ui
UI improvements
2 parents 8a8584f + 62cba34 commit fe0068d

File tree

5 files changed

+64
-16
lines changed

5 files changed

+64
-16
lines changed

Diff for: src/js/components/actions/index.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const Actions = ({ filter, filterFiles, onFullWidth, onOptions, onClose }) => (
1010
src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDMyIDMyIiBoZWlnaHQ9IjMycHgiIGlkPSLQodC70L7QuV8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAzMiAzMiIgd2lkdGg9IjMycHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxnIGlkPSJGdWxsc2NyZWVuIj48cGF0aCBkPSJNMzIsMWMwLTAuNTU4LTAuNDQyLTEtMS0xbC04Ljk4NSwwYy0wLjU2OCwwLTAuOTkxLDAuNDQ4LTAuOTkyLDEuMDE2QzIxLjAyMywxLjU4MywyMS40NDcsMiwyMi4wMTUsMkwzMCwyICAgbC0wLjAxNiw4LjAyM2MwLDAuNTY4LDAuNDMyLDEsMSwxYzAuNTY4LTAuMDAxLDEtMC40MzIsMS0xTDMyLDEuMDE1YzAtMC4wMDMtMC4wMDEtMC4wMDUtMC4wMDEtMC4wMDdDMzEuOTk5LDEuMDA1LDMyLDEuMDAzLDMyLDF6ICAgIiBmaWxsPSIjMT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GcvPjxnLz48Zy8+PC9zdmc+'
1111
width={16}
1212
height={16}
13+
alt='Toggle full width'
1314
/>
1415
</button>
1516
</div>

Diff for: src/js/components/branch/index.jsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,27 @@ import React from 'react'
22
import TreeView from 'react-treeview'
33
import File from '../file'
44

5-
const Branch = ({ nodeLabel, list, href, hasComments, isDeleted, diffElement, diffStats, visibleElement }) => {
5+
const Branch = ({ nodeLabel, list, href, hasComments, isDeleted, diffElement, diffStats, visibleElement, filter }) => {
66
if (href) {
77
const isVisible = (diffElement === visibleElement)
8-
return <File name={nodeLabel} href={href} hasComments={hasComments} isDeleted={isDeleted} isVisible={isVisible} diffStats={diffStats} />
8+
return (
9+
<File
10+
name={nodeLabel}
11+
href={href}
12+
hasComments={hasComments}
13+
isDeleted={isDeleted}
14+
isVisible={isVisible}
15+
diffStats={diffStats}
16+
filter={filter}
17+
/>
18+
)
919
}
1020

1121
return (
1222
<TreeView nodeLabel={nodeLabel} defaultCollapsed={false}>
1323
{list.map(node => (
1424
<span key={node.nodeLabel}>
15-
<Branch {...node} visibleElement={visibleElement} />
25+
<Branch {...node} visibleElement={visibleElement} filter={filter} />
1626
</span>
1727
))}
1828
</TreeView>

Diff for: src/js/components/file/index.jsx

+23-3
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,41 @@ class File extends React.Component {
2626
this.unmounted = true
2727
}
2828

29+
getHighlight ({ name, filter, index }) {
30+
const prefix = name.substring(0, index)
31+
const middle = name.substring(index, index + filter.length)
32+
const suffix = name.substring(index + filter.length)
33+
return (
34+
<>
35+
{prefix}
36+
{middle ? <span className='github-pr-file-highlight-filter'>{middle}</span> : null}
37+
{suffix}
38+
</>
39+
)
40+
}
41+
2942
render () {
30-
const { name, href, hasComments, isDeleted, isVisible, diffStats } = this.props
43+
const { name, href, hasComments, isDeleted, isVisible, diffStats, filter } = this.props
3144
const { options = {} } = this.state
3245
const className = fileIcons.getClassWithColor(name)
3346
const style = {
3447
background: isVisible ? highlightColor : transparentColor,
3548
textDecoration: isDeleted ? 'line-through' : null
3649
}
3750

51+
const index = filter ? (name.toLowerCase() || '').indexOf(filter.toLowerCase()) : -1
52+
const highlightedName = (index === -1) ? name : this.getHighlight({ name, filter, index })
53+
3854
return (
3955
<div className='github-pr-file' style={style}>
4056
<span className={`icon ${className}`} />
41-
<a href={href} className='link-gray-dark'>{name}</a>
57+
<a href={href} className='link-gray-dark'>{highlightedName}</a>
4258
{options.diffStats && diffStats && <DiffStats diffStats={diffStats} />}
43-
{hasComments ? ' 💬' : ''}
59+
{hasComments ? (
60+
<svg className='github-pr-file-comment octicon octicon-comment text-gray' viewBox='0 0 16 16' width='16' height='16' aria-hidden='true'>
61+
<path fillRule='evenodd' d='M14 1H2c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h2v3.5L7.5 11H14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm0 9H7l-2 2v-2H2V2h12v8z' />
62+
</svg>
63+
) : null}
4464
</div>
4565
)
4666
}

Diff for: src/js/components/tree/index.jsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,22 @@ class Tree extends React.Component {
162162

163163
return (
164164
<div>
165+
<div className='_better_github_pr_resizer' ref={node => { this.resizer = node }} />
165166
<Actions
166167
filter={filter}
167168
filterFiles={this.filterFiles}
168169
onFullWidth={this.onFullWidth}
169170
onOptions={this.onOptions}
170171
onClose={this.onClose}
171172
/>
172-
<div>
173-
<div className='_better_github_pr_resizer' ref={node => { this.resizer = node }} />
174-
{root.list.map(node => (
175-
<span key={node.nodeLabel}>
176-
<Branch {...node} visibleElement={visibleElement} />
177-
</span>
178-
))}
173+
<div className='file-container'>
174+
<div>
175+
{root.list.map(node => (
176+
<span key={node.nodeLabel}>
177+
<Branch {...node} visibleElement={visibleElement} filter={filter} />
178+
</span>
179+
))}
180+
</div>
179181
</div>
180182
</div>
181183
)

Diff for: src/js/style.css

+18-3
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,24 @@
3030
margin-top: 20px;
3131
padding: 0 10px 0;
3232
width: 330px;
33-
height: calc(100vh - 61px);
33+
height: calc(100vh - 68px);
3434
background-color: #ffffff;
3535
border: 1px solid #e1e4e8;
3636
box-sizing: border-box;
3737
border-radius: 3px;
3838
}
3939

4040
.__better_github_pr > div {
41+
height: calc(100% - 55px);
42+
}
43+
44+
.__better_github_pr .file-container {
4145
overflow: auto;
4246
height: 100%;
4347
padding-bottom: 10px;
4448
}
4549

46-
.__better_github_pr > div > div {
50+
.__better_github_pr .file-container > div {
4751
width: fit-content;
4852
}
4953

@@ -211,11 +215,22 @@
211215

212216
.github-pr-file span.change-block {
213217
display: inline-block;
218+
vertical-align: middle;
214219
height: 6px;
215-
margin-right: 2px;
216220
width: 6px;
221+
margin-right: 2px;
217222
}
218223

219224
.github-pr-file span.deletion {
220225
background-color: #b22;
221226
}
227+
228+
.github-pr-file-highlight-filter {
229+
background: #fffbdd;
230+
}
231+
232+
.github-pr-file-comment {
233+
margin-left: 3px;
234+
position: relative;
235+
top: 2px;
236+
}

0 commit comments

Comments
 (0)