Skip to content

fixes #924 #1107

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

Merged
merged 1 commit into from
Jun 18, 2019
Merged
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
68 changes: 50 additions & 18 deletions client/modules/IDE/components/Preferences.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}

onFontInputChange(event) {
this.setState({
fontSize: event.target.value
});
}

handleUpdateFont(event) {
let value = parseInt(event.target.value, 10);
onFontInputSubmit(event) {
event.preventDefault();
let value = parseInt(this.state.fontSize, 10);
if (Number.isNaN(value)) {
value = 16;
}
Expand All @@ -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);
Expand Down Expand Up @@ -107,29 +137,31 @@ class Preferences extends React.Component {
<h4 className="preference__title">Text size</h4>
<button
className="preference__minus-button"
onClick={() => this.props.setFontSize(this.props.fontSize - 2)}
onClick={this.decreaseFontSize}
aria-label="decrease font size"
disabled={this.props.fontSize <= 8}
disabled={this.state.fontSize <= 8}
>
<InlineSVG src={minusUrl} alt="Decrease Font Size" />
<h6 className="preference__label">Decrease</h6>
</button>
<input
className="preference__value"
aria-live="polite"
aria-atomic="true"
value={this.props.fontSize}
onChange={this.handleUpdateFont}
ref={(element) => { this.fontSizeInput = element; }}
onClick={() => {
this.fontSizeInput.select();
}}
/>
<form onSubmit={this.onFontInputSubmit}>
<input
className="preference__value"
aria-live="polite"
aria-atomic="true"
value={this.state.fontSize}
onChange={this.onFontInputChange}
ref={(element) => { this.fontSizeInput = element; }}
onClick={() => {
this.fontSizeInput.select();
}}
/>
</form>
<button
className="preference__plus-button"
onClick={() => this.props.setFontSize(this.props.fontSize + 2)}
onClick={this.increaseFontSize}
aria-label="increase font size"
disabled={this.props.fontSize >= 36}
disabled={this.state.fontSize >= 36}
>
<InlineSVG src={plusUrl} alt="Increase Font Size" />
<h6 className="preference__label">Increase</h6>
Expand Down