From 4bd081b30704e481c841d9929c1fa4fdc2665e38 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Tue, 18 Jun 2019 16:54:16 -0400 Subject: [PATCH] fixes #924 (#1107) --- client/modules/IDE/components/Preferences.jsx | 68 ++++++++++++++----- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/client/modules/IDE/components/Preferences.jsx b/client/modules/IDE/components/Preferences.jsx index 6723c038..1d3402eb 100644 --- a/client/modules/IDE/components/Preferences.jsx +++ b/client/modules/IDE/components/Preferences.jsx @@ -16,12 +16,27 @@ class Preferences extends React.Component { super(props); this.handleUpdateAutosave = this.handleUpdateAutosave.bind(this); this.handleUpdateLinewrap = this.handleUpdateLinewrap.bind(this); - this.handleUpdateFont = this.handleUpdateFont.bind(this); this.handleLintWarning = this.handleLintWarning.bind(this); + this.onFontInputChange = this.onFontInputChange.bind(this); + this.onFontInputSubmit = this.onFontInputSubmit.bind(this); + this.increaseFontSize = this.increaseFontSize.bind(this); + this.decreaseFontSize = this.decreaseFontSize.bind(this); + this.setFontSize = this.setFontSize.bind(this); + + this.state = { + fontSize: props.fontSize + }; } - handleUpdateFont(event) { - let value = parseInt(event.target.value, 10); + onFontInputChange(event) { + this.setState({ + fontSize: event.target.value + }); + } + + onFontInputSubmit(event) { + event.preventDefault(); + let value = parseInt(this.state.fontSize, 10); if (Number.isNaN(value)) { value = 16; } @@ -31,9 +46,24 @@ class Preferences extends React.Component { if (value < 8) { value = 8; } + this.setFontSize(value); + } + + setFontSize(value) { + this.setState({ fontSize: value }); this.props.setFontSize(value); } + decreaseFontSize() { + const newValue = this.state.fontSize - 2; + this.setFontSize(newValue); + } + + increaseFontSize() { + const newValue = this.state.fontSize + 2; + this.setFontSize(newValue); + } + handleUpdateAutosave(event) { const value = event.target.value === 'true'; this.props.setAutosave(value); @@ -107,29 +137,31 @@ class Preferences extends React.Component {

Text size

- { this.fontSizeInput = element; }} - onClick={() => { - this.fontSizeInput.select(); - }} - /> +
+ { this.fontSizeInput = element; }} + onClick={() => { + this.fontSizeInput.select(); + }} + /> +