Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigment 2 #98

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added SignUp and Login Page with routing
Mudit-Jxin7 committed May 26, 2023
commit 4a57ff8c3d71af5b2f43749d1990bb1eda17eac5
63 changes: 62 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.2"
},
"devDependencies": {
"@types/react": "^18.0.28",
42 changes: 0 additions & 42 deletions src/App.css

This file was deleted.

74 changes: 17 additions & 57 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,19 @@
/*
* Temporary problems array schema
*/
const problems = [{
title: "201. Bitwise AND of Numbers Range",
difficulty: "Medium",
acceptance: "42%"
},{
title: "201. Bitwise AND of Numbers Range",
difficulty: "Medium",
acceptance: "412%"
},
{
title: "202. Happy Number",
difficulty: "Easy",
acceptance: "54.9%"
},
{
title: "203. Remove Linked List Elements",
difficulty: "Hard",
acceptance: "42%"
}];
import React from "react";
import { Routes, Route } from "react-router-dom";
import Login from "./pages/Login";
import Signup from "./pages/Signup";
import Problem from "./pages/Problem";
import ProblemList from "./pages/ProblemList";

const App = () => {
return (
<Routes>
<Route path="/" element={<Login />} />
<Route path="/signup" element={<Signup />} />
<Route path="/problemlist" element={<ProblemList />} />
<Route path="/problem" element={<Problem />} />
</Routes>
);
};

function App() {

/* Add routing here, routes look like -
/login - Login page
/signup - Signup page
/problemset/all/ - All problems (see problems array above)
/problems/:problem_slug - A single problem page
*/

return (
<div>
Finish the assignment! Look at the comments in App.jsx as a starting point
</div>
)
}

// A demo component
function ProblemStatement(props) {
const title = props.title;
const acceptance = props.acceptance;
const difficulty = props.difficulty;

return <tr>
<td>
{title}
</td>
<td>
{acceptance}
</td>
<td>
{difficulty}
</td>
</tr>
}
export default App
export default App;
53 changes: 53 additions & 0 deletions src/css/Login.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
* {
font-family: Arial, Helvetica, sans-serif;
}

.login {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f5f5f5;
}

.card {
width: 300px;
max-width: 90%;
padding: 20px;
background-color: #fff;
border-radius: 5px;
text-align: center;
}

.card h2 {
margin-bottom: 20px;
color: #333;
}

form {
display: flex;
flex-direction: column;
}

input {
margin-bottom: 10px;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}

button {
padding: 10px 20px;
font-size: 16px;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 5px;
cursor: pointer;
margin-bottom: 1rem;
}

button:hover {
background-color: #0056b3;
}
Empty file removed src/index.css
Empty file.
20 changes: 11 additions & 9 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import './index.css'
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import { BrowserRouter } from "react-router-dom";

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
ReactDOM.createRoot(document.getElementById("root")).render(
<BrowserRouter>
<React.StrictMode>
<App />
</React.StrictMode>
</BrowserRouter>
);
20 changes: 20 additions & 0 deletions src/pages/Login.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import "../css/Login.css";
import { Link } from "react-router-dom";

const Login = () => {
return (
<div className="login">
<div className="card">
<h2>Login</h2>
<form>
<input type="text" placeholder="Username" required />
<input type="password" placeholder="Password" required />
<button type="submit">Login</button>
<Link to="/signup">Sign Up</Link>
</form>
</div>
</div>
);
};

export default Login;
7 changes: 7 additions & 0 deletions src/pages/Problem.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";

const Problem = () => {
return <div>Problem</div>;
};

export default Problem;
7 changes: 7 additions & 0 deletions src/pages/ProblemList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";

const ProblemList = () => {
return <div>ProblemList</div>;
};

export default ProblemList;
18 changes: 18 additions & 0 deletions src/pages/Signup.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "../css/Login.css";

const Signup = () => {
return (
<div className="login">
<div className="card">
<h2>Signup</h2>
<form>
<input type="text" placeholder="Username" required />
<input type="password" placeholder="Password" required />
<button type="submit">Signup</button>
</form>
</div>
</div>
);
};

export default Signup;