Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewed item background highlighting #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/js/components/file/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ class File extends React.Component {

const index = filter ? (name.toLowerCase() || '').indexOf(filter.toLowerCase()) : -1
const highlightedName = (index === -1) ? name : this.getHighlight({ name, filter, index })

const backgroundHighlightColor = '#E6FFED'

return (
<div className={topClassName}>
<span className={`icon ${className}`} />
<div className={topClassName} style={isViewed && options.viewedFileBackground ? {backgroundColor: backgroundHighlightColor} : null }>
<span className={`icon ${className}`}/>
<a href={href} className='link-gray-dark'>{highlightedName}</a>
{options.diffStats && diffStats && <DiffStats diffStats={diffStats} />}
{hasComments
Expand Down
9 changes: 9 additions & 0 deletions src/js/components/options/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ class Options extends React.Component {
/>
<span className='label-body'>Show <strong>Diff Stats</strong> next to files</span>
</label>
<label className='label-enabledd'>
<input
id='viewedFileBackground'
type='checkbox'
checked={Boolean(this.state.viewedFileBackground)}
onChange={this.handleOptions}
/>
<span className='label-body'><strong>Highlight Background</strong> of files marked viewed</span>
</label>
</div>
</div>
)
Expand Down
7 changes: 5 additions & 2 deletions src/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ export const StorageSync = {
save () {
return new Promise(resolve => {
const diffStats = document.getElementById('diffStats').checked
const viewedFileBackground = document.getElementById('viewedFileBackground').checked
const options = {
diffStats
diffStats,
viewedFileBackground
}

if (window.chrome) {
Expand All @@ -218,7 +220,8 @@ export const StorageSync = {
get () {
return new Promise(resolve => {
const defaults = {
diffStats: false
diffStats: false,
viewedFileBackground: false
}
if (window.chrome) {
window.chrome.storage.sync.get(defaults, resolve)
Expand Down