2016-06-27 21:57:36 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-08-01 19:55:49 +02:00
|
|
|
import InlineSVG from 'react-inlinesvg';
|
|
|
|
import classNames from 'classnames';
|
2016-08-05 03:43:13 +02:00
|
|
|
// import { bindActionCreators } from 'redux';
|
|
|
|
// import { connect } from 'react-redux';
|
|
|
|
// import * as PreferencesActions from '../actions/preferences';
|
2016-06-24 00:29:55 +02:00
|
|
|
|
|
|
|
const exitUrl = require('../../../images/exit.svg');
|
|
|
|
const plusUrl = require('../../../images/plus.svg');
|
|
|
|
const minusUrl = require('../../../images/minus.svg');
|
2016-09-01 05:07:43 +02:00
|
|
|
const beepUrl = require('../../../sounds/audioAlert.mp3');
|
2016-06-24 00:29:55 +02:00
|
|
|
|
2016-08-04 05:45:49 +02:00
|
|
|
class Preferences extends React.Component {
|
2016-08-09 22:15:28 +02:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.handleUpdateAutosave = this.handleUpdateAutosave.bind(this);
|
|
|
|
}
|
|
|
|
|
2016-08-04 05:45:49 +02:00
|
|
|
handleUpdateFont(event) {
|
|
|
|
this.props.setFontSize(parseInt(event.target.value, 10));
|
|
|
|
}
|
2016-07-06 17:27:39 +02:00
|
|
|
|
2016-08-04 05:45:49 +02:00
|
|
|
handleUpdateIndentation(event) {
|
|
|
|
this.props.setIndentation(parseInt(event.target.value, 10));
|
|
|
|
}
|
2016-07-06 17:27:39 +02:00
|
|
|
|
2016-08-09 22:15:28 +02:00
|
|
|
handleUpdateAutosave(event) {
|
|
|
|
const value = event.target.value === 'true';
|
|
|
|
this.props.setAutosave(value);
|
|
|
|
}
|
|
|
|
|
2016-08-11 20:09:59 +02:00
|
|
|
handleLintWarning(event) {
|
|
|
|
const value = event.target.value === 'true';
|
|
|
|
this.props.setLintWarning(value);
|
|
|
|
}
|
|
|
|
|
2016-08-04 05:45:49 +02:00
|
|
|
render() {
|
2016-09-01 05:07:43 +02:00
|
|
|
const beep = new Audio(beepUrl);
|
2016-08-04 05:45:49 +02:00
|
|
|
const preferencesContainerClass = classNames({
|
|
|
|
preferences: true,
|
|
|
|
'preferences--selected': this.props.isVisible
|
|
|
|
});
|
2016-08-29 20:39:23 +02:00
|
|
|
|
2016-08-04 05:45:49 +02:00
|
|
|
return (
|
|
|
|
<section className={preferencesContainerClass} tabIndex="0" title="preference-menu">
|
|
|
|
<div className="preferences__heading">
|
|
|
|
<h2 className="preferences__title">Preferences</h2>
|
|
|
|
<button
|
|
|
|
className="preferences__exit-button"
|
|
|
|
onClick={this.props.closePreferences}
|
|
|
|
title="exit"
|
|
|
|
aria-label="exit preferences"
|
|
|
|
>
|
|
|
|
<InlineSVG src={exitUrl} alt="Exit Preferences" />
|
|
|
|
</button>
|
2016-07-11 14:44:27 +02:00
|
|
|
</div>
|
2016-08-04 05:45:49 +02:00
|
|
|
|
|
|
|
<div className="preference">
|
|
|
|
<h4 className="preference__title">Text Size</h4>
|
|
|
|
<button
|
|
|
|
className="preference__minus-button"
|
|
|
|
onClick={() => this.props.setFontSize(this.props.fontSize - 2)}
|
|
|
|
aria-label="decrease font size"
|
|
|
|
>
|
|
|
|
<InlineSVG src={minusUrl} alt="Decrease Font Size" />
|
|
|
|
<h6 className="preference__label">Decrease</h6>
|
|
|
|
</button>
|
|
|
|
<input
|
|
|
|
className="preference__value"
|
|
|
|
aria-live="status"
|
|
|
|
aria-live="polite"
|
2016-08-12 02:26:14 +02:00
|
|
|
aria-atomic="true"
|
2016-08-04 05:45:49 +02:00
|
|
|
role="status"
|
|
|
|
value={this.props.fontSize}
|
|
|
|
onChange={this.handleUpdateFont}
|
|
|
|
>
|
|
|
|
</input>
|
|
|
|
<button
|
|
|
|
className="preference__plus-button"
|
|
|
|
onClick={() => this.props.setFontSize(this.props.fontSize + 2)}
|
|
|
|
aria-label="increase font size"
|
|
|
|
>
|
|
|
|
<InlineSVG src={plusUrl} alt="Increase Font Size" />
|
|
|
|
<h6 className="preference__label">Increase</h6>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="preference">
|
|
|
|
<h4 className="preference__title">Indentation Amount</h4>
|
|
|
|
<button
|
|
|
|
className="preference__minus-button"
|
|
|
|
onClick={() => this.props.setIndentation(this.props.indentationAmount - 2)}
|
|
|
|
aria-label="decrease indentation amount"
|
|
|
|
>
|
|
|
|
<InlineSVG src={minusUrl} alt="DecreaseIndentation Amount" />
|
|
|
|
<h6 className="preference__label">Decrease</h6>
|
|
|
|
</button>
|
|
|
|
<input
|
|
|
|
className="preference__value"
|
|
|
|
aria-live="status"
|
|
|
|
aria-live="polite"
|
2016-08-12 02:26:14 +02:00
|
|
|
aria-atomic="true"
|
2016-08-04 05:45:49 +02:00
|
|
|
role="status"
|
|
|
|
value={this.props.indentationAmount}
|
|
|
|
onChange={this.handleUpdateIndentation}
|
|
|
|
>
|
|
|
|
</input>
|
|
|
|
<button
|
|
|
|
className="preference__plus-button"
|
|
|
|
onClick={() => this.props.setIndentation(this.props.indentationAmount + 2)}
|
|
|
|
aria-label="increase indentation amount"
|
|
|
|
>
|
|
|
|
<InlineSVG src={plusUrl} alt="IncreaseIndentation Amount" />
|
|
|
|
<h6 className="preference__label">Increase</h6>
|
|
|
|
</button>
|
|
|
|
<div className="preference__vertical-list">
|
2016-08-29 20:39:23 +02:00
|
|
|
<input
|
|
|
|
type="radio"
|
2016-08-29 22:36:35 +02:00
|
|
|
onChange={this.props.indentWithSpace}
|
2016-08-29 20:39:23 +02:00
|
|
|
aria-label="indentation with space"
|
|
|
|
name="indentation"
|
|
|
|
id="indentation-space"
|
|
|
|
className="preference__radio-button"
|
|
|
|
value="Spaces"
|
|
|
|
checked={!this.props.isTabIndent}
|
|
|
|
/>
|
|
|
|
<label htmlFor="indentation-space" className="preference__option">Spaces</label>
|
|
|
|
<input
|
|
|
|
type="radio"
|
2016-08-29 22:36:35 +02:00
|
|
|
onChange={this.props.indentWithTab}
|
2016-08-29 20:39:23 +02:00
|
|
|
aria-label="indentation with tab"
|
|
|
|
name="indentation"
|
|
|
|
id="indentation-tab"
|
|
|
|
className="preference__radio-button"
|
|
|
|
value="Tabs"
|
|
|
|
checked={this.props.isTabIndent}
|
|
|
|
/>
|
|
|
|
<label htmlFor="indentation-tab" className="preference__option">Tabs</label>
|
2016-08-04 05:45:49 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-08-09 22:15:28 +02:00
|
|
|
<div className="preference">
|
|
|
|
<h4 className="preference__title">Autosave</h4>
|
2016-08-09 23:29:17 +02:00
|
|
|
<div className="preference__options">
|
2016-08-25 23:46:30 +02:00
|
|
|
<input
|
|
|
|
type="radio"
|
2016-08-29 22:36:35 +02:00
|
|
|
onChange={() => this.props.setAutosave(true)}
|
2016-08-09 23:29:17 +02:00
|
|
|
aria-label="autosave on"
|
2016-08-25 23:46:30 +02:00
|
|
|
name="autosave"
|
|
|
|
id="autosave-on"
|
|
|
|
className="preference__radio-button"
|
|
|
|
value="On"
|
|
|
|
checked={this.props.autosave}
|
|
|
|
/>
|
2016-08-29 20:39:23 +02:00
|
|
|
<label htmlFor="autosave-on" className="preference__option">On</label>
|
2016-08-25 23:46:30 +02:00
|
|
|
<input
|
|
|
|
type="radio"
|
2016-08-29 22:36:35 +02:00
|
|
|
onChange={() => this.props.setAutosave(false)}
|
2016-08-09 23:29:17 +02:00
|
|
|
aria-label="autosave off"
|
2016-08-25 23:46:30 +02:00
|
|
|
name="autosave"
|
|
|
|
id="autosave-off"
|
|
|
|
className="preference__radio-button"
|
|
|
|
value="Off"
|
|
|
|
checked={!this.props.autosave}
|
|
|
|
/>
|
2016-08-29 20:39:23 +02:00
|
|
|
<label htmlFor="autosave-off" className="preference__option">Off</label>
|
2016-08-09 23:29:17 +02:00
|
|
|
</div>
|
2016-08-09 22:15:28 +02:00
|
|
|
</div>
|
2016-08-12 20:19:23 +02:00
|
|
|
<div className="preference">
|
2016-08-11 20:09:59 +02:00
|
|
|
<h4 className="preference__title">Lint Warning Sound</h4>
|
|
|
|
<div className="preference__options">
|
2016-08-25 23:46:30 +02:00
|
|
|
<input
|
|
|
|
type="radio"
|
2016-08-29 22:36:35 +02:00
|
|
|
onChange={() => this.props.setLintWarning(true)}
|
2016-08-11 20:09:59 +02:00
|
|
|
aria-label="lint warning on"
|
2016-08-25 23:46:30 +02:00
|
|
|
name="lint warning"
|
|
|
|
id="lint-warning-on"
|
|
|
|
className="preference__radio-button"
|
|
|
|
value="On"
|
|
|
|
checked={this.props.lintWarning}
|
|
|
|
/>
|
2016-08-29 20:39:23 +02:00
|
|
|
<label htmlFor="lint-warning-on" className="preference__option">On</label>
|
2016-08-25 23:46:30 +02:00
|
|
|
<input
|
|
|
|
type="radio"
|
2016-08-29 22:36:35 +02:00
|
|
|
onChange={() => this.props.setLintWarning(false)}
|
2016-08-11 20:09:59 +02:00
|
|
|
aria-label="lint warning off"
|
2016-08-25 23:46:30 +02:00
|
|
|
name="lint warning"
|
|
|
|
id="lint-warning-off"
|
|
|
|
className="preference__radio-button"
|
|
|
|
value="Off"
|
|
|
|
checked={!this.props.lintWarning}
|
|
|
|
/>
|
2016-08-29 20:39:23 +02:00
|
|
|
<label htmlFor="lint-warning-off" className="preference__option">Off</label>
|
2016-08-11 20:09:59 +02:00
|
|
|
</div>
|
2016-09-01 05:07:43 +02:00
|
|
|
<button
|
|
|
|
className="preference__preview-button"
|
|
|
|
onClick={() => beep.play()}
|
|
|
|
aria-label="preview sound"
|
|
|
|
>
|
|
|
|
Preview Sound
|
|
|
|
</button>
|
2016-08-11 20:09:59 +02:00
|
|
|
</div>
|
2016-08-12 21:50:33 +02:00
|
|
|
<div className="preference">
|
2016-08-19 21:51:41 +02:00
|
|
|
<h4 className="preference__title">Accessible Text-based Canvas</h4>
|
|
|
|
<h6 className="preference__subtitle">Used with screen reader</h6>
|
2016-08-25 23:46:30 +02:00
|
|
|
|
2016-08-12 21:50:33 +02:00
|
|
|
<div className="preference__options">
|
2016-08-25 23:46:30 +02:00
|
|
|
<input
|
|
|
|
type="radio"
|
2016-08-29 22:36:35 +02:00
|
|
|
onChange={() => this.props.setTextOutput(true)}
|
2016-08-12 21:50:33 +02:00
|
|
|
aria-label="text output on"
|
2016-08-25 23:46:30 +02:00
|
|
|
name="text output"
|
|
|
|
id="text-output-on"
|
|
|
|
className="preference__radio-button"
|
|
|
|
value="On"
|
|
|
|
checked={this.props.textOutput}
|
|
|
|
/>
|
2016-08-29 20:39:23 +02:00
|
|
|
<label htmlFor="text-output-on" className="preference__option">On</label>
|
2016-08-25 23:46:30 +02:00
|
|
|
<input
|
|
|
|
type="radio"
|
2016-08-29 22:36:35 +02:00
|
|
|
onChange={() => this.props.setTextOutput(false)}
|
2016-08-12 21:50:33 +02:00
|
|
|
aria-label="text output off"
|
2016-08-25 23:46:30 +02:00
|
|
|
name="text output"
|
|
|
|
id="text-output-off"
|
|
|
|
className="preference__radio-button"
|
|
|
|
value="Off"
|
|
|
|
checked={!this.props.textOutput}
|
|
|
|
/>
|
2016-08-29 20:39:23 +02:00
|
|
|
<label htmlFor="text-output-off" className="preference__option">Off</label>
|
2016-08-25 23:46:30 +02:00
|
|
|
|
2016-08-12 21:50:33 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-08-04 05:45:49 +02:00
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
2016-06-24 00:29:55 +02:00
|
|
|
}
|
|
|
|
|
2016-06-27 21:57:36 +02:00
|
|
|
Preferences.propTypes = {
|
|
|
|
isVisible: PropTypes.bool.isRequired,
|
|
|
|
closePreferences: PropTypes.func.isRequired,
|
|
|
|
fontSize: PropTypes.number.isRequired,
|
2016-07-06 17:27:39 +02:00
|
|
|
indentationAmount: PropTypes.number.isRequired,
|
2016-08-04 05:45:49 +02:00
|
|
|
setIndentation: PropTypes.func.isRequired,
|
2016-07-11 04:52:48 +02:00
|
|
|
indentWithSpace: PropTypes.func.isRequired,
|
|
|
|
indentWithTab: PropTypes.func.isRequired,
|
2016-08-04 05:45:49 +02:00
|
|
|
isTabIndent: PropTypes.bool.isRequired,
|
2016-08-09 22:15:28 +02:00
|
|
|
setFontSize: PropTypes.func.isRequired,
|
|
|
|
autosave: PropTypes.bool.isRequired,
|
2016-08-11 20:09:59 +02:00
|
|
|
setAutosave: PropTypes.func.isRequired,
|
2016-08-12 21:50:33 +02:00
|
|
|
textOutput: PropTypes.bool.isRequired,
|
|
|
|
setTextOutput: PropTypes.func.isRequired,
|
2016-08-11 20:09:59 +02:00
|
|
|
lintWarning: PropTypes.bool.isRequired,
|
|
|
|
setLintWarning: PropTypes.func.isRequired
|
2016-06-27 21:57:36 +02:00
|
|
|
};
|
|
|
|
|
2016-08-05 03:43:13 +02:00
|
|
|
export default Preferences;
|