diff --git a/index.html b/index.html index 79c47019..dfafd199 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,11 @@ Vite + React +
diff --git a/package-lock.json b/package-lock.json index cd606935..4a36cfa9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "0.0.0", "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", @@ -766,6 +767,14 @@ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", "dev": true }, + "node_modules/@remix-run/router": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.6.2.tgz", + "integrity": "sha512-LzqpSrMK/3JBAVBI9u3NWtOhWNw5AMQfrUFYB0+bDHTSw17z++WJLsPsxAuK+oSddsxk4d7F/JcdDPM1M5YAhA==", + "engines": { + "node": ">=14" + } + }, "node_modules/@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", @@ -1226,6 +1235,36 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.11.2.tgz", + "integrity": "sha512-74z9xUSaSX07t3LM+pS6Un0T55ibUE/79CzfZpy5wsPDZaea1F8QkrsiyRnA2YQ7LwE/umaydzXZV80iDCPkMg==", + "dependencies": { + "@remix-run/router": "1.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.11.2.tgz", + "integrity": "sha512-JNbKtAeh1VSJQnH6RvBDNhxNwemRj7KxCzc5jb7zvDSKRnPWIFj9pO+eXqjM69gQJ0r46hSz1x4l9y0651DKWw==", + "dependencies": { + "@remix-run/router": "1.6.2", + "react-router": "6.11.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/resolve": { "version": "1.22.2", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", @@ -1853,6 +1892,11 @@ } } }, + "@remix-run/router": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.6.2.tgz", + "integrity": "sha512-LzqpSrMK/3JBAVBI9u3NWtOhWNw5AMQfrUFYB0+bDHTSw17z++WJLsPsxAuK+oSddsxk4d7F/JcdDPM1M5YAhA==" + }, "@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", @@ -2176,6 +2220,23 @@ "integrity": "sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==", "dev": true }, + "react-router": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.11.2.tgz", + "integrity": "sha512-74z9xUSaSX07t3LM+pS6Un0T55ibUE/79CzfZpy5wsPDZaea1F8QkrsiyRnA2YQ7LwE/umaydzXZV80iDCPkMg==", + "requires": { + "@remix-run/router": "1.6.2" + } + }, + "react-router-dom": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.11.2.tgz", + "integrity": "sha512-JNbKtAeh1VSJQnH6RvBDNhxNwemRj7KxCzc5jb7zvDSKRnPWIFj9pO+eXqjM69gQJ0r46hSz1x4l9y0651DKWw==", + "requires": { + "@remix-run/router": "1.6.2", + "react-router": "6.11.2" + } + }, "resolve": { "version": "1.22.2", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", diff --git a/package.json b/package.json index 154dd4dd..208323e3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/App.css b/src/App.css deleted file mode 100644 index b9d355df..00000000 --- a/src/App.css +++ /dev/null @@ -1,42 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} diff --git a/src/App.jsx b/src/App.jsx index 7743965b..731d884a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,59 +1,21 @@ -/* - * 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"; +import NotFound from "./pages/NotFound"; +const App = () => { + return ( + + } /> + } /> + } /> + } /> + } /> + + ); +}; -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 ( -
- Finish the assignment! Look at the comments in App.jsx as a starting point -
- ) -} - -// A demo component -function ProblemStatement(props) { - const title = props.title; - const acceptance = props.acceptance; - const difficulty = props.difficulty; - - return - - {title} - - - {acceptance} - - - {difficulty} - - -} -export default App +export default App; diff --git a/src/css/Login.css b/src/css/Login.css new file mode 100644 index 00000000..dac5952b --- /dev/null +++ b/src/css/Login.css @@ -0,0 +1,104 @@ +* { + 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: 10px; + text-align: center; + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); /* Add a subtle box shadow */ +} + +.card h2 { + margin-bottom: 20px; + color: #333; +} + +form { + display: flex; + flex-direction: column; + align-items: center; +} + +input { + margin-bottom: 10px; + padding: 10px; + font-size: 16px; + border: 1px solid #ccc; + border-radius: 5px; + outline: none; /* Remove the outline on focus */ +} + +button { + padding: 10px 20px; + font-size: 16px; + color: #fff; + background-color: #007bff; + border: none; + border-radius: 5px; + cursor: pointer; + margin-bottom: 1rem; + transition: background-color 0.3s ease; /* Add a smooth transition effect */ +} + +button:hover { + background-color: #0056b3; +} + +/* Add some additional styles to make it more visually appealing */ + +.login { + background-color: #f1f5f8; +} + +.card { + margin: 20px; + border: 1px solid #ddd; +} + +.card h2 { + margin-bottom: 30px; + font-size: 24px; + color: #333; +} + +input { + width: 100%; + margin-bottom: 20px; + padding: 12px; + font-size: 16px; + border: 1px solid #ddd; + border-radius: 8px; + transition: border-color 0.3s ease; +} + +input:focus { + border-color: #007bff; +} + +button { + width: 100%; + padding: 12px; + font-size: 16px; + color: #fff; + background-color: #007bff; + border: none; + border-radius: 8px; + cursor: pointer; + transition: background-color 0.3s ease; +} + +button:hover { + background-color: #0056b3; +} diff --git a/src/css/Problem.css b/src/css/Problem.css new file mode 100644 index 00000000..c042a8ab --- /dev/null +++ b/src/css/Problem.css @@ -0,0 +1,117 @@ +* { + font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; + box-sizing: border-box; +} + +.problem-form-container { + display: flex; + justify-content: space-between; +} + +.left-section { + flex: 1; + padding-right: 20px; +} + +.right-section { + flex: 1; + padding-left: 20px; + border-left: 1px solid #eaeaea; +} + +h2 { + font-size: 28px; + margin-bottom: 30px; + color: #333333; +} + +.form-fields { + display: flex; + flex-direction: column; +} + +.form-field { + margin-bottom: 30px; +} + +label { + font-weight: bold; + font-size: 16px; + color: #333333; + margin-bottom: 1rem; +} + +input, +textarea { + width: 100%; + padding: 12px; + border: 1px solid #eaeaea; + border-radius: 6px; + background-color: #f9f9f9; + color: #333333; + font-size: 16px; + outline: none; + transition: background-color 0.3s ease; +} + +input:focus, +textarea:focus { + background-color: #f5f5f5; +} + +button { + background-color: #007bff; + color: #ffffff; + padding: 12px 24px; + border: none; + border-radius: 6px; + font-size: 16px; + font-weight: bold; + cursor: pointer; + transition: background-color 0.3s ease; +} + +button:hover { + background-color: #0056b3; +} + +.preview-content { + display: flex; + flex-direction: column; +} + +.preview-field { + margin-bottom: 15px; +} + +.preview-field h3 { + font-size: 20px; + color: #333333; + margin-bottom: 10px; +} + +.preview-field p { + white-space: pre-line; + padding: 10px; + background-color: #f5f5f5; + border: 1px solid #eaeaea; + border-radius: 6px; + color: #333333; +} + +button.back-button { + background-color: #007bff; + color: #ffffff; + padding: 10px 20px; + border: none; + border-radius: 6px; + font-size: 16px; + font-weight: bold; + cursor: pointer; + transition: background-color 0.3s ease; + margin-top: 20px; +} + +button.back-button:hover { + background-color: #0056b3; +} diff --git a/src/css/ProblemList.css b/src/css/ProblemList.css new file mode 100644 index 00000000..35261cd0 --- /dev/null +++ b/src/css/ProblemList.css @@ -0,0 +1,57 @@ +* { + font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; + box-sizing: border-box; +} + +.heading { + margin: auto; + text-align: center; + margin-bottom: 1rem; +} + +table { + border-collapse: collapse; + width: 100%; + max-width: 600px; + margin: auto; +} + +th, +td { + border: 1px solid #ddd; + padding: 8px; +} + +thead th { + background-color: #f2f2f2; +} + +tbody tr:nth-child(even) { + background-color: #f9f9f9; +} + +div { + margin: 0.5rem; +} + +button { + background-color: #007bff; + color: #ffffff; + padding: 8px 12px; + border: none; + border-radius: 4px; + font-size: 14px; + font-weight: bold; + cursor: pointer; + transition: background-color 0.3s ease; +} + +button:hover { + background-color: #0056b3; +} + +.center { + display: flex; + justify-content: center; + align-items: center; +} diff --git a/src/index.css b/src/index.css deleted file mode 100644 index e69de29b..00000000 diff --git a/src/main.jsx b/src/main.jsx index 5cc59919..3ee309d3 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -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( - - - , -) +ReactDOM.createRoot(document.getElementById("root")).render( + + + + + +); diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx new file mode 100644 index 00000000..a17f696f --- /dev/null +++ b/src/pages/Login.jsx @@ -0,0 +1,20 @@ +import "../css/Login.css"; +import { Link } from "react-router-dom"; + +const Login = () => { + return ( +
+
+

Login

+
+ + + + Sign Up +
+
+
+ ); +}; + +export default Login; diff --git a/src/pages/NotFound.jsx b/src/pages/NotFound.jsx new file mode 100644 index 00000000..75f177c7 --- /dev/null +++ b/src/pages/NotFound.jsx @@ -0,0 +1,7 @@ +import React from "react"; + +const NotFound = () => { + return
NotFound
; +}; + +export default NotFound; diff --git a/src/pages/Problem.jsx b/src/pages/Problem.jsx new file mode 100644 index 00000000..6f5413c6 --- /dev/null +++ b/src/pages/Problem.jsx @@ -0,0 +1,205 @@ +import "../css/Problem.css"; +import { Link, useParams } from "react-router-dom"; +const Problems = [ + { + id: "1", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "2", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "3", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "4", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "5", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "6", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "7", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "8", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "9", + title: "Two Sum", + description: + "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.", + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + }, + { + id: "10", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, + { + id: "11", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, + { + id: "12", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, + { + id: "13", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, + { + id: "14", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, + { + id: "15", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, + { + id: "16", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, + { + id: "17", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, + { + id: "18", + title: "Add Two Numbers", + description: + "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.", + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + }, +]; + +const Problem = () => { + const { id } = useParams(); + + const problem = Problems.find((problem) => problem.id === id); + if (!problem) { + return
Problem not found
; + } + + const { title, description, input, output } = problem; + + return ( +
+
+
+
+

{title}

+

{description}

+
+
+

Input

+

{input}

+
+
+

Output

+

{output}

+
+
+ +
+
+
+
+
+
+ + +
+ + +
+
+
+ ); +}; + +export default Problem; diff --git a/src/pages/ProblemList.jsx b/src/pages/ProblemList.jsx new file mode 100644 index 00000000..5cdf16af --- /dev/null +++ b/src/pages/ProblemList.jsx @@ -0,0 +1,197 @@ +import React, { useState } from "react"; +import { Link } from "react-router-dom"; +import "../css/ProblemList.css"; + +const Problem1 = [ + { + id: 1, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, + { + id: 2, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, + { + id: 3, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, + { + id: 4, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, + { + id: 5, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, + { + id: 6, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, + { + id: 7, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, + { + id: 8, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, + { + id: 9, + Title: "Two Sum", + Acceptance: "67.8%", + difficulty: "Easy", + }, +]; + +const Problem2 = [ + { + id: 10, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, + { + id: 11, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, + { + id: 12, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, + { + id: 13, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, + { + id: 14, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, + { + id: 15, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, + { + id: 16, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, + { + id: 17, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, + { + id: 18, + Title: "Add Two Numbers", + Acceptance: "40.5%", + difficulty: "Medium", + }, +]; + +const ProblemList = () => { + const [data, setData] = useState(Problem1); + + const displayProblemSetOne = () => { + setData(Problem1); + }; + + const displayProblemSetTwo = () => { + setData(Problem2); + }; + + return ( +
+

Problems

+ + + + + + + + + + + {data.map((row) => ( + + + + + + + ))} + +
S.noTitleAcceptanceDifficulty
{row.id} +
+ {row.Title} +
+
+
{row.Acceptance}
+
+
{row.difficulty}
+
+
+ + +
+
+ ); +}; + +export default ProblemList; diff --git a/src/pages/Signup.jsx b/src/pages/Signup.jsx new file mode 100644 index 00000000..5e11e5ba --- /dev/null +++ b/src/pages/Signup.jsx @@ -0,0 +1,18 @@ +import "../css/Login.css"; + +const Signup = () => { + return ( +
+
+

Signup

+
+ + + +
+
+
+ ); +}; + +export default Signup;