Skip to content

Commit fd54a7b

Browse files
authored
Scroll Bars can now be hidden (#2713)
* Scroll Bars can now be hidden * Fix lint problems * fix lint errors * Fix lint * Fix lint * Change scrollBar to showScrollBar
1 parent 76de78a commit fd54a7b

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

browser/components/MarkdownPreview.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import mermaidRender from './render/MermaidRender'
1111
import SequenceDiagram from '@rokt33r/js-sequence-diagrams'
1212
import Chart from 'chart.js'
1313
import eventEmitter from 'browser/main/lib/eventEmitter'
14+
import config from 'browser/main/lib/ConfigManager'
1415
import htmlTextHelper from 'browser/lib/htmlTextHelper'
1516
import convertModeName from 'browser/lib/convertModeName'
1617
import copy from 'copy-to-clipboard'
@@ -194,10 +195,12 @@ ${allowCustomCSS ? customCSS : ''}
194195

195196
const scrollBarStyle = `
196197
::-webkit-scrollbar {
198+
${config.get().ui.showScrollBar ? '' : 'display: none;'}
197199
width: 12px;
198200
}
199201
200202
::-webkit-scrollbar-thumb {
203+
${config.get().ui.showScrollBar ? '' : 'display: none;'}
201204
background-color: rgba(0, 0, 0, 0.15);
202205
}
203206
@@ -207,10 +210,12 @@ const scrollBarStyle = `
207210
`
208211
const scrollBarDarkStyle = `
209212
::-webkit-scrollbar {
213+
${config.get().ui.showScrollBar ? '' : 'display: none;'}
210214
width: 12px;
211215
}
212216
213217
::-webkit-scrollbar-thumb {
218+
${config.get().ui.showScrollBar ? '' : 'display: none;'}
214219
background-color: rgba(0, 0, 0, 0.3);
215220
}
216221

browser/main/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { store, history } from './store'
44
import React, { Fragment } from 'react'
55
import ReactDOM from 'react-dom'
66
require('!!style!css!stylus?sourceMap!./global.styl')
7+
import config from 'browser/main/lib/ConfigManager'
78
import { Route, Switch, Redirect } from 'react-router-dom'
89
import { ConnectedRouter } from 'connected-react-router'
910
import DevTools from './DevTools'
@@ -77,6 +78,16 @@ document.addEventListener('click', function(e) {
7778
if (infoPanel) infoPanel.style.display = 'none'
7879
})
7980

81+
if (!config.get().ui.showScrollBar) {
82+
document.styleSheets[54].insertRule('::-webkit-scrollbar {display: none}')
83+
document.styleSheets[54].insertRule(
84+
'::-webkit-scrollbar-corner {display: none}'
85+
)
86+
document.styleSheets[54].insertRule(
87+
'::-webkit-scrollbar-thumb {display: none}'
88+
)
89+
}
90+
8091
const el = document.getElementById('content')
8192

8293
function notify(...args) {

browser/main/lib/ConfigManager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const DEFAULT_CONFIG = {
4949
theme: 'default',
5050
showCopyNotification: true,
5151
disableDirectWrite: false,
52+
showScrollBar: true,
5253
defaultNote: 'ALWAYS_ASK', // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
5354
showMenuBar: false
5455
},

browser/main/modals/PreferencesModal/UiTab.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class UiTab extends React.Component {
9494
showTagsAlphabetically: this.refs.showTagsAlphabetically.checked,
9595
saveTagsAlphabetically: this.refs.saveTagsAlphabetically.checked,
9696
enableLiveNoteCounts: this.refs.enableLiveNoteCounts.checked,
97+
showScrollBar: this.refs.showScrollBar.checked,
9798
showMenuBar: this.refs.showMenuBar.checked,
9899
disableDirectWrite:
99100
this.refs.uiD2w != null ? this.refs.uiD2w.checked : false
@@ -351,9 +352,21 @@ class UiTab extends React.Component {
351352
</label>
352353
</div>
353354
) : null}
354-
355+
<div styleName='group-checkBoxSection'>
356+
<label>
357+
<input
358+
onChange={e => this.handleUIChange(e)}
359+
checked={this.state.config.ui.showScrollBar}
360+
ref='showScrollBar'
361+
type='checkbox'
362+
/>
363+
&nbsp;
364+
{i18n.__(
365+
'Show the scroll bars in the editor and in the markdown preview (It will be applied after restarting)'
366+
)}
367+
</label>
368+
</div>
355369
<div styleName='group-header2'>Tags</div>
356-
357370
<div styleName='group-checkBoxSection'>
358371
<label>
359372
<input

0 commit comments

Comments
 (0)