import PropTypes from 'prop-types'; import React from 'react'; import InlineSVG from 'react-inlinesvg'; import { Helmet } from 'react-helmet'; import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; // import { bindActionCreators } from 'redux'; // import { connect } from 'react-redux'; // import * as PreferencesActions from '../actions/preferences'; const plusUrl = require('../../../images/plus.svg'); const minusUrl = require('../../../images/minus.svg'); const beepUrl = require('../../../sounds/audioAlert.mp3'); class Preferences extends React.Component { constructor(props) { super(props); this.handleUpdateAutosave = this.handleUpdateAutosave.bind(this); this.handleUpdateFont = this.handleUpdateFont.bind(this); this.handleLintWarning = this.handleLintWarning.bind(this); } handleUpdateFont(event) { let value = parseInt(event.target.value, 10); if (Number.isNaN(value)) { value = 16; } if (value > 36) { value = 36; } if (value < 8) { value = 8; } this.props.setFontSize(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); return (
p5.js Web Editor | Preferences

General Settings

Accessibility

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="high contrast theme on" name="high contrast theme" id="high-contrast-theme-on" className="preference__radio-button" value="contrast" checked={this.props.theme === 'contrast'} />

Text size

{ this.fontSizeInput = element; }} onClick={() => { this.fontSizeInput.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} />

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} />

Accessible text-based canvas

Used with screen reader
{ this.props.setTextOutput(event.target.checked); }} aria-label="text output on" name="text output" id="text-output-on" value="On" checked={(this.props.textOutput)} /> { this.props.setGridOutput(event.target.checked); }} aria-label="table output on" name="table output" id="table-output-on" value="On" checked={(this.props.gridOutput)} /> { this.props.setSoundOutput(event.target.checked); }} aria-label="sound output on" name="sound output" id="sound-output-on" value="On" checked={(this.props.soundOutput)} />
); } } Preferences.propTypes = { fontSize: PropTypes.number.isRequired, setFontSize: PropTypes.func.isRequired, autosave: PropTypes.bool.isRequired, setAutosave: PropTypes.func.isRequired, textOutput: PropTypes.bool.isRequired, gridOutput: PropTypes.bool.isRequired, soundOutput: PropTypes.bool.isRequired, setTextOutput: PropTypes.func.isRequired, setGridOutput: PropTypes.func.isRequired, setSoundOutput: PropTypes.func.isRequired, lintWarning: PropTypes.bool.isRequired, setLintWarning: PropTypes.func.isRequired, theme: PropTypes.string.isRequired, setTheme: PropTypes.func.isRequired, }; export default Preferences;