Skip to content

Commit 8d3e4f4

Browse files
authored
Merge pull request #20 from tonyito/mvp
Dummy Tutorial function and some smaller edits
2 parents d11dfd9 + b6d4f64 commit 8d3e4f4

File tree

10 files changed

+135
-68
lines changed

10 files changed

+135
-68
lines changed

main.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ function openFile() {
4141
mainWindow.webContents.send('new-file', file);
4242
}
4343

44+
function toggleTutorial() {
45+
mainWindow.webContents.send('tutorial_clicked');
46+
}
47+
4448
// Choose directory
4549
ipcMain.on('choose_app_dir', event => {
4650
const directory = dialog.showOpenDialog(mainWindow, {
@@ -92,28 +96,28 @@ const createWindow = () => {
9296
label: 'File',
9397
submenu: [
9498
{
95-
label: 'Open File',
99+
label: 'Open Image',
96100
accelerator: process.platform === 'darwin' ? 'Cmd+O' : 'Ctrl+Shift+O',
97101
click() {
98102
openFile();
99103
}
100104
}
101105
]
102106
},
103-
// {
104-
// label: 'Edit',
105-
// submenu: [
106-
// { role: 'undo' },
107-
// { role: 'redo' },
108-
// { type: 'separator' },
109-
// { role: 'cut' },
110-
// { role: 'copy' },
111-
// { role: 'paste' },
112-
// { role: 'pasteandmatchstyle' },
113-
// { role: 'delete' },
114-
// { role: 'selectall' },
115-
// ],
116-
// },
107+
{
108+
label: 'Edit',
109+
submenu: [
110+
{ role: 'undo' },
111+
{ role: 'redo' },
112+
{ type: 'separator' },
113+
{ role: 'cut' },
114+
{ role: 'copy' },
115+
{ role: 'paste' },
116+
{ role: 'pasteandmatchstyle' },
117+
{ role: 'delete' },
118+
{ role: 'selectall' },
119+
],
120+
},
117121
{
118122
label: 'View',
119123
submenu: [
@@ -137,7 +141,13 @@ const createWindow = () => {
137141
{
138142
label: 'Learn More',
139143
click() {
140-
shell.openExternal('https://electronjs.org');
144+
shell.openExternal('https://reactype.io');
145+
}
146+
},
147+
{
148+
label: 'Tutorial',
149+
click() {
150+
toggleTutorial();
141151
}
142152
}
143153
]

package.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
{
22
"name": "reactype",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "Prototyping tool for React/Typescript Applications.",
55
"main": "main.js",
66
"contributors": [
7+
"Adam Singer",
8+
"Charles Finocchiaro",
79
"Chelsey Fewer",
10+
"Christian Padilla",
11+
"Eliot Nguyen",
12+
"Jesse Zuniga",
813
"Mitchel Severe",
9-
"Sophia Huttner",
10-
"Charles Finocchiaro",
1114
"Natalie Vick",
12-
"Christian Padilla",
13-
"Tolga Mizrakci",
15+
"Sean Sadykoff",
1416
"Shlomo Porges",
15-
"Adam Singer"
16-
],
17+
"Sophia Huttner",
18+
"Tolga Mizrakci",
19+
"Tony Ito-Cole"
20+
],
1721
"repository": {
1822
"type": "git",
1923
"url": "https://github.com/team-reactype/ReacType"
2024
},
2125
"build": {
2226
"appId": "com.team-reactype.reactype",
23-
"copyright": "Copyright © 2018",
27+
"copyright": "Copyright © 2020",
2428
"linux": {
2529
"target": [
2630
"AppImage",
@@ -88,6 +92,7 @@
8892
"dependencies": {
8993
"@material-ui/core": "^3.9.3",
9094
"@material-ui/icons": "^2.0.0",
95+
"@material-ui/styles": "^4.9.0",
9196
"@types/prettier": "^1.19.0",
9297
"@types/react": "^16.8.14",
9398
"@types/react-dom": "^16.8.4",

src/components/KonvaStage.tsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import Rectangle from "./Rectangle";
77
import cloneDeep from "../utils/cloneDeep";
88
import { ComponentInt, ComponentsInt, ChildInt } from "../utils/Interfaces";
99
import isEmpty from '../utils/isEmpty';
10+
import Konva from "konva";
1011

12+
13+
//TODO check if these types are necessary
1114
interface PropsInt {
1215
image: HTMLImageElement;
1316
components: ComponentsInt;
@@ -34,10 +37,12 @@ interface StateInt {
3437
stageWidth: number;
3538
stageHeight: number;
3639
blockSnapSize: number;
37-
grid: [];
40+
grid: [] | JSX.Element[];
3841
gridStroke: number;
3942
}
4043

44+
45+
4146
class KonvaStage extends Component<PropsInt, StateInt> {
4247
constructor(props: PropsInt) {
4348
super(props);
@@ -52,11 +57,16 @@ class KonvaStage extends Component<PropsInt, StateInt> {
5257
grid: [],
5358
gridStroke: 1
5459
};
60+
5561
}
62+
63+
stage: Stage;
64+
layer: Konva.Layer;
65+
container: HTMLDivElement;
5666

5767
//makes a copy of the array of children plus the parent component pushed onto it
5868
getDirectChildrenCopy(focusComponent: ComponentInt) {
59-
//assign component to the docused component
69+
//assign component to the focused component
6070
const component = this.props.components.find(
6171
(comp: ComponentInt) => comp.id === focusComponent.id
6272
);
@@ -87,13 +97,15 @@ class KonvaStage extends Component<PropsInt, StateInt> {
8797
return childrenArrCopy;
8898
}
8999

100+
90101
//currently, only the handlekeydown event listener does anything.
91102
componentDidMount() {
92103
this.checkSize();
93104
// here we should add listener for "container" resize
94105
// take a look here https://developers.google.com/web/updates/2016/10/resizeobserver
95106
// for simplicity I will just listen window resize
96107
window.addEventListener("resize", this.checkSize);
108+
//TODO: Typing of this.container
97109
this.container.addEventListener("keydown", this.handleKeyDown);
98110
this.createGrid();
99111
}
@@ -105,7 +117,7 @@ class KonvaStage extends Component<PropsInt, StateInt> {
105117
this.container.removeEventListener("keydown", this.handleKeyDown);
106118
}
107119

108-
//something about the logic here isn't working. Will need to check some other time.
120+
//something about the logic here might not be working. Will need to check some other time.
109121
checkSize = () => {
110122
const width = this.container.offsetWidth;
111123
const height = this.container.offsetHeight;
@@ -126,6 +138,7 @@ class KonvaStage extends Component<PropsInt, StateInt> {
126138
//event handler to handle mouse click
127139
handleStageMouseDown = (e: any) => {
128140
// clicked on stage - clear selection
141+
//logic here doesn't seem to be working
129142
if (e.target === e.target.getStage()) {
130143
return;
131144
}
@@ -206,14 +219,14 @@ class KonvaStage extends Component<PropsInt, StateInt> {
206219
height: "100%"
207220
}}
208221
ref={node => {
209-
this.container = node;
222+
this.container= node;
210223
}}
211-
tabIndex="0" // required for keydown event to be heard by this.container
224+
tabIndex= {0} // required for keydown event to be heard by this.container
212225
>
213226
<Stage
214227
className={"canvasStage"}
215228
ref={node => {
216-
this.stage = node;
229+
this.stage = node;
217230
}}
218231
onMouseDown={this.handleStageMouseDown}
219232
width={this.state.stageWidth}
@@ -226,7 +239,7 @@ class KonvaStage extends Component<PropsInt, StateInt> {
226239
}}
227240
>
228241
{this.state.grid}
229-
{/* {The logic hereis that it creates a new rectangle or each component that belongs to this parent component, plus the parent component.
242+
{/* {The logic here is that it creates a new rectangle for each component that belongs to this parent component, plus the parent component.
230243
The parent component is rendered last. It renders based on the values in the return value of getDirectChildrenCopy. } */}
231244
{!isEmpty(focusComponent) && this.getDirectChildrenCopy(focusComponent)
232245
.map((child: ChildInt, i: number) => (
@@ -239,7 +252,7 @@ class KonvaStage extends Component<PropsInt, StateInt> {
239252
childComponentName={child.componentName}
240253
focusChild={focusChild}
241254
childId={child.childId} // -1 for pseudoChild
242-
x={child.position.x}
255+
x={child.position.x}
243256
y={child.position.y}
244257
scaleX={1}
245258
scaleY={1}
@@ -252,7 +265,7 @@ class KonvaStage extends Component<PropsInt, StateInt> {
252265
image={this.props.focusComponent.id === 1 ? image : null}
253266
/>
254267
))
255-
.sort((rectA, rectB) => {
268+
.sort((rectA: Rectangle, rectB: Rectangle) => {
256269
if (rectB.props.childId === -1) {
257270
return 1;
258271
}

src/components/LeftColExpansionPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const LeftColExpansionPanel = (props: any) => {
7676
primary={
7777
<div>
7878
<Typography
79-
type='body2'
79+
//type='body2'
8080
style={{
8181
color: '#fff',
8282
textShadow: '1px 1px 2px rgba(0, 0, 0, 0.2)',

src/components/Rectangle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ interface PropsInt {
2929
}
3030

3131
class Rectangle extends Component<PropsInt> {
32-
rect: Konva.Rect;
3332
group: Konva.Group;
33+
rect: Konva.Rect;
3434

3535
//This assigns the color to the Rect based on componentId's color in the state
3636
getComponentColor(componentId: number) {

src/components/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const theme = createMuiTheme({
1414
contrastText: '#fff',
1515
},
1616
secondary: indigo,
17-
},
17+
}
1818
});
1919

2020
export default theme;

0 commit comments

Comments
 (0)