Skip to content

Commit 9aa1b9f

Browse files
Merge pull request #12 from brianjshan/theme-changer
🔥👍👊 moved theme changer button & css on html element adding section
2 parents 2b9b121 + c8e6569 commit 9aa1b9f

File tree

13 files changed

+176
-145
lines changed

13 files changed

+176
-145
lines changed

app/src/components/bottom/BottomPanel.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useContext } from 'react';
22
import { stateContext } from '../../context/context';
33
import BottomTabs from './BottomTabs';
4-
// import BottomTabs from './BottomTabs';
54
import { Resizable } from 're-resizable';
65

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

app/src/components/bottom/BottomTabs.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ const BottomTabs = () => {
7171
</FormControl>
7272
</Box>
7373
{tab === 0 && <CodePreview theme={theme} setTheme={setTheme} />}
74-
{tab === 1 && (
75-
<Tree theme={theme} setTheme={setTheme} data={components} />
76-
)}
74+
{tab === 1 && <Tree data={components} />}
7775
</div>
7876
);
7977
};

app/src/components/bottom/CodePreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Component } from '../../interfaces/Interfaces';
2020
// }
2121
// }));
2222

23-
const optionColor = '#252526';
23+
// const optionColor = '#252526';
2424

2525
const CodePreview = ({ theme, setTheme }) => {
2626
const [state, dispatch] = useContext(stateContext);

app/src/components/left/ComponentPanel.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ 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)
165166
return (
166167
<ComponentPanelItem
167168
isFocus={isFocus(comp.id)}
@@ -179,6 +180,8 @@ const ComponentPanel = (): JSX.Element => {
179180
{state.components
180181
.filter(comp => !state.rootComponents.includes(comp.id))
181182
.map(comp => {
183+
//console.log('all root comps', state.rootComponents);
184+
//console.log('all reusable comps', state.components);
182185
return (
183186
<ComponentPanelItem
184187
isFocus={isFocus(comp.id)}
@@ -211,7 +214,7 @@ const ComponentPanel = (): JSX.Element => {
211214
);
212215
};
213216

214-
export const useStyles = makeStyles({
217+
const useStyles = makeStyles({
215218
inputField: {
216219
marginTop: '15px'
217220
},
@@ -274,7 +277,7 @@ export const useStyles = makeStyles({
274277
button: {
275278
fontSize: '1rem',
276279
height: '40px',
277-
marginTop: '10px',
280+
maginTop: '10px',
278281
width: '100%',
279282
// border: '1px solid rgba(70,131,83)',
280283
backgroundColor: 'rgba(1,212,109,0.1)'

app/src/components/left/HTMLPanel.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const HTMLPanel = (): JSX.Element => {
1414
const [errorMsg, setErrorMsg] = useState('');
1515
const [errorStatus, setErrorStatus] = useState(false);
1616

17-
const buttonClasses = "MuiButtonBase-root MuiButton-root MuiButton-text makeStyles-button-12 MuiButton-textPrimary";
17+
const buttonClasses =
18+
'MuiButtonBase-root MuiButton-root MuiButton-text makeStyles-button-12 MuiButton-textPrimary';
1819

1920
const handleTagChange = (e: React.ChangeEvent<HTMLInputElement>) => {
2021
resetError();
@@ -125,9 +126,11 @@ const HTMLPanel = (): JSX.Element => {
125126
value={tag}
126127
onChange={handleTagChange}
127128
className={classes.input}
129+
style={{ marginBottom: '10px' }}
128130
/>
129131
{errorStatus && <span>{errorMsg}</span>}
130132
</label>
133+
<br></br>
131134
<label className={classes.inputLabel}>
132135
Tag Name:
133136
<input
@@ -140,7 +143,13 @@ const HTMLPanel = (): JSX.Element => {
140143
/>
141144
{errorStatus && <span>{errorMsg}</span>}
142145
</label>
143-
<input className={buttonClasses} color="primary" type="submit" value="Add Element" style={{marginTop:'15px'}}/>
146+
<input
147+
className={buttonClasses}
148+
color="primary"
149+
type="submit"
150+
value="Add Element"
151+
style={{ marginTop: '15px' }}
152+
/>
144153
</form>
145154
</div>
146155
</div>
@@ -210,10 +219,11 @@ const useStyles = makeStyles({
210219
overflowX: 'hidden',
211220
textOverflow: 'ellipsis',
212221
border: '1px solid rgba(51,235,145,0.75)',
213-
backgroundColor: 'rgba(255,255,255,0.15)'
222+
backgroundColor: 'rgba(255,255,255,0.15)',
223+
marginLeft: '10px'
214224
},
215225
inputLabel: {
216-
fontSize: '14px',
226+
fontSize: '16px',
217227
zIndex: 20,
218228
color: '#fff',
219229
marginTop: '-10px'

app/src/components/right/ProjectManager.tsx

Lines changed: 71 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,19 @@ import LoginButton from './LoginButton';
2121
import SaveProjectButton from './SaveProjectButton';
2222
import DeleteProjects from './DeleteProjects';
2323

24+
// import { useStyles } from '../left/ComponentPanel';
25+
import { styleContext } from '../../containers/AppContainer';
26+
2427
const ProjectManager = () => {
2528
// state to keep track of whether a modal should display
2629
const [modal, setModal] = useState(null);
2730
const [state, dispatch] = useContext(stateContext);
2831

2932
const classes = useStyles();
3033

34+
const { style, setStyle } = useContext(styleContext);
35+
// console.log('style: ', style);
36+
3137
// Allows users to toggle project between "next.js" and "Classic React"
3238
// When a user changes the project type, the code of all components is rerendered
3339
const handleProjectChange = event => {
@@ -156,62 +162,76 @@ const ProjectManager = () => {
156162
};
157163

158164
return (
159-
// <div className={classes.logoutButton}>
160-
<div className={classes.projectManagerWrapper}>
161-
{state.name && state.isLoggedIn ? (
162-
<p style={{ color: 'white' }}>
163-
Your current project is <strong>{state.name}</strong>
164-
</p>
165-
) : null}
166-
{!state.name && state.isLoggedIn ? (
167-
<p style={{ color: 'white' }}>
168-
Select "Save project as" to create and save a project
169-
</p>
170-
) : null}
171-
172-
<div className={classes.projectTypeWrapper}>
173-
<FormControl>
174-
<Select
175-
variant="outlined"
176-
labelId="project-type-label"
177-
id="demo-simple-select"
178-
className={classes.projectSelector}
179-
value={state.projectType}
180-
onChange={handleProjectChange}
181-
>
182-
<MenuItem value={'Next.js'}>Next.js</MenuItem>
183-
<MenuItem value={'Classic React'}>Classic React</MenuItem>
184-
</Select>
185-
</FormControl>
186-
</div>
187-
{state.isLoggedIn ? <SaveProjectButton /> : ''}
188-
{state.isLoggedIn ? <ProjectsFolder /> : ''}
189-
{state.isLoggedIn ? <DeleteProjects /> : ''}
190-
{/* <div className={classes.btnGroup}> */}
165+
<div>
191166
<Button
192-
className={classes.button}
193-
variant="outlined"
194167
color="primary"
195-
onClick={showGenerateAppModal}
196-
endIcon={<PublishIcon />}
197-
>
198-
EXPORT PROJECT
199-
</Button>
200-
201-
<Button
168+
style={{ marginLeft: '15%' }}
202169
className={classes.button}
203-
variant="outlined"
204-
color="primary"
205-
onClick={clearWorkspace}
206-
endIcon={<WarningIcon />}
170+
onClick={() => {
171+
!style.backgroundColor
172+
? setStyle({ backgroundColor: '#00001a', color: 'red' })
173+
: setStyle({});
174+
}}
207175
>
208-
CLEAR WORKSPACE
176+
Change Darkness Mode
209177
</Button>
210-
<br />
211-
<br />
212-
<LoginButton />
213-
{/* </div> */}
214-
{modal}
178+
179+
<div className={classes.projectManagerWrapper}>
180+
{state.name && state.isLoggedIn ? (
181+
<p style={{ color: 'white' }}>
182+
Your current project is <strong>{state.name}</strong>
183+
</p>
184+
) : null}
185+
{!state.name && state.isLoggedIn ? (
186+
<p style={{ color: 'white' }}>
187+
Select "Save project as" to create and save a project
188+
</p>
189+
) : null}
190+
191+
<div className={classes.projectTypeWrapper}>
192+
<FormControl>
193+
<Select
194+
variant="outlined"
195+
labelId="project-type-label"
196+
id="demo-simple-select"
197+
className={classes.projectSelector}
198+
value={state.projectType}
199+
onChange={handleProjectChange}
200+
>
201+
<MenuItem value={'Next.js'}>Next.js</MenuItem>
202+
<MenuItem value={'Classic React'}>Classic React</MenuItem>
203+
</Select>
204+
</FormControl>
205+
</div>
206+
{state.isLoggedIn ? <SaveProjectButton /> : ''}
207+
{state.isLoggedIn ? <ProjectsFolder /> : ''}
208+
{state.isLoggedIn ? <DeleteProjects /> : ''}
209+
{/* <div className={classes.btnGroup}> */}
210+
<Button
211+
className={classes.button}
212+
variant="outlined"
213+
color="primary"
214+
onClick={showGenerateAppModal}
215+
endIcon={<PublishIcon />}
216+
>
217+
EXPORT PROJECT
218+
</Button>
219+
220+
<Button
221+
className={classes.button}
222+
variant="outlined"
223+
color="primary"
224+
onClick={clearWorkspace}
225+
endIcon={<WarningIcon />}
226+
>
227+
CLEAR WORKSPACE
228+
</Button>
229+
<br />
230+
<br />
231+
<LoginButton />
232+
{/* </div> */}
233+
{modal}
234+
</div>
215235
</div>
216236
);
217237
};

app/src/containers/AppContainer.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useContext, createContext } from 'react';
22
import { MuiThemeProvider } from '@material-ui/core/styles';
3-
import Button from '@material-ui/core/Button';
3+
// import Button from '@material-ui/core/Button';
44
import LeftContainer from './LeftContainer';
55
import MainContainer from './MainContainer';
66
import RightContainer from './RightContainer';
7-
import { theme1, theme2 } from '../public/styles/theme';
7+
import { theme1 } from '../public/styles/theme';
88
import { makeStyles } from '@material-ui/core/styles';
9-
import { useStyles } from '../components/left/ComponentPanel';
9+
10+
export const styleContext = createContext({});
11+
// console.log('styleContext: ', styleContext);
1012

1113
const AppContainer = () => {
1214
const [theme, setTheme] = useState(theme1);
13-
const classes = useStyles();
14-
const [style, setStyle] = useState({});
15+
const initialStyle = useContext(styleContext);
16+
const [style, setStyle] = useState(initialStyle);
1517

1618
return (
1719
// Mui theme provider provides themed styling to all MUI components in app
1820
<MuiThemeProvider theme={theme}>
19-
<Button
20-
color="primary"
21-
className={classes.button}
22-
onClick={() => (!style.backgroundColor ? setStyle({}) : setStyle({}))}
23-
>
24-
Change to Light/Dark Mode
25-
</Button>
2621
<div className="app-container">
27-
<LeftContainer style={style} />
28-
<MainContainer />
29-
<RightContainer />
22+
<styleContext.Provider value={{ style, setStyle }}>
23+
<LeftContainer style={style} />
24+
<MainContainer style={style} />
25+
<RightContainer style={style} />
26+
</styleContext.Provider>
3027
</div>
3128
</MuiThemeProvider>
3229
);

app/src/containers/LeftContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import HTMLPanel from '../components/left/HTMLPanel';
88
// Left-hand portion of the app, where component options are displayed
99
const LeftContainer = ({ style }): JSX.Element => {
1010
return (
11-
<div style={style} className="column left">
11+
<div className="column left" style={style}>
1212
<Grid container direction="row" alignItems="center">
1313
<ComponentPanel />
1414
<HTMLPanel />

app/src/containers/MainContainer.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,15 @@ import React, { Component } from 'react';
22
import BottomPanel from '../components/bottom/BottomPanel';
33
import CanvasContainer from '../components/main/CanvasContainer';
44

5-
import { Resizable } from "re-resizable";
6-
7-
class MainContainer extends Component {
8-
render() {
9-
return (
10-
<div className="main-container">
11-
<div className="main">
12-
<CanvasContainer />
13-
</div>
14-
{/* <Resizable minHeight={'25%'} enable={{ top: true }}> */}
15-
<BottomPanel />
16-
{/* </Resizable> */}
5+
const MainContainer = ({ style }) => {
6+
return (
7+
<div className="main-container" style={style}>
8+
<div className="main">
9+
<CanvasContainer />
10+
</div>
11+
<BottomPanel />
1712
</div>
18-
);
19-
}
20-
}
13+
);
14+
};
2115

2216
export default MainContainer;

0 commit comments

Comments
 (0)