Skip to content

Commit 51fa427

Browse files
committed
Fixed errors that prevented app from rendering
1 parent 5e49f07 commit 51fa427

File tree

7 files changed

+401
-388
lines changed

7 files changed

+401
-388
lines changed

app/src/components/bottom/CodePreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useContext } from 'react';
22
import { stateContext } from '../../context/context';
3-
import { format } from 'prettier';
3+
// import { format } from 'prettier';
44
import AceEditor from 'react-ace';
55
import { makeStyles } from '@material-ui/core/styles';
66
import 'ace-builds/src-noconflict/mode-javascript';

app/src/containers/AppContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import RightContainer from './RightContainer';
66
import theme from '../theme';
77

88
// ** Used with electron to render
9-
const IPC = require('electron').ipcRenderer;
9+
// const IPC = require('electron').ipcRenderer;
1010

1111
class AppContainer extends Component {
1212
constructor(props) {

app/src/containers/LeftContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import createModal from '../components/left/createModal';
1717
import { stateContext } from '../context/context';
1818
import exportProject from '../utils/exportProject.util';
1919

20-
const IPC = require('electron').ipcRenderer;
20+
// const IPC = require('electron').ipcRenderer;
2121

2222
const useStyles = makeStyles({
2323
btnGroup: {

app/src/helperFunctions/generateCode.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { format } from 'prettier';
1+
// import { format } from 'prettier';
22
import { Component, State, ChildElement } from '../interfaces/InterfacesNew';
33
import HTMLTypes from '../context/HTMLTypes';
44

5-
6-
75
// generate code based on the component heirarchy
86
const generateUnformattedCode = (comps: Component[], componentId: number) => {
97
const components = [...comps];
@@ -45,25 +43,39 @@ const generateUnformattedCode = (comps: Component[], componentId: number) => {
4543
if (child.tag === 'img') {
4644
return `<${child.tag} src=""${formatStyles(child.style)} />`;
4745
} else if (child.tag === 'a') {
48-
return `<${child.tag} href=""${formatStyles(child.style)}>[LINK]</${child.tag}>`;
46+
return `<${child.tag} href=""${formatStyles(child.style)}>[LINK]</${
47+
child.tag
48+
}>`;
4949
} else if (child.tag === 'div') {
5050
return `<${child.tag}${formatStyles(
5151
child.style
5252
)}>${writeNestedElements(child.children)}</${child.tag}>`;
5353
} else if (child.tag === 'h1') {
54-
return `<${child.tag}${formatStyles(child.style)}>HEADER 1</${child.tag}>`;
54+
return `<${child.tag}${formatStyles(child.style)}>HEADER 1</${
55+
child.tag
56+
}>`;
5557
} else if (child.tag === 'h2') {
56-
return `<${child.tag}${formatStyles(child.style)}>HEADER 2</${child.tag}>`;
58+
return `<${child.tag}${formatStyles(child.style)}>HEADER 2</${
59+
child.tag
60+
}>`;
5761
} else if (child.tag === 'form') {
58-
return `<${child.tag}${formatStyles(child.style)}>FORM</${child.tag}>`;
62+
return `<${child.tag}${formatStyles(child.style)}>FORM</${
63+
child.tag
64+
}>`;
5965
} else if (child.tag === 'p') {
60-
return `<${child.tag}${formatStyles(child.style)}>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</${child.tag}>`;
66+
return `<${child.tag}${formatStyles(
67+
child.style
68+
)}>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</${
69+
child.tag
70+
}>`;
6171
} else if (child.tag === 'li') {
6272
return `<ul${formatStyles(child.style)}><li>item 1</li>
6373
<li>item 2</li>
6474
<li>item 3</li></ul>`;
65-
} else if (child.tag === 'button'){
66-
return `<${child.tag}${formatStyles(child.style)}>BUTTON</${child.tag}>`;
75+
} else if (child.tag === 'button') {
76+
return `<${child.tag}${formatStyles(child.style)}>BUTTON</${
77+
child.tag
78+
}>`;
6779
} else {
6880
return `<${child.tag}${formatStyles(child.style)}></${child.tag}>`;
6981
}
@@ -135,13 +147,14 @@ const generateUnformattedCode = (comps: Component[], componentId: number) => {
135147

136148
// formats code with prettier linter
137149
const formatCode = (code: string) => {
138-
return format(code, {
139-
singleQuote: true,
140-
trailingComma: 'es5',
141-
bracketSpacing: true,
142-
jsxBracketSameLine: true,
143-
parser: 'babel'
144-
});
150+
return code;
151+
// return format(code, {
152+
// singleQuote: true,
153+
// trailingComma: 'es5',
154+
// bracketSpacing: true,
155+
// jsxBracketSameLine: true,
156+
// parser: 'babel'
157+
// });
145158
};
146159

147160
// generate code based on component heirarchy and then return the rendered code
@@ -151,4 +164,3 @@ const generateCode = (components: Component[], componentId: number) => {
151164
};
152165

153166
export default generateCode;
154-

app/src/public/index.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
/> -->
1919
<!-- Removed this option from original CSP () -->
2020
<title>ReacType</title>
21-
<!-- <link
21+
<link
2222
rel="stylesheet"
2323
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
2424
/>
2525
<link
2626
rel="stylesheet"
2727
href="https://fonts.googleapis.com/icon?family=Material+Icons"
28-
/> -->
28+
/>
2929
</head>
3030

3131
<body>

0 commit comments

Comments
 (0)