Skip to content

Commit 310b85d

Browse files
authored
Merge pull request #30 from jinsoolim/tutorial
tutorial finished and console logs cleaned up
2 parents 22328e8 + 324f346 commit 310b85d

37 files changed

+216
-306
lines changed

app/electron/main.js

Lines changed: 16 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
@@ -226,6 +226,7 @@ app.on('web-contents-created', (event, contents) => {
226226
'https://reactype.herokuapp.com',
227227
'https://github.com/',
228228
'https://nextjs.org',
229+
'https://developer.mozilla.org'
229230
];
230231
console.log('parsed URL origin', parsedUrl.origin);
231232
// Log and prevent the app from navigating to a new page if that page's origin is not whitelisted
@@ -247,6 +248,7 @@ app.on('web-contents-created', (event, contents) => {
247248
'https://reactype.herokuapp.com',
248249
'https://github.com/',
249250
'https://nextjs.org',
251+
'https://developer.mozilla.org'
250252
];
251253

252254
// Log and prevent the app from redirecting to a new page
@@ -260,12 +262,12 @@ app.on('web-contents-created', (event, contents) => {
260262

261263
event.preventDefault();
262264
return;
263-
} else console.log('Succesful link sent to browser');
265+
} else console.log('Successful link sent to browser');
264266
});
265267

266268
// https://electronjs.org/docs/tutorial/security#11-verify-webview-options-before-creation
267269
// The web-view is used to embed guest content in a page
268-
// 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
269271
// https://www.electronjs.org/docs/api/web-contents#event-will-attach-webview
270272
contents.on('will-attach-webview', (event, webPreferences, params) => {
271273
// Strip away preload scripts if unused or verify their location is legitimate
@@ -286,6 +288,7 @@ app.on('web-contents-created', (event, contents) => {
286288
'https://reactype.herokuapp.com',
287289
'https://github.com/',
288290
'https://nextjs.org',
291+
'https://developer.mozilla.org'
289292
];
290293
console.log('parsed URL origin', parsedUrl.origin);
291294
// Log and prevent the app from navigating to a new page if that page's origin is not whitelisted
@@ -377,15 +380,15 @@ ipcMain.on('delete_cookie', event => {
377380
.catch(err => console.log('Error deleting cookie:', err));
378381
});
379382

380-
// 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
381384
ipcMain.on('github', event => {
382385
// your github applications credentials
383386
const options = {
384387
client_id: 'your_client_id',
385388
client_secret: 'your_client_secret',
386389
scopes: ['user:email', 'notifications']
387390
};
388-
// create new browserwindow object with size, title, security options
391+
// create new browser window object with size, title, security options
389392
const github = new BrowserWindow({
390393
width: 800,
391394
height: 600,
@@ -425,7 +428,7 @@ ipcMain.on('github', event => {
425428
});
426429

427430
ipcMain.on('tutorial', event => {
428-
// create new browserwindow object with size, title, security options
431+
// create new browser window object with size, title, security options
429432
const tutorial = new BrowserWindow({
430433
width: 800,
431434
height: 600,

app/electron/menu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ var MenuBuilder = function(mainWindow, appName) {
1616

1717
const openTutorial = () => {
1818
const tutorial = new BrowserWindow({
19-
width: 1224,
20-
height: 1024,
19+
width: 800,
20+
height: 900,
2121
minWidth: 661,
2222
title: 'Tutorial',
2323
webPreferences: {

app/src/components/bottom/CodePreview.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useContext, useState, useRef, useEffect } from 'react';
22
import { StateContext } from '../../context/context';
33
import AceEditor from 'react-ace';
4-
import { makeStyles } from '@material-ui/core/styles';
54
import 'ace-builds/src-noconflict/mode-javascript';
65
import 'ace-builds/src-noconflict/theme-monokai';
76
import 'ace-builds/src-noconflict/theme-github';
@@ -13,14 +12,12 @@ import useResizeObserver from '../../tree/useResizeObserver';
1312

1413
const CodePreview = ({ theme, setTheme }) => {
1514
const wrapper = useRef();
16-
//console.log(wrapper.current);
1715
const dimensions = useResizeObserver(wrapper);
1816
const { width, height } =
1917
dimensions || 0;
2018

2119
const [state, dispatch] = useContext(StateContext);
2220
const [divHeight, setDivHeight] = useState(0);
23-
// const classes = useStyles();
2421
const currentComponent = state.components.find(
2522
(elem: Component) => elem.id === state.canvasFocus.componentId
2623
);
@@ -35,7 +32,6 @@ const CodePreview = ({ theme, setTheme }) => {
3532

3633
useEffect(() => {
3734
setDivHeight(height);
38-
//console.log(divHeight);
3935
}, [height])
4036

4137
return (
@@ -47,7 +43,6 @@ const CodePreview = ({ theme, setTheme }) => {
4743
justifyContent: 'center'
4844
}}
4945
>
50-
{/* <h1>{divHeight}</h1> */}
5146
<AceEditor
5247
mode="javascript"
5348
theme={theme}
@@ -57,16 +52,9 @@ const CodePreview = ({ theme, setTheme }) => {
5752
border: '2px solid #33eb91',
5853
borderRadius: '8px'
5954
}}
60-
// onChange={code =>
61-
// this.props.updateCode({
62-
// componentId: this.props.focusComponent.id,
63-
// code
64-
// })
65-
// }
6655
onChange={handleCodeSnipChange}
6756
value={currentComponent.code}
6857
name="Code_div"
69-
// readOnly={this.props.codeReadOnly}
7058
readOnly={false}
7159
editorProps={{ $blockScrolling: true }}
7260
fontSize={16}
@@ -76,6 +64,4 @@ const CodePreview = ({ theme, setTheme }) => {
7664
);
7765
};
7866

79-
// const useStyles = makeStyles(theme => ({}));
80-
8167
export default CodePreview;

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/HTMLItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ const HTMLItem: React.FC<{
6161
>
6262
{Icon && <Icon />}
6363
</span>
64-
<button className={buttonClasses} onClick={() => { handleDelete(id) }} > X </button>
64+
{id > 11 &&
65+
<button className={buttonClasses} onClick={() => { handleDelete(id) }} > X </button> }
6566
</div>
6667
</Grid>
6768
);

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/context/HTMLTypes.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ const HTMLTypes: HTMLType[] = [
9797
placeHolderShort: 'Header 2',
9898
placeHolderLong: '',
9999
icon: HeaderIcon
100+
},
101+
{
102+
id: 5,
103+
tag: 'span',
104+
name: 'Span',
105+
style: { fontSize: '1.5em' },
106+
placeHolderShort: 'Span',
107+
placeHolderLong: '',
108+
icon: HeaderIcon
100109
}
101110
];
102111

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/public/styles/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ RIGHT COLUMN
248248
transition: width 250ms ease-in-out;
249249
width: 100%;
250250
height: 100%;
251-
min-height: 100%;
251+
min-height: 500px;
252252
/* display: flex; */
253253
/* flex-direction: row; */
254254
background-color: #fcfcfc;

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
};

0 commit comments

Comments
 (0)