Skip to content

Commit

Permalink
Outsourced Styling to a css file
Browse files Browse the repository at this point in the history
Regarding #10

Co-authored-by: Mani Anand <mani.anand@fau.de>
  • Loading branch information
Waldleufer and manifau committed May 27, 2021
1 parent 824155a commit df59e06
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 67 deletions.
65 changes: 37 additions & 28 deletions frontend/src/components/login/LoginComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,43 @@
* @author Martin Wagner
* */

import style from "./Loginstyle"
function LoginComponent( ) {
import './Loginstyle.css';

return (
<>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style dangerouslySetInnerHTML={{__html: "\nbody {font-family: Arial, Helvetica, sans-serif;}\nform {border: 3px solid #f1f1f1;}\n\ninput[type=text], input[type=password] {\n width: 100%;\n padding: 12px 20px;\n margin: 8px 0;\n display: inline-block;\n border: 1px solid #ccc;\n box-sizing: border-box;\n}\n\nbutton {\n background-color: #04AA6D;\n color: white;\n padding: 14px 20px;\n margin: 8px 0;\n border: none;\n cursor: pointer;\n width: 100%;\n}\n\nbutton:hover {\n opacity: 0.8;\n}\n\n.cancelbtn {\n width: auto;\n padding: 10px 18px;\n background-color: #f44336;\n}\n\n.imgcontainer {\n text-align: center;\n margin: 24px 0 12px 0;\n}\n\nimg.avatar {\n width: 40%;\n border-radius: 50%;\n}\n\n.container {\n padding: 16px;\n}\n\nspan.psw {\n float: right;\n padding-top: 16px;\n}\n\n/* Change styles for span and cancel button on extra small screens */\n@media screen and (max-width: 300px) {\n span.psw {\n display: block;\n float: none;\n }\n .cancelbtn {\n width: 100%;\n }\n}\n" }} />
<h2>Login Form</h2>
<form action="/action_page.php" method="post">
<div className="imgcontainer">
<img src="img_avatar2.png" alt="Avatar" className="avatar" />
</div>
<div className="container">
<label htmlFor="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required />
<label htmlFor="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required />
<button type="submit">Login</button>
<label>
<input type="checkbox" defaultChecked="checked" name="remember" /> Remember me
</label>
</div>
<div className="container" style={{backgroundColor: '#f1f1f1'}}>
<button type="button" className="cancelbtn">Cancel</button>
<span className="psw">Forgot <a href="#">password?</a></span>
</div>
</form>
</>
)}
function LoginComponent() {
return (
<>
<meta name='viewport' content='width=device-width, initial-scale=1' />
<h2>Login Form</h2>
<form action='/action_page.php' method='post'>
<div className='imgcontainer'>
<img src='img_avatar2.png' alt='Avatar' className='avatar' />
</div>
<div className='container'>
<label htmlFor='uname'>
<b>Username</b>
</label>
<input type='text' placeholder='Enter Username' name='uname' required />
<label htmlFor='psw'>
<b>Password</b>
</label>
<input type='password' placeholder='Enter Password' name='psw' required />
<button type='submit'>Login</button>
<label>
<input type='checkbox' defaultChecked='checked' name='remember' /> Remember
me
</label>
</div>
<div className='container' style={{ backgroundColor: '#f1f1f1' }}>
<button type='button' className='cancelbtn'>
Cancel
</button>
<span className='psw'>
Forgot <a href='#'>password?</a>
</span>
</div>
</form>
</>
);
}

export default LoginComponent;
72 changes: 72 additions & 0 deletions frontend/src/components/login/Loginstyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* Bordered form */
form {
border: 3px solid #f1f1f1;
}

/* Full-width inputs */
input[type='text'],
input[type='password'] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}

/* Set a style for all buttons */
button {
background-color: #04aa6d;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}

/* Add a hover effect for buttons */
button:hover {
opacity: 0.8;
}

/* Extra style for the cancel button (red) */
.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}

/* Center the avatar image inside this container */
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}

/* Avatar image */
img.avatar {
width: 40%;
border-radius: 50%;
}

/* Add padding to containers */
.container {
padding: 16px;
}

/* 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: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}
39 changes: 0 additions & 39 deletions frontend/src/components/login/Loginstyle.js

This file was deleted.

0 comments on commit df59e06

Please sign in to comment.