generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from amosproj/frontend-dev-#10
Implementation of #10
- Loading branch information
Showing
10 changed files
with
253 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import './Loginstyle.css'; | ||
import { useContext } from 'react'; | ||
import CarbonFootprintLogo from 'assets/logo/LogoCarbonteam.png'; | ||
import { uniformStyle, color } from 'resources/theme'; | ||
import slugs from 'resources/slugs'; | ||
import { GlobalContext } from 'hooks/GlobalContext'; | ||
import React from 'react'; | ||
|
||
/** | ||
* The LoginComponent realizes the Login Page. | ||
* | ||
* @author Mani Anand, Martin Wagner | ||
*/ | ||
function LoginComponent() { | ||
const [, setState] = useContext(GlobalContext); | ||
|
||
return ( | ||
<div | ||
className='flex-container' | ||
style={{ backgroundColor: uniformStyle.color.secondaryBackgroundColor }} | ||
> | ||
<div className='w3-padding-24 w3-auto'> | ||
<form | ||
className='login' | ||
action={slugs.categories} | ||
onSubmit={() => setState({ userIsLoggedIn: true })} | ||
style={{ | ||
backgroundColor: uniformStyle.color.primaryBackgroundColor, | ||
borderColor: uniformStyle.color.accentColor | ||
}} | ||
> | ||
<div className='imgcontainer'> | ||
<img src={CarbonFootprintLogo} alt='Carbon Footprint' className='avatar' /> | ||
</div> | ||
<div className='login-container'> | ||
<label htmlFor='uname'> | ||
<b>Username</b> | ||
</label> | ||
<input | ||
className='login' | ||
type='text' | ||
placeholder='Enter Username' | ||
name='uname' | ||
required | ||
/> | ||
<label htmlFor='psw'> | ||
<b>Password</b> | ||
</label> | ||
<input | ||
className='login' | ||
type='password' | ||
placeholder='Enter Password' | ||
name='psw' | ||
required | ||
/> | ||
<button | ||
className='login' | ||
style={{ backgroundColor: uniformStyle.color.accentColor }} | ||
type='submit' | ||
> | ||
Login | ||
</button> | ||
<label> | ||
<input type='checkbox' defaultChecked='checked' name='remember' />{' '} | ||
Remember me | ||
</label> | ||
<div | ||
className='login-container' | ||
style={{ | ||
marginTop: '10px', | ||
marginBottom: '10px', | ||
textAlign: 'right', | ||
backgroundColor: color.lightGray | ||
}} | ||
> | ||
<a href={slugs.forgotPassword}>Forgot password?</a> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default LoginComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* Stylefile for the LoginComponent. | ||
* | ||
*/ | ||
|
||
html, | ||
body, | ||
#root, | ||
.App { | ||
height: 100%; | ||
} | ||
|
||
/* Vertically Centering Container */ | ||
.flex-container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100%; | ||
overflow: auto; | ||
} | ||
|
||
/* Bordered form */ | ||
form.login { | ||
display: flex; | ||
flex-direction: column; | ||
border: 3px solid; | ||
margin: auto; | ||
border-radius: 25px; | ||
max-width: 800px; | ||
} | ||
|
||
/* Full-width inputs */ | ||
input[type='text'].login, | ||
input[type='password'].login { | ||
width: 100%; | ||
padding: 12px 20px; | ||
margin: 8px 0; | ||
display: inline-block; | ||
border: 1px solid #ccc; | ||
box-sizing: border-box; | ||
border-radius: 10px; | ||
} | ||
|
||
/* Making the selected text field appearance also rounded */ | ||
input.login:focus { | ||
outline: none; | ||
box-shadow: 0 0 0 2px; | ||
} | ||
|
||
/* Set a style for all buttons */ | ||
button.login { | ||
color: white; | ||
padding: 14px 20px; | ||
margin: 8px 0; | ||
border: none; | ||
cursor: pointer; | ||
width: 100%; | ||
border-radius: 10px; | ||
} | ||
|
||
/* Add a hover effect for buttons */ | ||
button.login:hover { | ||
opacity: 0.8; | ||
} | ||
|
||
/* Center the logo inside this container */ | ||
.imgcontainer { | ||
height: fit-content; | ||
text-align: center; | ||
margin: 24px 0 12px 0; | ||
} | ||
|
||
/* Avatar image */ | ||
img.avatar { | ||
width: 25%; | ||
margin: auto; | ||
} | ||
|
||
/* Add padding to containers */ | ||
.login-container { | ||
padding: 16px; | ||
max-width: 500px; | ||
margin: auto; | ||
} | ||
|
||
/* The "Forgot password" text */ | ||
span.psw { | ||
float: right; | ||
padding-top: 16px; | ||
} | ||
|
||
/* Change styles for span and cancel button on extra small screens */ | ||
@media screen and (max-width: 450px) { | ||
img.avatar { | ||
width: 75%; | ||
margin: auto; | ||
} | ||
span.psw { | ||
display: block; | ||
float: none; | ||
} | ||
.cancelbtn { | ||
width: 100%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* The GlobalContext enables cross-Component State-Management | ||
* | ||
* @author Martin Wagner | ||
*/ | ||
|
||
import React, { useState, createContext } from 'react'; | ||
|
||
export const GlobalContext = createContext(); | ||
|
||
/** | ||
* Defines a StateProvider, that passes down all its data to every child component. | ||
* | ||
* @param {*} props the previous state that has been used. | ||
*/ | ||
export const GlobalStateProvider = (props) => { | ||
const [state, setState] = useState({ userIsLoggedIn: false }); | ||
|
||
return ( | ||
<GlobalContext.Provider value={[state, setState]}>{props.children}</GlobalContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters