p5.js-web-editor/client/modules/IDE/components/Preferences.js

85 lines
3.3 KiB
JavaScript
Raw Normal View History

import React, { PropTypes } from 'react';
2016-06-23 22:29:55 +00:00
const Isvg = require('react-inlinesvg');
const exitUrl = require('../../../images/exit.svg');
const plusUrl = require('../../../images/plus.svg');
const minusUrl = require('../../../images/minus.svg');
const classNames = require('classnames');
function Preferences(props) {
const preferencesContainerClass = classNames({
preferences: true,
'preferences--selected': props.isVisible
});
2016-07-11 02:52:48 +00:00
let preferencesTabOptionClass = classNames({
preference__option: true,
'preference__option--selected': props.isTabIndent
});
let preferencesSpaceOptionClass = classNames({
preference__option: true,
'preference__option--selected': !props.isTabIndent
});
return (
<div className={preferencesContainerClass} tabIndex="0">
<div className="preferences__heading">
<h2 className="preferences__title">Preferences</h2>
<button className="preferences__exit-button" onClick={props.closePreferences}>
<Isvg src={exitUrl} alt="Exit Preferences" />
</button>
2016-06-23 22:29:55 +00:00
</div>
2016-07-06 15:27:39 +00:00
<div className="preference">
2016-07-06 15:27:39 +00:00
<h4 className="preference__title">Text Size</h4>
<button className="preference__plus-button" onClick={props.decreaseFont}>
<Isvg src={minusUrl} alt="Decrease Font Size" />
2016-07-11 02:52:48 +00:00
<h6 className="preference__label">Decrease</h6>
</button>
2016-07-11 02:52:48 +00:00
<input className="preference__value" value={props.fontSize} onChange={props.updateFont}></input>
<button className="preference__minus-button" onClick={props.increaseFont}>
<Isvg src={plusUrl} alt="Increase Font Size" />
2016-07-11 02:52:48 +00:00
<h6 className="preference__label">Increase</h6>
</button>
2016-07-11 02:52:48 +00:00
</div>
2016-07-06 15:27:39 +00:00
<div className="preference">
<h4 className="preference__title">Indentation Amount</h4>
<button className="preference__plus-button" onClick={props.decreaseIndentation}>
<Isvg src={minusUrl} alt="DecreaseIndentation Amount" />
2016-07-11 02:52:48 +00:00
<h6 className="preference__label">Decrease</h6>
2016-07-06 15:27:39 +00:00
</button>
2016-07-11 02:52:48 +00:00
<input className="preference__value" value={props.indentationAmount} onChange={props.updateIndentation}></input>
2016-07-06 15:27:39 +00:00
<button className="preference__minus-button" onClick={props.increaseIndentation}>
<Isvg src={plusUrl} alt="IncreaseIndentation Amount" />
2016-07-11 02:52:48 +00:00
<h6 className="preference__label">Increase</h6>
2016-07-06 15:27:39 +00:00
</button>
2016-07-11 12:44:27 +00:00
<div className="preference__vertical-list">
<button className={preferencesSpaceOptionClass} onClick={props.indentWithSpace}>Spaces</button>
<button className={preferencesTabOptionClass} onClick={props.indentWithTab}>Tabs</button>
</div>
2016-07-06 15:27:39 +00:00
</div>
</div>
);
2016-06-23 22:29:55 +00:00
}
Preferences.propTypes = {
isVisible: PropTypes.bool.isRequired,
closePreferences: PropTypes.func.isRequired,
decreaseFont: PropTypes.func.isRequired,
2016-07-11 00:13:37 +00:00
updateFont: PropTypes.func.isRequired,
fontSize: PropTypes.number.isRequired,
2016-07-06 15:27:39 +00:00
increaseFont: PropTypes.func.isRequired,
indentationAmount: PropTypes.number.isRequired,
decreaseIndentation: PropTypes.func.isRequired,
2016-07-11 00:13:37 +00:00
increaseIndentation: PropTypes.func.isRequired,
2016-07-11 02:52:48 +00:00
updateIndentation: PropTypes.func.isRequired,
indentWithSpace: PropTypes.func.isRequired,
indentWithTab: PropTypes.func.isRequired,
isTabIndent: PropTypes.bool.isRequired
};
2016-06-23 22:29:55 +00:00
export default Preferences;