From 70d3bc6e7464bd329bc091d39904365ad5a15a4b Mon Sep 17 00:00:00 2001 From: Sree Sree Date: Sat, 20 May 2023 11:16:46 +0530 Subject: [PATCH 1/2] added register,login screens --- index.html | 28 ++++++---- package-lock.json | 63 +++++++++++++++++++++- package.json | 3 +- src/App.jsx | 70 +++++++----------------- src/Layout/Footer.jsx | 17 ++++++ src/Layout/Layout.jsx | 18 +++++++ src/containers/Auth/Login.jsx | 74 ++++++++++++++++++++++++++ src/containers/Auth/Register.jsx | 91 ++++++++++++++++++++++++++++++++ src/containers/Header.jsx | 55 +++++++++++++++++++ src/containers/HomePage.jsx | 14 +++++ src/containers/Pagenotfound.jsx | 26 +++++++++ src/index.css | 15 ++++++ src/main.jsx | 5 +- 13 files changed, 413 insertions(+), 66 deletions(-) create mode 100644 src/Layout/Footer.jsx create mode 100644 src/Layout/Layout.jsx create mode 100644 src/containers/Auth/Login.jsx create mode 100644 src/containers/Auth/Register.jsx create mode 100644 src/containers/Header.jsx create mode 100644 src/containers/HomePage.jsx create mode 100644 src/containers/Pagenotfound.jsx diff --git a/index.html b/index.html index 79c47019..6d4e65f7 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,21 @@ - - - - - Vite + React - - -
- - + + + + + + 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.jsx b/src/App.jsx index 7743965b..a3b953d5 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,59 +1,25 @@ -/* - * 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 { Route, Routes } from 'react-router-dom'; +import HomePage from './containers/HomePage'; +import Layout from './Layout/Layout'; +import Login from './containers/Auth/Login'; +import Pagenotfound from './containers/Pagenotfound'; +import Register from './containers/Auth/Register'; +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 diff --git a/src/Layout/Footer.jsx b/src/Layout/Footer.jsx new file mode 100644 index 00000000..e580b3f4 --- /dev/null +++ b/src/Layout/Footer.jsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { Link } from 'react-router-dom'; + +const Footer = () => { + return ( +
+

All Right's Reserved © Sree

+

+ About | + Contact | + Privacy Policy +

+
+ ); +}; + +export default Footer; diff --git a/src/Layout/Layout.jsx b/src/Layout/Layout.jsx new file mode 100644 index 00000000..e2d2b8e3 --- /dev/null +++ b/src/Layout/Layout.jsx @@ -0,0 +1,18 @@ +import React from 'react' +import Footer from '../Layout/Footer' +import HomePage from '../containers/HomePage' +import Header from '../containers/Header' + +const Layout = ({ children }) => { + return ( +
+
+
{children}
+ +
+ +
+ ) +} + +export default Layout diff --git a/src/containers/Auth/Login.jsx b/src/containers/Auth/Login.jsx new file mode 100644 index 00000000..850d23bf --- /dev/null +++ b/src/containers/Auth/Login.jsx @@ -0,0 +1,74 @@ +import React, { useState } from 'react' +import Layout from '../../Layout/Layout'; +import { useNavigate } from 'react-router-dom'; + + +const Login = () => { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + + const navigate = useNavigate(); + const submitHandle = () => { + navigate('/') + } + return ( + +
+
+

Login Form

+
+ setEmail(e.target.value)} + placeholder='Enter your Email' + type='email' + className='form-control border border-0 rounded-0' + id='exampleInputEmail1' + required + aria-describedby='emailHelp' + autoFocus + /> +
+
+ setPassword(e.target.value)} + placeholder='Enter your Password' + type='password' + required + className='form-control border border-0 rounded-0' + id='exampleInputPassword1' + /> +
+ + navigate('/forgot-password')} + > + Forgot Password? + + +
+
+
+ ) +} + +export default Login diff --git a/src/containers/Auth/Register.jsx b/src/containers/Auth/Register.jsx new file mode 100644 index 00000000..9c2f5155 --- /dev/null +++ b/src/containers/Auth/Register.jsx @@ -0,0 +1,91 @@ +import React, { useState } from 'react' +import Layout from '../../Layout/Layout'; +import { useNavigate } from 'react-router-dom'; + + +const Register = () => { + const [name, setName] = useState(''); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + + const navigate = useNavigate(); + const submitHandle = () => { + navigate('/') + } + return ( + +
+
+

Register Form

+
+ setName(e.target.value)} + placeholder='Enter your Name' + type='text' + className='form-control border border-0 rounded-0' + id='exampleInputName' + required + autoFocus + /> +
+
+ setEmail(e.target.value)} + placeholder='Enter your Email' + type='email' + className='form-control border border-0 rounded-0' + id='exampleInputEmail1' + required + aria-describedby='emailHelp' + autoFocus + /> +
+ +
+ setPassword(e.target.value)} + placeholder='Enter your Password' + type='password' + required + className='form-control border border-0 rounded-0' + id='exampleInputPassword1' + /> +
+ + + + + Already have an account? + navigate('/login')} + > + Sign In + + +
+
+
+ ) +} + +export default Register diff --git a/src/containers/Header.jsx b/src/containers/Header.jsx new file mode 100644 index 00000000..a9cad8de --- /dev/null +++ b/src/containers/Header.jsx @@ -0,0 +1,55 @@ +import React from 'react' +import { NavLink, Link } from 'react-router-dom'; + +const Header = () => { + + return ( +
+ + + + +
+ ) +} + +export default Header diff --git a/src/containers/HomePage.jsx b/src/containers/HomePage.jsx new file mode 100644 index 00000000..a9871e01 --- /dev/null +++ b/src/containers/HomePage.jsx @@ -0,0 +1,14 @@ +import React from 'react' +import Layout from '../Layout/Layout' + +const HomePage = () => { + return ( +
+ +

Welcome to LeetCode

+
+
+ ) +} + +export default HomePage diff --git a/src/containers/Pagenotfound.jsx b/src/containers/Pagenotfound.jsx new file mode 100644 index 00000000..d5259df2 --- /dev/null +++ b/src/containers/Pagenotfound.jsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { Link } from 'react-router-dom'; +import Layout from '../Layout/Layout' + + +const Pagenotfound = () => { + return ( + +
+

404

+

Oops ! Page not found..

+ + Go Back + +
+
+ ); +}; + +export default Pagenotfound; diff --git a/src/index.css b/src/index.css index e69de29b..31f5b851 100644 --- a/src/index.css +++ b/src/index.css @@ -0,0 +1,15 @@ +.footer { + color: white; + padding: 11px; + background: #000; + background: -webkit-linear-gradient(to right, #4343, #000); + background: linear-gradient(to right, #434343, #000); +} + +.cursor-pointer { + cursor: pointer; +} + +.text-small { + font-size: smaller; +} diff --git a/src/main.jsx b/src/main.jsx index 5cc59919..7ce3c4dd 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -2,9 +2,10 @@ import React from 'react' import ReactDOM from 'react-dom/client' import App from './App' import './index.css' +import { BrowserRouter } from 'react-router-dom' ReactDOM.createRoot(document.getElementById('root')).render( - + - , + , ) From 32d99d1a2de232c98a2b4b4d40ac976bf8685443 Mon Sep 17 00:00:00 2001 From: Sree Sree Date: Sat, 20 May 2023 13:15:07 +0530 Subject: [PATCH 2/2] added problems --- README.md | 34 ++++- index.html | 2 +- src/App.css | 42 ------ src/App.jsx | 7 +- src/Layout/Footer.jsx | 8 +- src/Layout/Layout.jsx | 2 +- src/assets/react.svg | 1 - src/constants/Questions.jsx | 234 +++++++++++++++++++++++++++++++++ src/containers/AllProblems.jsx | 84 ++++++++++++ src/containers/Header.jsx | 53 +++++--- src/containers/HomePage.jsx | 12 +- src/containers/Problem.jsx | 158 ++++++++++++++++++++++ src/index.css | 12 +- 13 files changed, 572 insertions(+), 77 deletions(-) delete mode 100644 src/App.css delete mode 100644 src/assets/react.svg create mode 100644 src/constants/Questions.jsx create mode 100644 src/containers/AllProblems.jsx create mode 100644 src/containers/Problem.jsx diff --git a/README.md b/README.md index 83f3a207..0eabc906 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,28 @@ -## Full stack assignment +

Leetcode

+ +
    +
  1. Problem Repository: Browse and search a wide range of coding problems categorized by topics and difficulty levels.
  2. -### Video - -Link to video - https://www.youtube.com/watch?v=569YZm0X5-0 - -### Where to start? -Look at App.jsx inside the src/ folder +
+

Technologies Used

+ +

Getting Started

+
    +
  1. Clone the repository: git clone t
  2. +
  3. Navigate to the project directory: cd leetcode-clone
  4. +
  5. Install the dependencies: npm install
  6. + +
  7. Start the development server: npm start
  8. +
  9. Access the application in your browser at http://localhost:3000.
  10. +
+

Contributing

+

Contributions are welcome! If you would like to contribute to this project, please follow these steps:

+
    +
  1. Fork the repository.
  2. +
  3. Create a new branch: git checkout -b feature/your-feature
  4. +
  5. Make your changes and commit them: git commit -m 'Add your feature'
  6. +
  7. Push to the branch: git push origin feature/your-feature
  8. +
  9. Open a pull request and describe your changes.
  10. +
diff --git a/index.html b/index.html index 6d4e65f7..e064d9b1 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - Vite + React + LeetCode By Sree 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 a3b953d5..10f21a70 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -5,19 +5,20 @@ import Layout from './Layout/Layout'; import Login from './containers/Auth/Login'; import Pagenotfound from './containers/Pagenotfound'; import Register from './containers/Auth/Register'; +import AllProblems from './containers/AllProblems'; +import Problem from './containers/Problem'; const App = () => { return ( <> - } /> } /> } /> + } /> + } /> } /> - - ) } diff --git a/src/Layout/Footer.jsx b/src/Layout/Footer.jsx index e580b3f4..1d50e685 100644 --- a/src/Layout/Footer.jsx +++ b/src/Layout/Footer.jsx @@ -5,10 +5,10 @@ const Footer = () => { return (

All Right's Reserved © Sree

-

- About | - Contact | - Privacy Policy +

+ About | + Contact | + Privacy Policy

); diff --git a/src/Layout/Layout.jsx b/src/Layout/Layout.jsx index e2d2b8e3..3b25ce6d 100644 --- a/src/Layout/Layout.jsx +++ b/src/Layout/Layout.jsx @@ -6,7 +6,7 @@ import Header from '../containers/Header' const Layout = ({ children }) => { return (
-
+
{children}