Skip to content

Commit 24d0044

Browse files
merging
2 parents eeae75d + 8d330d1 commit 24d0044

File tree

15 files changed

+298
-90
lines changed

15 files changed

+298
-90
lines changed

app/src/components/bottom/BottomPanel.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@ import React, { useContext } from 'react';
22
import { stateContext } from '../../context/context';
33
import BottomTabs from './BottomTabs';
44
// import BottomTabs from './BottomTabs';
5+
import { Resizable } from 're-resizable';
56

67
// const IPC = require('electron').ipcRenderer;
78

89
const BottomPanel = () => {
910
return (
10-
<div className="bottom-panel" style={{ width: '100%' }}>
11-
<BottomTabs />
12-
</div>
11+
<Resizable
12+
enable={{
13+
top: true,
14+
}}
15+
>
16+
<div className="bottom-panel">
17+
<BottomTabs />
18+
</div>
19+
</Resizable>
1320
);
1421
};
1522

16-
export default BottomPanel;
23+
export default BottomPanel;

app/src/components/bottom/BottomTabs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Tab from '@material-ui/core/Tab';
77
import CodePreview from './CodePreview';
88
import Box from '@material-ui/core/Box';
99
import Tree from '../../tree/TreeChart';
10+
import { emitKeypressEvents } from 'readline';
1011

1112
const BottomTabs = () => {
1213
// state that controls which tab the user is on
Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,75 @@
1-
import React, { useContext } from 'react';
1+
import React, { useContext, useState } from 'react';
22
import { stateContext } from '../../context/context';
33
import AceEditor from 'react-ace';
44
import { makeStyles } from '@material-ui/core/styles';
55
import 'ace-builds/src-noconflict/mode-javascript';
66
import 'ace-builds/src-noconflict/theme-monokai';
7-
import Button from '@material-ui/core/Button';
7+
import 'ace-builds/src-noconflict/theme-github';
8+
import 'ace-builds/src-noconflict/theme-solarized_dark';
9+
import 'ace-builds/src-noconflict/theme-solarized_light';
10+
import 'ace-builds/src-noconflict/theme-terminal';
811
import { Component } from '../../interfaces/Interfaces';
12+
import NativeSelect from '@material-ui/core/NativeSelect';
13+
import FormControl from '@material-ui/core/FormControl';
14+
15+
const useStyles = makeStyles(theme => ({
16+
formControl: {
17+
margin: theme.spacing(1),
18+
minWidth: 120
19+
},
20+
selectEmpty: {
21+
marginTop: theme.spacing(2)
22+
}
23+
}));
924

1025
const CodePreview = () => {
1126
const [state, dispatch] = useContext(stateContext);
27+
const [theme, setTheme] = useState('monokai');
28+
const classes = useStyles();
1229
const currentComponent = state.components.find(
1330
(elem: Component) => elem.id === state.canvasFocus.componentId
1431
);
1532

33+
const handleCodeSnipChange = val => {
34+
currentComponent.code = val;
35+
};
36+
37+
const changeTheme = e => {
38+
setTheme(e.target.value);
39+
};
40+
1641
return (
1742
<div
1843
style={{
1944
height: '90%',
2045
paddingLeft: '0px',
21-
paddingTop: '1rem',
22-
paddingBottom: '1rem',
23-
overflow: 'auto',
46+
// paddingTop: '1rem',
47+
// paddingBottom: '1rem',
48+
// overflow: 'auto',
2449
maxWidth: '100%',
25-
display: 'flex',
50+
// display: 'flex',
2651
justifyContent: 'center'
2752
}}
2853
>
54+
<FormControl fullWidth={true} className={classes.formControl}>
55+
{/* <InputLabel variant="filled" style={{ color: 'white' }}>
56+
Change Theme
57+
</InputLabel> */}
58+
<NativeSelect
59+
style={{ color: 'white' }}
60+
value={theme}
61+
onChange={changeTheme}
62+
>
63+
<option value={'monokai'}>Monokai</option>
64+
<option value={'github'}>Github</option>
65+
<option value={'solarized_dark'}>Solarized Dark</option>
66+
<option value={'terminal'}>Terminal</option>
67+
<option value={'solarized_light'}>Solarized Light</option>
68+
</NativeSelect>
69+
</FormControl>
2970
<AceEditor
3071
mode="javascript"
31-
theme="monokai"
72+
theme={theme}
3273
width="100%"
3374
height="100%"
3475
style={{
@@ -41,10 +82,11 @@ const CodePreview = () => {
4182
// code
4283
// })
4384
// }
85+
onChange={handleCodeSnipChange}
4486
value={currentComponent.code}
4587
name="Code_div"
4688
// readOnly={this.props.codeReadOnly}
47-
readOnly={true}
89+
readOnly={false}
4890
editorProps={{ $blockScrolling: true }}
4991
fontSize={16}
5092
tabSize={2}
@@ -53,6 +95,6 @@ const CodePreview = () => {
5395
);
5496
};
5597

56-
const useStyles = makeStyles(theme => ({}));
98+
// const useStyles = makeStyles(theme => ({}));
5799

58100
export default CodePreview;

app/src/components/left/ComponentPanel.tsx

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const ComponentPanel = (): JSX.Element => {
3232
setErrorMsg('Component name already exists.');
3333
} else if (type === 'letters') {
3434
setErrorMsg('Component name must start with a letter.');
35+
} else if (type === 'symbolsDetected') {
36+
setErrorMsg('Component name must not contain symbols.');
3537
}
3638
};
3739

@@ -66,7 +68,7 @@ const ComponentPanel = (): JSX.Element => {
6668

6769
// Add a new component
6870
const createOption = (inputName: String) => {
69-
// format name so first letter is capitalized and there are no whitespaces
71+
// format name so first letter is capitalized and there are no white spaces
7072
let inputNameClean = inputName.replace(/\s+/g, '');
7173
const formattedName =
7274
inputNameClean.charAt(0).toUpperCase() + inputNameClean.slice(1);
@@ -81,11 +83,20 @@ const ComponentPanel = (): JSX.Element => {
8183
setCompName('');
8284
};
8385

86+
const alphanumeric = input => {
87+
let letterNumber = /^[0-9a-zA-Z]+$/;
88+
if (input.match(letterNumber)) return true;
89+
return false;
90+
}
91+
8492
const handleNameSubmit = () => {
8593
let letters = /[a-zA-Z]/;
8694
if (!compName.charAt(0).match(letters)) {
8795
triggerError('letters');
8896
return;
97+
} else if (!alphanumeric(compName)) {
98+
triggerError('symbolsDetected');
99+
return;
89100
} else if (compName.trim() === '') {
90101
triggerError('empty');
91102
return;
@@ -101,12 +112,6 @@ const ComponentPanel = (): JSX.Element => {
101112
return state.canvasFocus.componentId === targetId ? true : false;
102113
};
103114

104-
const deleteReusableComponent = (id) => {
105-
// reducer to modify state.components
106-
// make sure the component is not a root
107-
//
108-
}
109-
110115
return (
111116
<div className={classes.panelWrapper}>
112117
{/* Add a new component*/}
@@ -159,14 +164,15 @@ const ComponentPanel = (): JSX.Element => {
159164
.map(comp => {
160165
//console.log('root comp', comp.name)
161166
return (
162-
<ComponentPanelItem
163-
isFocus={isFocus(comp.id)}
164-
key={`comp-${comp.id}`}
165-
name={comp.name}
166-
id={comp.id}
167-
root={true}
168-
/>
169-
)})}
167+
<ComponentPanelItem
168+
isFocus={isFocus(comp.id)}
169+
key={`comp-${comp.id}`}
170+
name={comp.name}
171+
id={comp.id}
172+
root={true}
173+
/>
174+
);
175+
})}
170176
</Grid>
171177
{/* Display all reusable components */}
172178
<h4>Reusable components</h4>
@@ -177,14 +183,15 @@ const ComponentPanel = (): JSX.Element => {
177183
//console.log('all root comps', state.rootComponents);
178184
//console.log('all reusable comps', state.components);
179185
return (
180-
<ComponentPanelItem
181-
isFocus={isFocus(comp.id)}
182-
key={`comp-${comp.id}`}
183-
name={comp.name}
184-
id={comp.id}
185-
root={false}
186-
/>
187-
)})}
186+
<ComponentPanelItem
187+
isFocus={isFocus(comp.id)}
188+
key={`comp-${comp.id}`}
189+
name={comp.name}
190+
id={comp.id}
191+
root={false}
192+
/>
193+
);
194+
})}
188195
</Grid>
189196
{/* Display navigation components - (only applies to next.js which has routing built in) */}
190197
{state.projectType === 'Next.js' ? (

0 commit comments

Comments
 (0)