1
- import React , { useState , useCallback , useEffect } from 'react' ;
1
+ import React , { useState , useCallback , useEffect , createContext } from 'react' ;
2
2
import { LoginInt } from '../../interfaces/Interfaces' ;
3
3
import {
4
4
Link as RouteLink ,
@@ -18,6 +18,25 @@ import Container from '@material-ui/core/Container';
18
18
import LockOutlinedIcon from '@material-ui/icons/LockOutlined' ;
19
19
import { newUserIsCreated } from '../../helperFunctions/auth' ;
20
20
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
+ } ;
21
40
22
41
function Copyright ( ) {
23
42
return (
@@ -184,95 +203,115 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
184
203
'MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-4 MuiButton-fullWidth' ;
185
204
186
205
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
+ />
228
266
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 >
268
307
</ 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 >
275
314
) ;
276
315
} ;
277
316
278
- export default withRouter ( SignIn ) ;
317
+ export default connect ( mapStateToProps , mapDispatchToProps ) ( SignIn ) ;
0 commit comments