Skip to content

Commit 797d30a

Browse files
authored
Merge pull request #5 from brianjshan/typescript
🔥 Working theme changer 🔥
2 parents 7718220 + 757c303 commit 797d30a

File tree

9 files changed

+113
-51
lines changed

9 files changed

+113
-51
lines changed

app/src/components/bottom/BottomPanel.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@ 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+
right: false,
15+
bottom: false,
16+
left: false,
17+
topRight: false,
18+
bottomRight: false,
19+
bottomLeft: false,
20+
topLeft: false
21+
}}
22+
// style={style}
23+
>
24+
<div className="bottom-panel">
25+
<BottomTabs />
26+
</div>
27+
</Resizable>
1328
);
1429
};
1530

app/src/components/bottom/BottomTabs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Tab from '@material-ui/core/Tab';
55
// import Tree from 'react-d3-tree';
66
import CodePreview from './CodePreview';
77
import Box from '@material-ui/core/Box';
8+
import { emitKeypressEvents } from 'readline';
89

910
const BottomTabs = () => {
1011
// state that controls which tab the user is on
Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,79 @@
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={{
35-
border: '2px solid #33eb91',
76+
// border: '2px solid #33eb91',
3677
borderRadius: '8px'
3778
}}
3879
// onChange={code =>
@@ -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: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,6 @@ const ComponentPanel = (): JSX.Element => {
101101
return state.canvasFocus.componentId === targetId ? true : false;
102102
};
103103

104-
const deleteReusableComponent = (id) => {
105-
// reducer to modify state.components
106-
// make sure the component is not a root
107-
//
108-
}
109-
110104
return (
111105
<div className={classes.panelWrapper}>
112106
{/* Add a new component*/}
@@ -159,14 +153,15 @@ const ComponentPanel = (): JSX.Element => {
159153
.map(comp => {
160154
//console.log('root comp', comp.name)
161155
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-
)})}
156+
<ComponentPanelItem
157+
isFocus={isFocus(comp.id)}
158+
key={`comp-${comp.id}`}
159+
name={comp.name}
160+
id={comp.id}
161+
root={true}
162+
/>
163+
);
164+
})}
170165
</Grid>
171166
{/* Display all reusable components */}
172167
<h4>Reusable components</h4>
@@ -177,14 +172,15 @@ const ComponentPanel = (): JSX.Element => {
177172
//console.log('all root comps', state.rootComponents);
178173
//console.log('all reusable comps', state.components);
179174
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-
)})}
175+
<ComponentPanelItem
176+
isFocus={isFocus(comp.id)}
177+
key={`comp-${comp.id}`}
178+
name={comp.name}
179+
id={comp.id}
180+
root={false}
181+
/>
182+
);
183+
})}
188184
</Grid>
189185
{/* Display navigation components - (only applies to next.js which has routing built in) */}
190186
{state.projectType === 'Next.js' ? (

app/src/components/main/Canvas.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function Canvas() {
4949
}
5050
// if item is not a new instance, change position of element dragged inside div so that the div is the new parent
5151
else {
52-
console.log('dispatch change position')
52+
console.log('dispatch change position');
5353
dispatch({
5454
type: 'CHANGE POSITION',
5555
payload: {

app/src/components/right/SimpleModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ const SimpleModal = (props: any) => {
4646
<Modal
4747
aria-labelledby="simple-modal-title"
4848
aria-describedby="simple-modal-description"
49-
onClose={closeModal}
5049
open={open}
50+
onClose={closeModal}
5151
>
5252
<div
5353
style={{

app/src/containers/MainContainer.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ class MainContainer extends Component {
88
render() {
99
return (
1010
<div className="main-container">
11-
<div
12-
className="main" //ref={main} **no function, commenting out**
13-
>
11+
<div className="main">
1412
<CanvasContainer />
1513
</div>
1614

app/src/public/styles/style.css

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ body {
1717
overflow: hidden;
1818
}
1919
/**************
20-
*
21-
* for Material React Table found in Add Child Props
20+
*
21+
* for Material React Table found in Add Child Props
2222
*
2323
***************/
2424

@@ -36,7 +36,7 @@ body {
3636
}
3737

3838
/*
39-
///////////////////////////////////////////
39+
///////////////////////////////////////////
4040
Remove focus styling
4141
/////////////////////////////////////////////
4242
*/
@@ -73,7 +73,7 @@ header {
7373
} */
7474

7575
/*
76-
///////////////////////////////////////////
76+
///////////////////////////////////////////
7777
BUTTONS
7878
/////////////////////////////////////////////
7979
*/
@@ -83,7 +83,7 @@ BUTTONS
8383
}
8484

8585
/*
86-
///////////////////////////////////////////
86+
///////////////////////////////////////////
8787
LEFT COLUMN
8888
/////////////////////////////////////////////
8989
*/
@@ -131,7 +131,7 @@ LEFT COLUMN
131131
}
132132

133133
/*
134-
///////////////////////////////////////////
134+
///////////////////////////////////////////
135135
MAIN COLUMN
136136
/////////////////////////////////////////////
137137
*/
@@ -214,8 +214,16 @@ h1 {
214214
text-align: center;
215215
}
216216

217+
.ace_scrollbar {
218+
display: none;
219+
}
220+
221+
.ace_print-margin {
222+
display: none;
223+
}
224+
217225
/*
218-
///////////////////////////////////////////
226+
///////////////////////////////////////////
219227
RIGHT COLUMN
220228
/////////////////////////////////////////////
221229
*/
@@ -233,13 +241,14 @@ RIGHT COLUMN
233241
.bottom-panel {
234242
transition: width 250ms ease-in-out;
235243
width: 100%;
236-
height: 33%;
237-
min-height: 260px;
244+
height: 100%;
245+
min-height: 500px;
238246
/* display: flex;
239247
flex-direction: row; */
240248
background-color: #fcfcfc;
241249
/* box-shadow: 0 -5px 7px 2px rgb(255, 0, 0); */
242-
margin-right: 100px;
250+
/* margin-right: 100px;
251+
padding-right: 10px; */
243252
}
244253

245254
.htmlattr {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@
118118
"immutable": "^4.0.0-rc.12",
119119
"js-cookie": "^2.2.1",
120120
"localforage": "^1.7.2",
121+
"node-fetch": "^2.6.0",
121122
"passport": "^0.4.1",
122123
"passport-github2": "^0.1.12",
123-
"node-fetch": "^2.6.0",
124124
"prettier": "^1.19.1",
125125
"prop-types": "^15.6.2",
126+
"re-resizable": "^6.7.0",
126127
"react": "^16.13.0",
127128
"react-ace": "^8.1.0",
128129
"react-dnd": "^11.1.3",

0 commit comments

Comments
 (0)