Skip to content

Commit 1d21bb1

Browse files
committed
Values are now saved
1 parent aa38b1f commit 1d21bb1

File tree

2 files changed

+86
-14
lines changed

2 files changed

+86
-14
lines changed

browser/main/modals/PreferencesModal/ConfigTab.styl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
span first-child
1818
margin-top 18px
1919
padding-right 10px
20+
padding-left 10px
2021
position relative
22+
background $ui-backgroundColor
2123

2224
div[id^="secondRow"]
2325
position absolute;
@@ -70,7 +72,9 @@ div[id^="firstRow"]
7072
font-weight: normal
7173
box-sizing: border-box
7274
border: none
73-
margin-bottom: -15px
75+
margin-bottom: -5px
76+
margin-top: -10px
77+
width: 0px
7478
margin-left: 0px
7579
left: attr(value)
7680
color: $ui-text-color
@@ -248,12 +252,10 @@ body[data-theme="dark"]
248252
select, .group-section-control-input
249253
colorDarkControl()
250254

251-
.box-minmax
252-
colorDarkControl()
253-
254-
.rs-range
255+
.box-minmax, .rs-range, .rs-label
255256
colorDarkControl()
256257

258+
257259
body[data-theme="solarized-dark"]
258260
.root
259261
color $ui-solarized-dark-text-color
@@ -280,6 +282,8 @@ body[data-theme="solarized-dark"]
280282
.group-section-control
281283
select, .group-section-control-input
282284
colorSolarizedDarkControl()
285+
.box-minmax, .rs-range, .rs-label
286+
colorSolarizedDarkControl()
283287

284288
body[data-theme="monokai"]
285289
.root
@@ -307,6 +311,8 @@ body[data-theme="monokai"]
307311
.group-section-control
308312
select, .group-section-control-input
309313
colorMonokaiControl()
314+
.box-minmax, .rs-range, .rs-label
315+
colorMonokaiControl()
310316

311317
body[data-theme="dracula"]
312318
.root
@@ -333,4 +339,6 @@ body[data-theme="dracula"]
333339
colorDraculaControl()
334340
.group-section-control
335341
select, .group-section-control-input
336-
colorDraculaControl()
342+
colorDraculaControl()
343+
.box-minmax, .rs-range, .rs-label
344+
colorDraculaControl()

browser/main/modals/PreferencesModal/UiTab.js

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class UiTab extends React.Component {
4444
}
4545
ipc.addListener('APP_SETTING_DONE', this.handleSettingDone)
4646
ipc.addListener('APP_SETTING_ERROR', this.handleSettingError)
47+
48+
this.handleSlider(null, 1)
49+
this.handleSlider(null, 2)
50+
4751
}
4852

4953
componentWillUnmount () {
@@ -65,6 +69,10 @@ class UiTab extends React.Component {
6569
const newConfig = {
6670
ui: {
6771
theme: this.refs.uiTheme.value,
72+
enableScheduleTheme: this.refs.enableScheduleTheme.value,
73+
scheduledTheme: this.refs.uiScheduledTheme.value,
74+
scheduleStart: this.refs.scheduleStart.value,
75+
scheduleEnd: this.refs.scheduleEnd.value,
6876
language: this.refs.uiLanguage.value,
6977
defaultNote: this.refs.defaultNote.value,
7078
showCopyNotification: this.refs.showCopyNotification.checked,
@@ -162,18 +170,43 @@ class UiTab extends React.Component {
162170
}, 2000)()
163171
}
164172

165-
handleSlider (number) {
173+
/**
174+
* Gets the total number of minutes and returns a string in the HH:MM format
175+
* @param {Number} time total number of minutes
176+
*/
177+
formatTime (time) {
178+
let hour = Math.floor(time / 60)
179+
let minute = time % 60
180+
181+
if (hour < 10) {
182+
hour = '0' + hour
183+
}
184+
185+
if (minute < 10) {
186+
minute = '0' + minute
187+
}
188+
189+
return `${hour}:${minute}`
190+
}
191+
192+
handleSlider (e, number) {
166193
const sliderID = 'rs-range-line-' + number
167194
const bulletID = 'rs-bullet-' + number
168195

169196
const rangeSlider = document.getElementById(sliderID)
170197
const rangeBullet = document.getElementById(bulletID)
171198

172199
if (rangeSlider && rangeBullet) {
173-
rangeBullet.innerHTML = Math.floor(rangeSlider.value / 60) + ':' + rangeSlider.value % 60
200+
rangeBullet.innerHTML = this.formatTime(rangeSlider.value)
174201
const bulletPosition = (rangeSlider.value / rangeSlider.max)
175202
rangeBullet.style.left = (bulletPosition * 578) + 'px'
176203
}
204+
205+
if (e) {
206+
this.handleUIChange(e)
207+
} else {
208+
console.log('HEY')
209+
}
177210
}
178211

179212
render () {
@@ -212,17 +245,48 @@ class UiTab extends React.Component {
212245
</select>
213246
</div>
214247
</div>
248+
<div styleName='group-header2'>
249+
{i18n.__('Theme Schedule')}
250+
</div>
251+
<div styleName='group-checkBoxSection'>
252+
<label>
253+
<input onChange={(e) => this.handleUIChange(e)}
254+
checked={this.state.config.ui.enableScheduleTheme}
255+
ref='enableScheduleTheme'
256+
type='checkbox'
257+
/>&nbsp;
258+
{i18n.__('Enable Scheduled Themes')}
259+
</label>
260+
</div>
261+
<div styleName='group-section'>
262+
<div styleName='group-section-label'>
263+
{i18n.__('Scheduled Theme')}
264+
</div>
265+
<div styleName='group-section-control'>
266+
<select value={config.ui.scheduledTheme}
267+
onChange={(e) => this.handleUIChange(e)}
268+
ref='uiScheduledTheme'
269+
>
270+
<option value='default'>{i18n.__('Default')}</option>
271+
<option value='white'>{i18n.__('White')}</option>
272+
<option value='solarized-dark'>{i18n.__('Solarized Dark')}</option>
273+
<option value='monokai'>{i18n.__('Monokai')}</option>
274+
<option value='dracula'>{i18n.__('Dracula')}</option>
275+
<option value='dark'>{i18n.__('Dark')}</option>
276+
</select>
277+
</div>
278+
</div>
215279
<div styleName='group-section'>
216280
<div styleName='container'>
217281
<div styleName='range-slider' id='firstRow'>
218-
<span id='rs-bullet-1' styleName='rs-label'>00:00</span>
219-
<input id='rs-range-line-1' styleName='rs-range' type='range' value={config.ui.scheduleStart} min='0' max='1440' step='5'
220-
onChange={() => this.handleSlider(1)} />
282+
<span id='rs-bullet-1' styleName='rs-label'>{this.formatTime(config.ui.scheduleStart)}</span>
283+
<input id='rs-range-line-1' styleName='rs-range' type='range' value={config.ui.scheduleStart} min='0' max='1440' step='5' ref='scheduleStart'
284+
onChange={(e) => this.handleSlider(e, 1)} />
221285
</div>
222286
<div styleName='range-slider' id='secondRow'>
223-
<span id='rs-bullet-2' styleName='rs-label'>24:00</span>
224-
<input id='rs-range-line-2' styleName='rs-range' type='range' value={config.ui.scheduleEnd} min='0' max='1440' step='5'
225-
onInput={() => this.handleSlider(2)} />
287+
<span id='rs-bullet-2' styleName='rs-label'>{this.formatTime(config.ui.scheduleEnd)}</span>
288+
<input id='rs-range-line-2' styleName='rs-range' type='range' value={config.ui.scheduleEnd} min='0' max='1440' step='5' ref='scheduleEnd'
289+
onChange={(e) => this.handleSlider(e, 2)} />
226290
</div>
227291
<div styleName='box-minmax'>
228292
<span>00:00</span><span>24:00</span>

0 commit comments

Comments
 (0)