Skip to content

Commit d48cdd8

Browse files
committed
Add subtle edit button to instructions bar
Closes popcodeorg#145
1 parent f3890e2 commit d48cdd8

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/components/Workspace.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class Workspace extends React.Component {
3030
this,
3131
'_handleUnload',
3232
'_handleClickInstructionsBar',
33+
'_handleClickInstructionsEditButton',
3334
);
3435
this.columnRefs = [null, null];
3536
}
@@ -76,6 +77,15 @@ export default class Workspace extends React.Component {
7677
}
7778
}
7879

80+
_handleClickInstructionsEditButton() {
81+
const {isEditingInstructions, onClickInstructionsEditButton} = this.props;
82+
if (!isEditingInstructions) {
83+
onClickInstructionsEditButton(
84+
get(this.props, ['currentProject', 'projectKey']),
85+
);
86+
}
87+
}
88+
7989
_renderInstructionsBar() {
8090
const currentInstructions = get(
8191
this.props,
@@ -98,6 +108,17 @@ export default class Workspace extends React.Component {
98108
u__icon_disabled: this.props.isEditingInstructions,
99109
})}
100110
>&#xf05a;</span>
111+
{!this.props.isEditingInstructions &&
112+
<span
113+
className="u__icon layout__instructions-bar-edit-button"
114+
onClick={(e) => {
115+
e.stopPropagation();
116+
this._handleClickInstructionsEditButton();
117+
}}
118+
>
119+
&#xf044;
120+
</span>
121+
}
101122
</div>
102123
);
103124
}
@@ -164,6 +185,7 @@ Workspace.propTypes = {
164185
resizableFlexGrow: ImmutablePropTypes.list.isRequired,
165186
resizableFlexRefs: PropTypes.array.isRequired,
166187
onApplicationLoaded: PropTypes.func.isRequired,
188+
onClickInstructionsEditButton: PropTypes.func.isRequired,
167189
onComponentToggle: PropTypes.func.isRequired,
168190
onResizableFlexDividerDrag: PropTypes.func.isRequired,
169191
onStartDragColumnDivider: PropTypes.func.isRequired,

src/containers/Workspace.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
applicationLoaded,
88
startDragColumnDivider,
99
stopDragColumnDivider,
10+
startEditingInstructions,
1011
} from '../actions';
1112
import resizableFlex from '../higherOrderComponents/resizableFlex';
1213

@@ -34,6 +35,10 @@ function mapDispatchToProps(dispatch) {
3435
onStopDragColumnDivider() {
3536
dispatch(stopDragColumnDivider());
3637
},
38+
39+
onClickInstructionsEditButton(projectKey) {
40+
dispatch(startEditingInstructions(projectKey));
41+
},
3742
};
3843
}
3944

src/css/application.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ body {
122122
cursor: pointer;
123123
display: flex;
124124
flex: none;
125+
flex-direction: column;
125126
font-size: 2em;
126127
text-align: center;
127128
padding: 0.25em;
@@ -131,6 +132,15 @@ body {
131132
cursor: default;
132133
}
133134

135+
.layout__instructions-bar-edit-button {
136+
margin-top: .25em;
137+
opacity: 0;
138+
}
139+
140+
.layout__instructions-bar:hover .layout__instructions-bar-edit-button {
141+
opacity: 1;
142+
}
143+
134144
.layout__main {
135145
flex: 1 1 100vw;
136146
position: relative;

0 commit comments

Comments
 (0)