Skip to content

Commit 324f346

Browse files
author
john lim
committed
tutorial finished and console logs cleaned up
1 parent 0ec607d commit 324f346

16 files changed

+26
-50
lines changed

app/electron/main.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ const isDev =
2929
const port = 8080;
3030
const selfHost = `http://localhost:${port}`;
3131

32-
// main.js is what controls the lifecycle of the electron applicaton
32+
// main.js is what controls the lifecycle of the electron application
3333

3434
// Keep a global reference of the window object, if you don't, the window will
3535
// be closed automatically when the JavaScript object is garbage collected.
3636
let win;
3737
let menuBuilder;
3838

39-
// function to create a new broswer window
39+
// function to create a new browser window
4040
// this function will be called when Electron has initialized itself
4141
async function createWindow() {
4242
if (isDev) {
@@ -58,22 +58,22 @@ async function createWindow() {
5858
minWidth: 980,
5959
// window title
6060
title: `ReacType`,
61-
// the browser window will not display intiially as it's loading
61+
// the browser window will not display initially as it's loading
6262
// once the browser window renders, a function is called below that hides the splash screen and displays the browser window
6363
show: false,
6464
// icon: path.join(__dirname, '../src/public/icons/png/256x256.png'),
6565
webPreferences: {
6666
zoomFactor: 0.7,
6767
// enable devtools when in development mode
6868
devTools: isDev,
69-
// crucial security feature - blocks rendering process from having access to node moduels
69+
// crucial security feature - blocks rendering process from having access to node modules
7070
nodeIntegration: false,
7171
// web workers will not have access to node
7272
nodeIntegrationInWorker: false,
73-
// disallow experimental feature to allow node.js suppport in subframes (iframes/child windows)
73+
// disallow experimental feature to allow node.js support in sub-frames (i-frames/child windows)
7474
nodeIntegrationInSubFrames: false,
75-
// runs electron apis and preload script in a seperate JS context
76-
// sepearate context has access to document/window but has it's own built-ins and is isolate from chagnes to gloval environment by locaded page
75+
// runs electron apis and preload script in a separate JS context
76+
// separate context has access to document/window but has it's own built-ins and is isolate from changes to global environment by located page
7777
// Electron API only available from preload, not loaded page
7878
contextIsolation: true,
7979
// disables remote module. critical for ensuring that rendering process doesn't have access to node functionality
@@ -101,7 +101,7 @@ async function createWindow() {
101101

102102
// Load app
103103
if (isDev) {
104-
// load app from webdev server
104+
// load app from web-dev server
105105
win.loadURL(selfHost);
106106
} else {
107107
// load local file if in production
@@ -262,12 +262,12 @@ app.on('web-contents-created', (event, contents) => {
262262

263263
event.preventDefault();
264264
return;
265-
} else console.log('Succesful link sent to browser');
265+
} else console.log('Successful link sent to browser');
266266
});
267267

268268
// https://electronjs.org/docs/tutorial/security#11-verify-webview-options-before-creation
269269
// The web-view is used to embed guest content in a page
270-
// This event listener deletes webviews if they happen to occur in the app
270+
// This event listener deletes web-views if they happen to occur in the app
271271
// https://www.electronjs.org/docs/api/web-contents#event-will-attach-webview
272272
contents.on('will-attach-webview', (event, webPreferences, params) => {
273273
// Strip away preload scripts if unused or verify their location is legitimate
@@ -380,15 +380,15 @@ ipcMain.on('delete_cookie', event => {
380380
.catch(err => console.log('Error deleting cookie:', err));
381381
});
382382

383-
// opens new window for github oauth when button on signin page is clicked
383+
// opens new window for github oauth when button on sign in page is clicked
384384
ipcMain.on('github', event => {
385385
// your github applications credentials
386386
const options = {
387387
client_id: 'your_client_id',
388388
client_secret: 'your_client_secret',
389389
scopes: ['user:email', 'notifications']
390390
};
391-
// create new browserwindow object with size, title, security options
391+
// create new browser window object with size, title, security options
392392
const github = new BrowserWindow({
393393
width: 800,
394394
height: 600,
@@ -428,7 +428,7 @@ ipcMain.on('github', event => {
428428
});
429429

430430
ipcMain.on('tutorial', event => {
431-
// create new browserwindow object with size, title, security options
431+
// create new browser window object with size, title, security options
432432
const tutorial = new BrowserWindow({
433433
width: 800,
434434
height: 600,

app/electron/menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var MenuBuilder = function(mainWindow, appName) {
2727
contextIsolation: true,
2828
enableRemoteModule: false,
2929
zoomFactor: 1.0,
30-
// devTools: false
30+
devTools: false
3131
}
3232
});
3333
tutorial.loadURL(`http://localhost:8080/#/tutorial`);

app/src/components/left/ComponentPanel.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ const ComponentPanel = (): JSX.Element => {
162162
{state.components
163163
.filter(comp => state.rootComponents.includes(comp.id))
164164
.map(comp => {
165-
//console.log('root comp', comp.name)
166165
return (
167166
<ComponentPanelItem
168167
isFocus={isFocus(comp.id)}
@@ -180,8 +179,6 @@ const ComponentPanel = (): JSX.Element => {
180179
{state.components
181180
.filter(comp => !state.rootComponents.includes(comp.id))
182181
.map(comp => {
183-
//console.log('all root comps', state.rootComponents);
184-
//console.log('all reusable comps', state.components);
185182
return (
186183
<ComponentPanelItem
187184
isFocus={isFocus(comp.id)}

app/src/components/left/HTMLPanel.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ const HTMLPanel = (): JSX.Element => {
7474
const formattedName =
7575
inputNameClean.charAt(0).toUpperCase() + inputNameClean.slice(1);
7676
// add new component to state
77-
console.log(inputTag);
78-
console.log(inputName);
7977
const newElement = {
8078
id: currentID,
8179
tag: inputTag,
@@ -89,7 +87,6 @@ const HTMLPanel = (): JSX.Element => {
8987
type: 'ADD ELEMENT',
9088
payload: newElement
9189
});
92-
9390
setCurrentID(currentID + 1);
9491
setTag('');
9592
setName('');

app/src/components/main/Canvas.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const findNestedChild = (curr, components) => {
1111
comp.children.forEach(child => {
1212
if (child.name === curr.name) console.log(child.name)
1313
});
14-
if (comp.children.length !== 0) findNestedChild(curr, comp.children);
14+
if (comp.children.length !== 0) findNestedChild(curr, comp.children);
1515
});
1616
}
1717

@@ -84,7 +84,7 @@ function Canvas() {
8484
// Combine the default styles of the canvas with the custom styles set by the user for that component
8585
// The render children function renders all direct children of a given component
8686
// Direct children are draggable/clickable
87-
87+
8888
const canvasStyle = combineStyles(defaultCanvasStyle, currentComponent.style);
8989
return (
9090
<div ref={drop} style={canvasStyle} onClick={onClickHandler}>

app/src/components/main/DirectChildComponent.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function DirectChildComponent({ childId, type, typeId, style }: ChildElement) {
2222
const referencedComponent: Component = state.components.find(
2323
(elem: Component) => elem.id === typeId
2424
);
25-
25+
2626
const [{ isDragging }, drag] = useDrag({
2727
// setting item attributes to be referenced when updating state with new instance of dragged item
2828
item: {
@@ -58,8 +58,6 @@ function DirectChildComponent({ childId, type, typeId, style }: ChildElement) {
5858
state.canvasFocus.childId === childId ? '1px 1px 3px rgb(11,212,112)' : ''
5959
};
6060

61-
//console.log('reference comp', referencedComponent);
62-
6361
const combinedStyle = combineStyles(
6462
combineStyles(
6563
combineStyles(globalDefaultStyle, referencedComponent.style),
@@ -87,7 +85,7 @@ function DirectChildComponent({ childId, type, typeId, style }: ChildElement) {
8785
childReferencedComponent.style,
8886
child.style
8987
);
90-
88+
9189
// render an IndirectChild component, and also call renderIndirectChildren recursively to render any of the child Component's children
9290
return (
9391
<IndirectChild

app/src/components/main/RouteLink.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ function RouteLink({ childId, type, typeId, style }: ChildElement) {
1111
const ref = useRef(null);
1212

1313
// find the name of the Component corresponding with this link
14-
console.log(state.components);
15-
1614
const routeName: string = state.components.find(
1715
(comp: Component) => comp.id === typeId
1816
).name;

app/src/components/right/DeleteProjects.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ function ProjectsDialog(props: ProjectDialogProps) {
4242
const selectedProject = projects.filter(
4343
(project: any) => project.name === value
4444
)[0];
45-
console.log('selectedProject is', selectedProject);
4645
deleteProject(selectedProject);
4746
localforage.removeItem(window.localStorage.getItem('ssid'));
4847
dispatch({ type: 'SET INITIAL STATE', payload: initialState });

app/src/components/right/ProjectManager.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const ProjectManager = () => {
3232
const classes = useStyles();
3333

3434
const { style, setStyle } = useContext(styleContext);
35-
// console.log('style: ', style);
3635

3736
// Allows users to toggle project between "next.js" and "Classic React"
3837
// When a user changes the project type, the code of all components is rerendered

app/src/containers/AppContainer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const styleContext = createContext({
1111
style: null,
1212
setStyle: null
1313
});
14-
// console.log('styleContext: ', styleContext);
1514

1615
const AppContainer = () => {
1716
const [theme, setTheme] = useState(theme1);

app/src/helperFunctions/generateCode.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,6 @@ const generateCode = (
245245
projectType: string,
246246
HTMLTypes: HTMLType[]
247247
) => {
248-
// console.log('components', components);
249-
// console.log('componentId', componentId);
250-
// console.log('rootComponents', rootComponents);
251-
// console.log('projectType', projectType);
252248
const code = generateUnformattedCode(
253249
components,
254250
componentId,

app/src/helperFunctions/projectGetSaveDel.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ if (isDev) {
66
// helper functions that will do fetch requests to get and save user/guest projects
77

88
export const getProjects = (): Promise<any> => {
9-
//console.log("Loading user's projects...");
109
let userId = window.localStorage.getItem('ssid');
1110
const body = JSON.stringify({ userId });
1211
const projects = fetch(`${serverURL}/getProjects`, {

app/src/reducers/componentReducer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ const reducer = (state: State, action: Action) => {
127127
}
128128

129129
const deleteComponentFromPages = (components, name) => {
130-
console.log('name', name);
131130
const searchNestedComps = (childComponents) => {
132131
console.log('child components', childComponents);
133132
// if (childComponents.length === 0) return console.log('empty children array');
@@ -163,7 +162,6 @@ const reducer = (state: State, action: Action) => {
163162
children: [],
164163
isPage: action.payload.root
165164
};
166-
console.log('new comp =>', newComponent);
167165
components.push(newComponent);
168166

169167
const rootComponents = [...state.rootComponents];
@@ -388,7 +386,6 @@ const reducer = (state: State, action: Action) => {
388386
case 'DELETE REUSABLE COMPONENT' : {
389387
const id: number = state.canvasFocus.componentId;
390388
const name: string = state.components[id - 1].name;
391-
console.log(name);
392389
const components: Component[] = deleteById(id);
393390
updateIds(components);
394391

@@ -476,9 +473,7 @@ const reducer = (state: State, action: Action) => {
476473
}
477474

478475
case 'OPEN PROJECT': {
479-
console.log("BEFORE: ", action.payload.HTMLTypes);
480476
convertToJSX(action.payload.HTMLTypes);
481-
console.log("AFTER: ", action.payload.HTMLTypes);
482477
return {
483478
...action.payload
484479
};

app/src/tree/TreeChart.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function TreeChart({ data }) {
3737
// transform hierarchical data
3838
const root = hierarchy(data[canvasId - 1]);
3939
const treeLayout = tree().size([height, width - 125]);
40-
//console.log(root);
4140

4241
// Returns a new link generator with horizontal display.
4342
// To visualize links in a tree diagram rooted on the left edge of the display

app/src/utils/createApplication.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const createDefaultCSS = (path, appName, components) => {
9898
components.forEach(comp => {
9999
data += compToCSS(comp);
100100
})
101-
101+
102102
window.api.writeFile(filePath, data, err => {
103103
if (err) {
104104
console.log('default.css error:', err.message);

app/src/utils/createNextApp.util.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Create all files necessary to run a next.js application
1+
// Create all files necessary to run a next.js application
22

33
import createNextFiles from './createNextFiles.util';
44
import { Component } from '../interfaces/Interfaces';
@@ -46,7 +46,7 @@ export const createPackage = (path, appName) => {
4646
"@types/react": "^16.9.41",
4747
"typescript": "^3.9.6"
4848
}
49-
}
49+
}
5050
`;
5151
window.api.writeFile(filePath, data, err => {
5252
if (err) {
@@ -110,7 +110,7 @@ export const initFolders = (path:string, appName: string) => {
110110

111111
//createBaseTsx
112112
export const createBaseTsx = (path, appName) => {
113-
113+
114114
const filePath:string = `${path}/${appName}/pages/_app.tsx`;
115115
const data:string = `
116116
import React from 'react';
@@ -123,7 +123,7 @@ export const createBaseTsx = (path, appName) => {
123123
</>
124124
)
125125
}
126-
126+
127127
export default Base;
128128
`;
129129
window.api.writeFile(filePath, data, err => {
@@ -147,13 +147,13 @@ async function createNextAppUtil({
147147
rootComponents: number[];
148148
}) {
149149
console.log('in the createNextApplication util');
150-
150+
151151
await initFolders(path, appName);
152152
await createBaseTsx(path, appName);
153153
await createDefaultCSS(path, appName, components);
154154
await createPackage(path, appName);
155155
await createTsConfig(path, appName);
156156
await createNextFiles(components, path, appName, rootComponents);
157-
157+
158158
}
159-
export default createNextAppUtil;
159+
export default createNextAppUtil;

0 commit comments

Comments
 (0)