Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status bar #432

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\index.js":"1","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\containers\\AppContainer.js":"2","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\reducers\\index.js":"3","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\containers\\MainContainer.js":"4","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\app.js":"5","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\reducers\\programsReducer.js":"6","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\Login.js":"7","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\EditorAndOutput\\EditorAndOutput.js":"8","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\Sketches\\index.js":"9","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\Sketches\\containers\\EditSketchModalContainer.js":"10","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\common\\OpenPanelButton.js":"11","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\Sketches\\components\\DropdownButton.js":"12","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\lib\\sketch.js":"13","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\TextEditor\\components\\StatusBar.js":"14","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\TextEditor\\components\\TextEditor.js":"15","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\common\\ProfilePanel.js":"16","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\reducers\\uiReducer.js":"17","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\actions\\uiActions.js":"18","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\common\\containers\\ProfilePanelContainer.js":"19","D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\TextEditor\\containers\\TextEditorContainer.js":"20"},{"size":764,"mtime":1612404807718,"results":"21","hashOfConfig":"22"},{"size":1623,"mtime":1602724010484,"results":"23","hashOfConfig":"22"},{"size":407,"mtime":1602724010893,"results":"24","hashOfConfig":"22"},{"size":2155,"mtime":1612404807696,"results":"25","hashOfConfig":"22"},{"size":6586,"mtime":1612404807625,"results":"26","hashOfConfig":"22"},{"size":1268,"mtime":1602724010900,"results":"27","hashOfConfig":"22"},{"size":4931,"mtime":1602724006777,"results":"28","hashOfConfig":"22"},{"size":3621,"mtime":1602724006775,"results":"29","hashOfConfig":"22"},{"size":5955,"mtime":1612404807589,"results":"30","hashOfConfig":"22"},{"size":801,"mtime":1602724009096,"results":"31","hashOfConfig":"22"},{"size":789,"mtime":1602724010456,"results":"32","hashOfConfig":"22"},{"size":2280,"mtime":1602724008820,"results":"33","hashOfConfig":"22"},{"size":738,"mtime":1602724010785,"results":"34","hashOfConfig":"22"},{"size":482,"mtime":1613086981399,"results":"35","hashOfConfig":"22"},{"size":11539,"mtime":1613087017437,"results":"36","hashOfConfig":"22"},{"size":10474,"mtime":1613088242026,"results":"37","hashOfConfig":"22"},{"size":1003,"mtime":1613086930261,"results":"38","hashOfConfig":"22"},{"size":634,"mtime":1613086901589,"results":"39","hashOfConfig":"22"},{"size":1259,"mtime":1613087549546,"results":"40","hashOfConfig":"22"},{"size":1564,"mtime":1613087652148,"results":"41","hashOfConfig":"22"},{"filePath":"42","messages":"43","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1xdarae",{"filePath":"44","messages":"45","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"46","messages":"47","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"48","messages":"49","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"52","messages":"53","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"56","messages":"57","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"68","messages":"69","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"74","messages":"75","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"78","messages":"79","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"80","messages":"81","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\index.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\containers\\AppContainer.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\reducers\\index.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\containers\\MainContainer.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\app.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\reducers\\programsReducer.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\Login.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\EditorAndOutput\\EditorAndOutput.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\Sketches\\index.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\Sketches\\containers\\EditSketchModalContainer.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\common\\OpenPanelButton.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\Sketches\\components\\DropdownButton.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\lib\\sketch.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\TextEditor\\components\\StatusBar.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\TextEditor\\components\\TextEditor.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\common\\ProfilePanel.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\reducers\\uiReducer.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\actions\\uiActions.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\common\\containers\\ProfilePanelContainer.js",[],"D:\\Projects\\TeachLA\\TeachLAFrontend\\src\\components\\TextEditor\\containers\\TextEditorContainer.js",[]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file can be safely deleted. I will add it to our .gitignore a little later.

5 changes: 5 additions & 0 deletions src/actions/uiActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ export const SET_THEME = "SET_THEME";
export function setTheme(theme) {
return { type: SET_THEME, theme };
}

export const SHOW_STATUSBAR = "SHOW_STATUSBAR";
export function setStatusBar(value) {
return { type: SHOW_STATUSBAR, value };
}
17 changes: 17 additions & 0 deletions src/components/TextEditor/components/StatusBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { useState } from "react";

const StatusBar = (props) => {
const edit = props.editing;
const textStyle = { color: "white" };
if (props.theme === "light") {
textStyle.color = "black";
}
return (
<div className="status-bar-container">
<p className="status-bar-info" style={textStyle}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think that we could integrate this with our built-in styles with something like this instead:

<p className="status-bar-info" className={props.theme === "light" ? "light-status" : "dark-status"}>

{edit ? "Editing" : "Viewing"} line: {props.line + 1} col: {props.col + 1}{" "}
</p>
</div>
);
};
export default StatusBar;
18 changes: 15 additions & 3 deletions src/components/TextEditor/components/TextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import sketch from "../../../lib/";

import EditorRadio from "./EditorRadio.js";
import ShareSketchModal from "./ShareSketchModal";
import StatusBar from "./StatusBar";

import { Button } from "reactstrap";
import OpenPanelButtonContainer from "../../common/containers/OpenPanelButtonContainer";
Expand Down Expand Up @@ -37,6 +38,7 @@ class TextEditor extends React.Component {
this.state = {
codeMirrorInstance: null,
currentLine: 0,
currentColumn: 0,
sketch: null,
showForkModal: false,
forking: false,
Expand Down Expand Up @@ -102,17 +104,16 @@ class TextEditor extends React.Component {
}
this.props.setProgramCode(this.props.mostRecentProgram, newCode);
};

setCurrentLine = (cm) => {
const { codeMirrorInstance, currentLine } = this.state;
let { line } = cm.getCursor();
let { line, ch } = cm.getCursor();
if (codeMirrorInstance) {
//removeLineClass removes the back highlight style from the last selected line
codeMirrorInstance.removeLineClass(currentLine, "wrap", "selected-line");
//addLineClass adds the style to the newly selected line
codeMirrorInstance.addLineClass(line, "wrap", "selected-line");
}
this.setState({ currentLine: line });
this.setState({ currentLine: line, currentColumn: ch });
};

renderForkModal = () => {
Expand Down Expand Up @@ -299,6 +300,7 @@ class TextEditor extends React.Component {
showModal={this.state.showShareModal}
toggleModal={this.toggleShareModal}
/>

<div
className="text-editor-container"
style={{
Expand All @@ -322,6 +324,16 @@ class TextEditor extends React.Component {
onBeforeChange={this.updateCode}
onChange={this.updateCode}
/>
{this.props.statusBar ? (
<StatusBar
editing={!this.props.viewOnly}
line={this.state.currentLine}
col={this.state.currentColumn}
theme={this.props.theme}
/>
) : (
""
)}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const mapStateToProps = (state, ownProps) => {
mostRecentProgram,
theme: ownProps.theme,
uid,
statusBar: state.ui.statusBar,
};
};

Expand Down
14 changes: 14 additions & 0 deletions src/components/common/ProfilePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,19 @@ class ProfilePanel extends React.Component {
</div>
);

renderShowStatusBar = () => {
let onToggle = () => {
console.log(this.props);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove extraneous logging.

Suggested change
console.log(this.props);

this.props.setStatusBar(!this.props.statusBar);
};
return (
<div className="panel-button">
<button className="statusbar-button" onClick={() => onToggle()}>
<span> Status Bar</span>
</button>
</div>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, let's mask the button from the editor, then we can add a button for it when we create the collaborative editor. Apologies if that wasn't clear. As a side note, using the same classes as themeSwitch, etc. would benefit its uniformity:

image

renderContent = () => (
<div className="panel-content">
{this.renderPanelImage()}
Expand All @@ -324,6 +337,7 @@ class ProfilePanel extends React.Component {
{this.renderErrorMessage(this.state.displayNameMessage)}
{this.renderButtons()}
{this.renderThemeSwitch()}
{this.renderShowStatusBar()}
</div>
);

Expand Down
8 changes: 5 additions & 3 deletions src/components/common/containers/ProfilePanelContainer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ProfilePanel from "../ProfilePanel";
import { connect } from "react-redux";
import { setDisplayName, setPhotoName } from "../../../actions/userDataActions";
import { togglePanel } from "../../../actions/uiActions";
import { setStatusBar, togglePanel } from "../../../actions/uiActions";
import { DEFAULT_PHOTO_NAME, CLOSED_PANEL_LEFT, OPEN_PANEL_LEFT } from "../../../constants";

const mapStateToProps = (state, ownProps) => {
Expand All @@ -12,18 +12,20 @@ const mapStateToProps = (state, ownProps) => {
screenHeight: state.ui.screenHeight,
left: state.ui.panelOpen ? OPEN_PANEL_LEFT : CLOSED_PANEL_LEFT,
theme: ownProps.theme,
statusBar: state.ui.statusBar,
};
};

const mapDispatchToProps = (dispatch, ownProps) => {
return {
onThemeChange: ownProps.onThemeChange,
collectUserPhoto: () => {},
setDisplayName: name => dispatch(setDisplayName(name)),
setPhotoName: name => dispatch(setPhotoName(name)),
setDisplayName: (name) => dispatch(setDisplayName(name)),
setPhotoName: (name) => dispatch(setPhotoName(name)),
togglePanel: () => {
dispatch(togglePanel());
},
setStatusBar: (value) => dispatch(setStatusBar(value)),
};
};

Expand Down
11 changes: 10 additions & 1 deletion src/reducers/uiReducer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { SCREEN_RESIZE, TOGGLE_PANEL, SET_PANEL, SET_THEME } from "../actions/uiActions";
import {
SCREEN_RESIZE,
TOGGLE_PANEL,
SET_PANEL,
SET_THEME,
SHOW_STATUSBAR,
} from "../actions/uiActions";

const initialState = {
screenWidth: typeof window === "object" ? window.innerWidth : null,
screenHeight: typeof window === "object" ? window.innerHeight : null,
panelOpen: false,
theme: "dark",
statusBar: false,
};

function uiReducer(state = initialState, action) {
Expand All @@ -17,6 +24,8 @@ function uiReducer(state = initialState, action) {
return Object.assign({}, state, { panelOpen: action.value });
case SET_THEME:
return Object.assign({}, state, { theme: action.theme });
case SHOW_STATUSBAR:
return Object.assign({}, state, { statusBar: action.value });
default:
return state;
}
Expand Down
23 changes: 18 additions & 5 deletions src/styles/Editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
padding: 4px;
border-radius: 25px;
@include themify($themes) {
background-color: themed("cardBackground")
}
background-color: themed("cardBackground");
}
}


.program-sketch-name {
flex: 0 1 auto;
@include themify($themes) {
Expand All @@ -47,7 +46,6 @@
margin-left: 1em;
}


.code-section-banner {
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -179,4 +177,19 @@
background-color: rgb(255, 255, 255);
padding: 40px;
border-radius: 20px;
}
}

.status-bar-container {
@include themify($themes) {
background-color: themed("backgroundColor");
}
margin-left: 60%;
padding: 10px 20px 0px;
position: absolute;
bottom: 0%;
width: fit-content;
}

.status-bar-info {
font-size: 25px;
}
7 changes: 7 additions & 0 deletions src/styles/Panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@
}
}

.statusbar-button {
@include themify($themes) {
color: themed("color");
border-color: themed("backgroundColor");
background-color: themed("backgroundColor");
}
}
.panel-button:hover,
.panel-button:active {
@include themify($themes) {
Expand Down