Skip to content

Commit 146b9f8

Browse files
committed
🔥Not fully working light to dark mode button🔥
1 parent 6ff29e7 commit 146b9f8

File tree

9 files changed

+126
-107
lines changed

9 files changed

+126
-107
lines changed

app/src/components/bottom/BottomTabs.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ import { makeStyles } from '@material-ui/core/styles';
33
import { stateContext } from '../../context/context';
44
import Tabs from '@material-ui/core/Tabs';
55
import Tab from '@material-ui/core/Tab';
6-
// import Tree from 'react-d3-tree';
76
import CodePreview from './CodePreview';
87
import Box from '@material-ui/core/Box';
98
import Tree from '../../tree/TreeChart';
109
import { emitKeypressEvents } from 'readline';
11-
import 'ace-builds/src-noconflict/theme-monokai';
10+
import NativeSelect from '@material-ui/core/NativeSelect';
11+
import FormControl from '@material-ui/core/FormControl';
1212

1313
const BottomTabs = () => {
1414
// state that controls which tab the user is on
1515
const [state, dispatch] = useContext(stateContext);
1616
const [tab, setTab] = useState(0);
1717
const classes = useStyles();
1818
treeWrapper: HTMLDivElement;
19-
2019
const [theme, setTheme] = useState('monokai');
21-
// console.log('theme:', theme);
2220

2321
// method changes the
2422
const handleChange = (event: React.ChangeEvent, value: number) => {
@@ -28,6 +26,10 @@ const BottomTabs = () => {
2826
const { HTMLTypes } = state;
2927
const { components } = state;
3028

29+
const changeTheme = e => {
30+
setTheme(e.target.value);
31+
};
32+
3133
return (
3234
<div className={classes.root}>
3335
<Box display="flex" justifyContent="space-between">
@@ -50,9 +52,28 @@ const BottomTabs = () => {
5052
label="Component Tree"
5153
/>
5254
</Tabs>
55+
<FormControl>
56+
<div className="flex-container">
57+
<div className="flex1">Change Theme:</div>
58+
<NativeSelect
59+
className="flex2"
60+
style={{ color: 'white' }}
61+
value={theme}
62+
onChange={changeTheme}
63+
>
64+
<option value={'monokai'}>Monokai</option>
65+
<option value={'github'}>Github</option>
66+
<option value={'solarized_dark'}>Solarized Dark</option>
67+
<option value={'terminal'}>Terminal</option>
68+
<option value={'solarized_light'}>Solarized Light</option>
69+
</NativeSelect>
70+
</div>
71+
</FormControl>
5372
</Box>
5473
{tab === 0 && <CodePreview theme={theme} setTheme={setTheme} />}
55-
{tab === 1 && <Tree data={components} />}
74+
{tab === 1 && (
75+
<Tree theme={theme} setTheme={setTheme} data={components} />
76+
)}
5677
</div>
5778
);
5879
};

app/src/components/bottom/CodePreview.tsx

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,22 @@ import 'ace-builds/src-noconflict/theme-solarized_dark';
99
import 'ace-builds/src-noconflict/theme-solarized_light';
1010
import 'ace-builds/src-noconflict/theme-terminal';
1111
import { Component } from '../../interfaces/Interfaces';
12-
import NativeSelect from '@material-ui/core/NativeSelect';
13-
import FormControl from '@material-ui/core/FormControl';
14-
import InputLabel from '@material-ui/core/InputLabel';
1512

16-
const useStyles = makeStyles(theme => ({
17-
formControl: {
18-
margin: theme.spacing(1),
19-
minWidth: 120
20-
},
21-
selectEmpty: {
22-
marginTop: theme.spacing(2)
23-
}
24-
}));
13+
// const useStyles = makeStyles(theme => ({
14+
// formControl: {
15+
// margin: theme.spacing(1),
16+
// minWidth: 120
17+
// },
18+
// selectEmpty: {
19+
// marginTop: theme.spacing(2)
20+
// }
21+
// }));
2522

2623
const optionColor = '#252526';
2724

2825
const CodePreview = ({ theme, setTheme }) => {
2926
const [state, dispatch] = useContext(stateContext);
30-
// const [theme, setTheme] = useState('monokai');
31-
const classes = useStyles();
27+
// const classes = useStyles();
3228
const currentComponent = state.components.find(
3329
(elem: Component) => elem.id === state.canvasFocus.componentId
3430
);
@@ -45,31 +41,10 @@ const CodePreview = ({ theme, setTheme }) => {
4541
<div
4642
style={{
4743
height: '90%',
48-
paddingLeft: '0px',
49-
paddingBottom: '8%',
50-
// overflow: 'auto',
5144
maxWidth: '100%',
52-
// display: 'flex',
5345
justifyContent: 'center'
5446
}}
5547
>
56-
<FormControl className={classes.formControl}>
57-
<div className="flex-container">
58-
<div className="flex1">Change Theme:</div>
59-
<NativeSelect
60-
className="flex2"
61-
style={{ color: 'white' }}
62-
value={theme}
63-
onChange={changeTheme}
64-
>
65-
<option value={'monokai'}>Monokai</option>
66-
<option value={'github'}>Github</option>
67-
<option value={'solarized_dark'}>Solarized Dark</option>
68-
<option value={'terminal'}>Terminal</option>
69-
<option value={'solarized_light'}>Solarized Light</option>
70-
</NativeSelect>
71-
</div>
72-
</FormControl>
7348
<AceEditor
7449
mode="javascript"
7550
theme={theme}

app/src/components/left/ComponentPanel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const ComponentPanel = (): JSX.Element => {
8787
let letterNumber = /^[0-9a-zA-Z]+$/;
8888
if (input.match(letterNumber)) return true;
8989
return false;
90-
}
90+
};
9191

9292
const handleNameSubmit = () => {
9393
let letters = /[a-zA-Z]/;
@@ -214,7 +214,7 @@ const ComponentPanel = (): JSX.Element => {
214214
);
215215
};
216216

217-
const useStyles = makeStyles({
217+
export const useStyles = makeStyles({
218218
inputField: {
219219
marginTop: '15px'
220220
},
@@ -277,7 +277,7 @@ const useStyles = makeStyles({
277277
button: {
278278
fontSize: '1rem',
279279
height: '40px',
280-
maginTop: '10px',
280+
marginTop: '10px',
281281
width: '100%',
282282
// border: '1px solid rgba(70,131,83)',
283283
backgroundColor: 'rgba(1,212,109,0.1)'

app/src/containers/AppContainer.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import { MuiThemeProvider } from '@material-ui/core/styles';
3+
import Button from '@material-ui/core/Button';
34
import LeftContainer from './LeftContainer';
45
import MainContainer from './MainContainer';
56
import RightContainer from './RightContainer';
6-
import theme from '../public/styles/theme';
7+
import { theme1, theme2 } from '../public/styles/theme';
8+
import { makeStyles } from '@material-ui/core/styles';
9+
import { useStyles } from '../components/left/ComponentPanel';
710

811
const AppContainer = () => {
12+
const [theme, setTheme] = useState(theme1);
13+
const classes = useStyles();
14+
const [style, setStyle] = useState({});
15+
916
return (
1017
// Mui theme provider provides themed styling to all MUI components in app
1118
<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>
1226
<div className="app-container">
13-
<LeftContainer />
27+
<LeftContainer style={style} />
1428
<MainContainer />
1529
<RightContainer />
1630
</div>

app/src/containers/LeftContainer.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import Grid from '@material-ui/core/Grid';
55
import ComponentPanel from '../components/left/ComponentPanel';
66
import HTMLPanel from '../components/left/HTMLPanel';
77

8-
98
// Left-hand portion of the app, where component options are displayed
10-
const LeftContainer = (): JSX.Element => {
11-
9+
const LeftContainer = ({ style }): JSX.Element => {
1210
return (
13-
<div className="column left">
11+
<div style={style} className="column left">
1412
<Grid container direction="row" alignItems="center">
1513
<ComponentPanel />
1614
<HTMLPanel />
@@ -19,5 +17,4 @@ const LeftContainer = (): JSX.Element => {
1917
);
2018
};
2119

22-
2320
export default LeftContainer;

app/src/public/styles/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ RIGHT COLUMN
276276
.flex-container {
277277
display: flex;
278278
flex-direction: row;
279+
padding-top: 5px;
279280
}
280281

281282
.flex1 {

app/src/public/styles/theme.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
import { createMuiTheme } from '@material-ui/core/styles';
2-
import indigo from '@material-ui/core/colors/indigo';
2+
// import purple from '@material-ui/core/colors/purple';
3+
// import indigo from '@material-ui/core/colors/indigo';
4+
// import orange from '@material-ui/core/colors/orange';
35

4-
const theme = createMuiTheme({
5-
typography: {
6-
useNextVariants: true
7-
},
6+
export const theme1 = createMuiTheme({
7+
// typography: {
8+
// useNextVariants: true
9+
// },
810
palette: {
911
primary: {
10-
light: '#00e676',
11-
// main: '#33eb91',
12-
main: '#01d46d', // less blinding green
13-
dark: '#14a37f',
14-
contrastText: '#fff'
12+
// light: '#00e676',
13+
main: '#01d46d' // less blinding green
14+
// dark: '#14a37f',
15+
// contrastText: '#fff'
1516
},
16-
secondary: indigo
17+
secondary: {
18+
main: '#ff5722'
19+
}
1720
}
1821
});
1922

20-
export default theme;
23+
export const theme2 = createMuiTheme({
24+
// overrides: {
25+
// MuiContainer: {}
26+
// }
27+
});
28+
29+
// export default theme;

app/src/reducers/componentReducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ const reducer = (state: State, action: Action) => {
415415
};
416416
const rootComponent = {
417417
...state.components[0],
418-
code: '',
418+
code: '<div>Drag in a component or HTML element into the canvas!</div>',
419419
children: [],
420420
style: {}
421421
};

0 commit comments

Comments
 (0)