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

75 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-06-27 19:08:25 +00:00
import React, { PropTypes } from 'react';
2016-06-23 22:29:55 +00:00
const Isvg = require('react-inlinesvg');
const playUrl = require('../../../images/play.svg');
const logoUrl = require('../../../images/p5js-logo.svg');
const stopUrl = require('../../../images/stop.svg');
const preferencesUrl = require('../../../images/preferences.svg');
const classNames = require('classnames');
2016-06-27 19:08:25 +00:00
function Toolbar(props) {
let playButtonClass = classNames({
'toolbar__play-button': true,
'toolbar__play-button--selected': props.isPlaying
});
let stopButtonClass = classNames({
'toolbar__stop-button': true,
'toolbar__stop-button--selected': !props.isPlaying
});
let preferencesButtonClass = classNames({
'toolbar__preferences-button': true,
'toolbar__preferences-button--selected': props.isPreferencesVisible
});
2016-06-23 22:29:55 +00:00
2016-06-27 19:08:25 +00:00
return (
<div className="toolbar">
<img className="toolbar__logo" src={logoUrl} alt="p5js Logo" />
2016-07-15 20:47:12 +00:00
<button className={playButtonClass} onClick={props.startSketch} id="play-button">
2016-06-27 19:08:25 +00:00
<Isvg src={playUrl} alt="Play Sketch" />
</button>
2016-07-15 20:47:12 +00:00
<label htmlFor="play-button" className="toolbar__button-label">
play
</label>
<button className={stopButtonClass} onClick={props.stopSketch} id="stop-button">
2016-06-27 19:08:25 +00:00
<Isvg src={stopUrl} alt="Stop Sketch" />
</button>
2016-07-15 20:47:12 +00:00
<label htmlFor="stop-button" className="toolbar__button-label">
stop
</label>
2016-06-27 19:08:25 +00:00
<div className="toolbar__project-name-container">
<span
className="toolbar__project-name"
2016-06-27 21:22:54 +00:00
// TODO change this span into an input
2016-07-12 16:25:48 +00:00
onBlur={props.setProjectName.bind(this)} // eslint-disable-line
2016-06-27 19:08:25 +00:00
contentEditable
suppressContentEditableWarning
>
{props.projectName}
</span>
2016-06-23 22:29:55 +00:00
</div>
2016-07-13 19:23:48 +00:00
<button
className={preferencesButtonClass}
onClick={props.openPreferences}
2016-07-15 20:47:12 +00:00
id="preferences-button"
2016-07-13 19:23:48 +00:00
>
2016-06-27 19:08:25 +00:00
<Isvg src={preferencesUrl} alt="Show Preferences" />
</button>
2016-07-15 20:47:12 +00:00
<label htmlFor="preferences-button" className="toolbar__button-label">
preferences
</label>
2016-06-27 19:08:25 +00:00
</div>
);
2016-06-23 22:29:55 +00:00
}
2016-06-27 19:08:25 +00:00
Toolbar.propTypes = {
isPlaying: PropTypes.bool.isRequired,
isPreferencesVisible: PropTypes.bool.isRequired,
startSketch: PropTypes.func.isRequired,
stopSketch: PropTypes.func.isRequired,
setProjectName: PropTypes.func.isRequired,
projectName: PropTypes.string.isRequired,
openPreferences: PropTypes.func.isRequired
};
2016-06-23 22:29:55 +00:00
export default Toolbar;