import React, { PropTypes } from 'react'; import InlineSVG from 'react-inlinesvg'; import classNames from 'classnames'; // import { bindActionCreators } from 'redux'; // import { connect } from 'react-redux'; // import * as PreferencesActions from '../actions/preferences'; const exitUrl = require('../../../images/exit.svg'); const plusUrl = require('../../../images/plus.svg'); const minusUrl = require('../../../images/minus.svg'); const beepUrl = require('../../../sounds/audioAlert.mp3'); // import { debounce } from 'lodash'; class Preferences extends React.Component { constructor(props) { super(props); this.handleUpdateAutosave = this.handleUpdateAutosave.bind(this); this.handleUpdateFont = this.handleUpdateFont.bind(this); this.handleUpdateIndentation = this.handleUpdateIndentation.bind(this); this.handleLintWarning = this.handleLintWarning.bind(this); } handleUpdateFont(event) { let value = parseInt(event.target.value, 10); if (isNaN(value)) { value = 16; } this.props.setFontSize(value); } handleUpdateIndentation(event) { let value = parseInt(event.target.value, 10); if (isNaN(value)) { value = 2; } this.props.setIndentation(value); } handleUpdateAutosave(event) { const value = event.target.value === 'true'; this.props.setAutosave(value); } handleLintWarning(event) { const value = event.target.value === 'true'; this.props.setLintWarning(value); } render() { const beep = new Audio(beepUrl); const preferencesContainerClass = classNames({ preferences: true, 'preferences--selected': this.props.isVisible }); return (

Preferences

Text size

{ this.refs.fontSizeInput.select(); }} >

Indentation amount

{ this.refs.indentationInput.select(); }} >

Autosave

this.props.setAutosave(true)} aria-label="autosave on" name="autosave" id="autosave-on" className="preference__radio-button" value="On" checked={this.props.autosave} /> this.props.setAutosave(false)} aria-label="autosave off" name="autosave" id="autosave-off" className="preference__radio-button" value="Off" checked={!this.props.autosave} />

Theme

this.props.setTheme('light')} aria-label="light theme on" name="light theme" id="light-theme-on" className="preference__radio-button" value="light" checked={this.props.theme === 'light'} /> this.props.setTheme('dark')} aria-label="dark theme on" name="dark theme" id="dark-theme-on" className="preference__radio-button" value="dark" checked={this.props.theme === 'dark'} /> this.props.setTheme('contrast')} aria-label="contrast theme on" name="contrast theme" id="contrast-theme-on" className="preference__radio-button" value="contrast" checked={this.props.theme === 'contrast'} />

Lint warning sound

this.props.setLintWarning(true)} aria-label="lint warning on" name="lint warning" id="lint-warning-on" className="preference__radio-button" value="On" checked={this.props.lintWarning} /> this.props.setLintWarning(false)} aria-label="lint warning off" name="lint warning" id="lint-warning-off" className="preference__radio-button" value="Off" checked={!this.props.lintWarning} />
beep.play()} aria-label="preview sound" > Preview sound

Accessible text-based canvas

Used with screen reader
this.props.setTextOutput(1)} aria-label="text output on" name="text output" id="text-output-on" className="preference__radio-button" value="On" checked={Boolean(this.props.textOutput === 1)} /> this.props.setTextOutput(2)} aria-label="grid output on" name="grid output" id="grid-output-on" className="preference__radio-button" value="Grid On" checked={Boolean(this.props.textOutput === 2)} /> this.props.setTextOutput(3)} aria-label="sound output on" name="sound output" id="sound-output-on" className="preference__radio-button" value="On" checked={Boolean(this.props.textOutput === 3)} /> this.props.setTextOutput(0)} aria-label="text output off" name="text output" id="text-output-off" className="preference__radio-button" value="Off" checked={!Boolean(this.props.textOutput)} />
); } } Preferences.propTypes = { isVisible: PropTypes.bool.isRequired, closePreferences: PropTypes.func.isRequired, fontSize: PropTypes.number.isRequired, indentationAmount: PropTypes.number.isRequired, setIndentation: PropTypes.func.isRequired, indentWithSpace: PropTypes.func.isRequired, indentWithTab: PropTypes.func.isRequired, isTabIndent: PropTypes.bool.isRequired, setFontSize: PropTypes.func.isRequired, autosave: PropTypes.bool.isRequired, setAutosave: PropTypes.func.isRequired, textOutput: PropTypes.number.isRequired, setTextOutput: PropTypes.func.isRequired, lintWarning: PropTypes.bool.isRequired, setLintWarning: PropTypes.func.isRequired, theme: PropTypes.string.isRequired, setTheme: PropTypes.func.isRequired }; export default Preferences;