Skip to content
Snippets Groups Projects
Commit ecaee987 authored by Ray Schamp's avatar Ray Schamp
Browse files

Add green flag and stop buttons to blocks example

Add class name props to the components, and fix positioning for the green flag to be reusable.
parent c92b14be
No related branches found
No related tags found
No related merge requests found
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
width: 1.1rem; width: 1.1rem;
height: 1.1rem; height: 1.1rem;
opacity: 0.5; opacity: 0.5;
margin: 0.25rem 0.6rem;
user-select: none; user-select: none;
cursor: pointer; cursor: pointer;
transition: opacity 0.2s ease-out; /* @todo: standardize with var */ transition: opacity 0.2s ease-out; /* @todo: standardize with var */
} }
.green-flag.is-active, .green-flag.is-active,
......
...@@ -8,16 +8,20 @@ import styles from './green-flag.css'; ...@@ -8,16 +8,20 @@ import styles from './green-flag.css';
const GreenFlagComponent = function (props) { const GreenFlagComponent = function (props) {
const { const {
active, active,
className,
onClick, onClick,
title, title,
...componentProps ...componentProps
} = props; } = props;
return ( return (
<img <img
className={classNames({ className={classNames(
[styles.greenFlag]: true, className,
[styles.isActive]: active styles.greenFlag,
})} {
[styles.isActive]: active
}
)}
src={greenFlagIcon} src={greenFlagIcon}
title={title} title={title}
onClick={onClick} onClick={onClick}
...@@ -27,6 +31,7 @@ const GreenFlagComponent = function (props) { ...@@ -27,6 +31,7 @@ const GreenFlagComponent = function (props) {
}; };
GreenFlagComponent.propTypes = { GreenFlagComponent.propTypes = {
active: PropTypes.bool, active: PropTypes.bool,
className: PropTypes.string,
onClick: PropTypes.func.isRequired, onClick: PropTypes.func.isRequired,
title: PropTypes.string title: PropTypes.string
}; };
......
...@@ -101,6 +101,10 @@ ...@@ -101,6 +101,10 @@
position: relative; position: relative;
} }
.green-flag {
margin: 0.25rem 0.6rem;
}
.stage-and-target-wrapper { .stage-and-target-wrapper {
/* /*
Makes rows for children: Makes rows for children:
......
...@@ -90,7 +90,10 @@ const GUIComponent = props => { ...@@ -90,7 +90,10 @@ const GUIComponent = props => {
<Box className={styles.stageAndTargetWrapper}> <Box className={styles.stageAndTargetWrapper}>
<Box className={styles.stageMenuWrapper}> <Box className={styles.stageMenuWrapper}>
<GreenFlag vm={vm} /> <GreenFlag
className={styles.greenFlag}
vm={vm}
/>
<StopAll vm={vm} /> <StopAll vm={vm} />
</Box> </Box>
<Box className={styles.stageWrapper}> <Box className={styles.stageWrapper}>
......
...@@ -8,16 +8,20 @@ import styles from './stop-all.css'; ...@@ -8,16 +8,20 @@ import styles from './stop-all.css';
const StopAllComponent = function (props) { const StopAllComponent = function (props) {
const { const {
active, active,
className,
onClick, onClick,
title, title,
...componentProps ...componentProps
} = props; } = props;
return ( return (
<img <img
className={classNames({ className={classNames(
[styles.stopAll]: true, className,
[styles.isActive]: active styles.stopAll,
})} {
[styles.isActive]: active
}
)}
src={stopAllIcon} src={stopAllIcon}
title={title} title={title}
onClick={onClick} onClick={onClick}
...@@ -28,6 +32,7 @@ const StopAllComponent = function (props) { ...@@ -28,6 +32,7 @@ const StopAllComponent = function (props) {
StopAllComponent.propTypes = { StopAllComponent.propTypes = {
active: PropTypes.bool, active: PropTypes.bool,
className: PropTypes.string,
onClick: PropTypes.func.isRequired, onClick: PropTypes.func.isRequired,
title: PropTypes.string title: PropTypes.string
}; };
......
.app { .green-flag {
position: absolute;
z-index: 2;
top: 10px;
right: 50px;
}
.stop-all {
position: absolute;
z-index: 2;
top: 10px;
right: 15px;
} }
...@@ -3,6 +3,8 @@ import ReactDOM from 'react-dom'; ...@@ -3,6 +3,8 @@ import ReactDOM from 'react-dom';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import AppStateHOC from '../lib/app-state-hoc.jsx'; import AppStateHOC from '../lib/app-state-hoc.jsx';
import GreenFlag from '../containers/green-flag.jsx';
import StopAll from '../containers/stop-all.jsx';
import Blocks from '../containers/blocks.jsx'; import Blocks from '../containers/blocks.jsx';
import GUI from '../containers/gui.jsx'; import GUI from '../containers/gui.jsx';
import ProjectLoaderHOC from '../lib/project-loader-hoc.jsx'; import ProjectLoaderHOC from '../lib/project-loader-hoc.jsx';
...@@ -10,7 +12,10 @@ import ProjectLoaderHOC from '../lib/project-loader-hoc.jsx'; ...@@ -10,7 +12,10 @@ import ProjectLoaderHOC from '../lib/project-loader-hoc.jsx';
import styles from './blocks-only.css'; import styles from './blocks-only.css';
const mapStateToProps = (state) => ({vm: state.vm}); const mapStateToProps = (state) => ({vm: state.vm});
const VMBlocks = connect(mapStateToProps)(Blocks); const VMBlocks = connect(mapStateToProps)(Blocks);
const VMGreenFlag = connect(mapStateToProps)(GreenFlag);
const VMStopAll = connect(mapStateToProps)(StopAll);
const BlocksOnly = props => ( const BlocksOnly = props => (
<GUI {...props}> <GUI {...props}>
...@@ -20,13 +25,14 @@ const BlocksOnly = props => ( ...@@ -20,13 +25,14 @@ const BlocksOnly = props => (
media: `static/blocks-media/` media: `static/blocks-media/`
}} }}
/> />
<VMGreenFlag className={styles.greenFlag} />
<VMStopAll className={styles.stopAll} />
</GUI> </GUI>
); );
const App = AppStateHOC(ProjectLoaderHOC(BlocksOnly)); const App = AppStateHOC(ProjectLoaderHOC(BlocksOnly));
const appTarget = document.createElement('div'); const appTarget = document.createElement('div');
appTarget.className = styles.app;
document.body.appendChild(appTarget); document.body.appendChild(appTarget);
ReactDOM.render(<App />, appTarget); ReactDOM.render(<App />, appTarget);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment