Skip to content

Commit 3621590

Browse files
authored
Merge pull request #17 from oslabs-beta/addReduxAndMikos
Fixed demo render, live preview, darkmode, and misc visual bugs
2 parents 889bba7 + 05d3187 commit 3621590

26 files changed

+516
-270
lines changed

app/src/components/bottom/CodePreview.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ const CodePreview: React.FC<{
4545
);
4646

4747
const [input, setInput] = useState();
48-
49-
useEffect(() => {
50-
console.log('CodePreview input', input);
51-
console.log('currentComponent.code', currentComponent.code);
52-
}, [input])
5348

5449
useEffect(() => {
5550
startService();

app/src/components/form/Selector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const FormSelector = (props): JSX.Element => {
88
const items = [];
99
let key = 1;
1010
props.items.forEach(el => {
11-
items.push(<MenuItem value={el.value} key={`menu${key}`}>{el.text}</MenuItem>);
11+
items.push(<MenuItem style={{ color: 'black' }} value={el.value} key={`menu${key}`}>{el.text}</MenuItem>);
1212
key++
1313
})
1414
return (

app/src/components/left/DragDropPanel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const DragDropPanel = (props): JSX.Element => {
2828
};
2929

3030
// filter out separator so that it will not appear on the html panel
31-
const htmlTypesToRender = state.HTMLTypes.filter(type => type.name !== 'separator' && type.name !== 'Route');
31+
const htmlTypesToRender = state.HTMLTypes.filter(type => type.name !== 'separator');
3232
return (
3333
<div className="HTMLItems">
3434
<div id="HTMLItemsTopHalf">
@@ -37,7 +37,7 @@ const DragDropPanel = (props): JSX.Element => {
3737
>
3838
<h3 style={ {color: isThemeLight ? '#000' : '#fff'} }>HTML ELEMENTS</h3>
3939
{htmlTypesToRender.map(option => {
40-
if (!['Switch', 'LinkTo', 'LinkHref', 'Image'].includes(option.name)) {
40+
if (!['Switch', 'LinkTo', 'LinkHref', 'Image', 'Route'].includes(option.name)) {
4141
return (
4242
<HTMLItem
4343
name={option.name}
@@ -53,7 +53,7 @@ const DragDropPanel = (props): JSX.Element => {
5353
})}
5454
{state.projectType === "Classic React" ? <h3 style={ {color: isThemeLight ? '#000' : '#fff' } }>REACT ROUTER</h3> : null}
5555
{htmlTypesToRender.map(option => {
56-
if ((option.name === 'Switch' || option.name === 'LinkTo') && state.projectType === "Classic React") {
56+
if ((option.name === 'Switch' || option.name === 'LinkTo' || option.name === 'Route') && state.projectType === "Classic React") {
5757
return (
5858
<HTMLItem
5959
name={option.name}

app/src/components/left/HTMLPanel.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ const HTMLPanel = (props): JSX.Element => {
172172
onChange={handleTagChange}
173173
className={isThemeLight ? `${classes.input} ${classes.lightThemeFontColor}` : `${classes.input} ${classes.darkThemeFontColor}`}
174174
style={{ margin: '10px' }}
175+
InputProps={{
176+
style: {
177+
color: isThemeLight ? 'black' : 'white'
178+
}
179+
}}
175180
/>
176181

177182
{(!tag.charAt(0).match(/[A-Za-z]/) || !alphanumeric(tag) || tag.trim() === '' || checkNameDupe(tag))
@@ -192,8 +197,14 @@ const HTMLPanel = (props): JSX.Element => {
192197
onChange={handleNameChange}
193198
autoComplete="off"
194199
className={isThemeLight ? `${classes.input} ${classes.lightThemeFontColor}` : `${classes.input} ${classes.darkThemeFontColor}`}
195-
style={{ margin: '10px' }}
200+
style={{}}
201+
InputProps={{
202+
style: {
203+
color: isThemeLight ? 'black' : 'white'
204+
}
205+
}}
196206
/>
207+
197208

198209
{(!name.charAt(0).match(/[A-Za-z]/) || !alphanumeric(name) || name.trim() === '' || name.length > 10 || checkNameDupe(name))
199210
&& <span className={isThemeLight ? `${classes.errorMessage} ${classes.errorMessageLight}` : `${classes.errorMessage} ${classes.errorMessageDark}`}>
@@ -244,8 +255,8 @@ const useStyles = makeStyles({
244255
textOverflow: 'ellipsis',
245256
backgroundColor: 'rgba(255,255,255,0.15)',
246257
margin: '0px 0px 0px 0px',
247-
width: '160px',
248-
height: '30px',
258+
// width: '200px',
259+
// height: '75px',
249260
alignSelf: 'center',
250261
border: '2px solid grey'
251262
},

app/src/components/login/SignIn.tsx

Lines changed: 127 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useCallback, useEffect } from 'react';
1+
import React, { useState, useCallback, useEffect, createContext } from 'react';
22
import { LoginInt } from '../../interfaces/Interfaces';
33
import {
44
Link as RouteLink,
@@ -18,6 +18,25 @@ import Container from '@material-ui/core/Container';
1818
import LockOutlinedIcon from '@material-ui/icons/LockOutlined';
1919
import { newUserIsCreated } from '../../helperFunctions/auth';
2020
import randomPassword from '../../helperFunctions/randomPassword';
21+
import { connect } from 'react-redux';
22+
import * as actions from '../../redux/actions/actions.js';
23+
24+
import { MuiThemeProvider } from '@material-ui/core/styles';
25+
import { SigninDark, SigninLight } from '../../../../app/src/public/styles/theme';
26+
import Brightness3Icon from '@material-ui/icons/Brightness3';
27+
import Brightness5Icon from '@material-ui/icons/Brightness5';
28+
29+
const mapDispatchToProps = (dispatch) => ({
30+
darkModeToggle: () => {
31+
dispatch(actions.darkModeToggle());
32+
}
33+
});
34+
35+
const mapStateToProps = (state) => {
36+
return {
37+
darkMode: state.darkModeSlice.darkMode
38+
}
39+
};
2140

2241
function Copyright() {
2342
return (
@@ -184,95 +203,115 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
184203
'MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-4 MuiButton-fullWidth';
185204

186205
return (
187-
<Container component="main" maxWidth="xs">
188-
<CssBaseline />
189-
<div className={classes.paper}>
190-
<Avatar className={classes.avatar}>
191-
<LockOutlinedIcon />
192-
</Avatar>
193-
<Typography component="h1" variant="h5" color="textPrimary">
194-
Sign in
195-
</Typography>
196-
<TextField
197-
className={classes.root}
198-
variant="outlined"
199-
margin="normal"
200-
required
201-
fullWidth
202-
id="username"
203-
label="Username"
204-
name="username"
205-
autoComplete="username"
206-
autoFocus
207-
value={username}
208-
onChange={handleChange}
209-
helperText={invalidUserMsg}
210-
error={invalidUser}
211-
/>
212-
<TextField
213-
className={classes.root}
214-
variant="outlined"
215-
margin="normal"
216-
required
217-
fullWidth
218-
name="password"
219-
label="Password"
220-
type="password"
221-
id="password"
222-
autoComplete="current-password"
223-
value={password}
224-
onChange={handleChange}
225-
helperText={invalidPassMsg}
226-
error={invalidPass}
227-
/>
206+
<MuiThemeProvider theme={!props.darkMode ? SigninLight : SigninDark}>
207+
<Container component="main" maxWidth="xs">
208+
<CssBaseline />
209+
<div className={classes.paper}>
210+
<Button
211+
color="primary"
212+
style={{
213+
minWidth: '113.97px',
214+
top: 10,
215+
right: 20,
216+
position: "absolute"
217+
}}
218+
// variant="contained"
219+
endIcon={
220+
props.darkMode ? <Brightness3Icon /> : <Brightness5Icon />
221+
}
222+
onClick={() => {
223+
props.darkModeToggle();
224+
}}
225+
>
226+
{`Dark Mode: ${props.darkMode}`}
227+
</Button>
228+
<Avatar className={classes.avatar}>
229+
<LockOutlinedIcon />
230+
</Avatar>
231+
<Typography component="h1" variant="h5" color="textPrimary">
232+
Sign in
233+
</Typography>
234+
<TextField
235+
className={classes.root}
236+
variant="outlined"
237+
margin="normal"
238+
required
239+
fullWidth
240+
id="username"
241+
label="Username"
242+
name="username"
243+
autoComplete="username"
244+
autoFocus
245+
value={username}
246+
onChange={handleChange}
247+
helperText={invalidUserMsg}
248+
error={invalidUser}
249+
/>
250+
<TextField
251+
className={classes.root}
252+
variant="outlined"
253+
margin="normal"
254+
required
255+
fullWidth
256+
name="password"
257+
label="Password"
258+
type="password"
259+
id="password"
260+
autoComplete="current-password"
261+
value={password}
262+
onChange={handleChange}
263+
helperText={invalidPassMsg}
264+
error={invalidPass}
265+
/>
228266

229-
<Button
230-
fullWidth
231-
id="SignIn"
232-
variant="contained"
233-
color="default"
234-
className={classes.submit}
235-
onClick={e => handleLogin(e)}
236-
>
237-
Sign In
238-
</Button>
239-
<Button
240-
fullWidth
241-
id="SignInWithGithub"
242-
variant="contained"
243-
color="default"
244-
className={classes.submit}
245-
onClick={e => handleGithubLogin(e)}
246-
>
247-
Sign In With Github
248-
</Button>
249-
<Button
250-
fullWidth
251-
variant="contained"
252-
color="default"
253-
className={classes.submit}
254-
onClick={e => handleLoginGuest(e)}
255-
>
256-
Continue as Guest
257-
</Button>
258-
<Grid container>
259-
<Grid item xs>
260-
<RouteLink to={`/signup`} className="nav_link">
261-
Forgot password?
262-
</RouteLink>
263-
</Grid>
264-
<Grid item>
265-
<RouteLink to={`/signup`} className="nav_link">
266-
Don't have an account? Sign Up
267-
</RouteLink>
267+
<Button
268+
fullWidth
269+
id="SignIn"
270+
variant="contained"
271+
color="primary"
272+
className={classes.submit}
273+
onClick={e => handleLogin(e)}
274+
>
275+
Sign In
276+
</Button>
277+
<Button
278+
fullWidth
279+
id="SignInWithGithub"
280+
variant="contained"
281+
color="primary"
282+
className={classes.submit}
283+
onClick={e => handleGithubLogin(e)}
284+
>
285+
Sign In With Github
286+
</Button>
287+
<Button
288+
fullWidth
289+
variant="contained"
290+
color="primary"
291+
className={classes.submit}
292+
onClick={e => handleLoginGuest(e)}
293+
>
294+
Continue as Guest
295+
</Button>
296+
<Grid container>
297+
<Grid item xs>
298+
<RouteLink to={`/signup`} className="nav_link">
299+
Forgot password?
300+
</RouteLink>
301+
</Grid>
302+
<Grid item>
303+
<RouteLink to={`/signup`} className="nav_link">
304+
Don't have an account? Sign Up
305+
</RouteLink>
306+
</Grid>
268307
</Grid>
269-
</Grid>
270-
</div>
271-
<Box mt={8}>
272-
<Copyright />
273-
</Box>
274-
</Container>
308+
</div>
309+
<Box mt={8}>
310+
<Copyright />
311+
</Box>
312+
</Container>
313+
</MuiThemeProvider>
275314
);
276315
};
277316

278-
export default withRouter(SignIn);
317+
export default connect(mapStateToProps, mapDispatchToProps)(SignIn);

0 commit comments

Comments
 (0)