Skip to content

Commit 0022054

Browse files
committed
application form created with navbar
1 parent 0dc7751 commit 0022054

File tree

10 files changed

+194
-41
lines changed

10 files changed

+194
-41
lines changed

react/reactapp/package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

react/reactapp/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"formik": "^2.2.9",
1010
"react": "^18.2.0",
1111
"react-dom": "^18.2.0",
12+
"react-icons": "^4.8.0",
1213
"react-router-dom": "^6.9.0",
1314
"react-scripts": "5.0.1",
1415
"web-vitals": "^2.1.4",

react/reactapp/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
To begin the development, run `npm start` or `yarn start`.
4141
To create a production bundle, use `npm run build` or `yarn build`.
4242
-->
43+
4344

4445
</body>
4546
</html>

react/reactapp/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ function App() {
3131
<Routes>
3232
<Route path="dashboard" element={<Dashboard />}>
3333
</Route>
34+
</Routes>
35+
<Routes>
3436
<Route path="application" element={<ApplicationForm />}>
3537
</Route>
3638
</Routes>

react/reactapp/src/App2.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// CREATE ROUTES FOR DASHBOARD INSIDE App.js
2+
3+
// import route
4+
// CREATE ROUTES FOR DASHBOARD INSIDE App.js
5+
import React from 'react';
6+
// import route
7+
import {BrowserRouter, Routes, Route} from 'react-router-dom';
8+
import logo from './logo.svg';
9+
import './App.css';
10+
import Login from './components/login/Login'; // Login component from components
11+
import Dashboard from './components/Dashboard/Dashboard' // import Dashboard component
12+
import UseToken from './components/useToken';
13+
import ApplicationForm from './components/Dashboard/ApplicationForm'
14+
import Navbar from './components/Header/Navbar'
15+
16+
17+
18+
/* Add BrowserRouter, then add a Routes component as a child
19+
in the return method
20+
inside of Switch, add a Route with a path for each component
21+
that used to route to the endpoints
22+
*/
23+
/* you can modify the following component */
24+
25+
function App() {
26+
27+
28+
return (
29+
<>
30+
<Navbar />
31+
<div className="container">
32+
33+
<BrowserRouter>
34+
<Routes>
35+
<Route path="/" element={<ApplicationForm />}>
36+
</Route>
37+
</Routes>
38+
<Routes>
39+
<Route path="/application" element={<ApplicationForm />}>
40+
</Route>
41+
</Routes>
42+
</BrowserRouter>
43+
</div>
44+
</>
45+
);
46+
}
47+
48+
export default App;

react/reactapp/src/components/Dashboard/ApplicationForm.js

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,33 @@
1+
12
// create student registration form component
2-
import './form-style.css';
33
import React from 'react';
4-
/*
5-
INSTALL: npm install formik
6-
- Formik is the world's most popular open source form library for React and React Native
7-
- then, import the module
8-
*/
9-
import { Formik, Form, Field, ErrorMessage } from 'formik';
10-
11-
/*
12-
INSTALL: npm install yup
13-
14-
- Yup is a schema builder for runtime value parsing and validation.
15-
- Define a schema, transform a value to match, assert the shape of an existing value, or both.
16-
- Yup schema are extremely expressive and allow modeling complex,
17-
interdependent validations, or value transformation
4+
import './formStyle.css';
185

19-
*/
20-
import * as Yup from 'yup';
216

227
function ApplicationForm(){
238

24-
// validate the form values before submitting
25-
const validationSchema = Yup.object().shape({
26-
fname: Yup.string().required('Enter First Name'),
27-
lname: Yup.string().required('Enter Last Name'),
28-
phone: Yup.
29-
email: Yup.string()
30-
.email('You have entered an invalid email address')
31-
.required('Required')
32-
33-
})
34-
359
// return the form layout
3610
return (
3711
<div class="form-container">
3812
<div class="title">Application Form</div>
39-
<Formik {...props} validationSchema = {validationSchema}>
4013
<form >
4114
<div class="user__details">
4215
<div class="input__box">
4316
<span class="details">First Name</span>
4417
<input type="text" name='fname' placeholder="E.g: Asibeh" required />
45-
<ErrorMessage name='fname' className='d-block invalid-feedback' component='span' />
4618
</div>
4719
<div class="input__box">
4820
<span class="details">Last Name</span>
4921
<input type="text" name='lname' placeholder="E.g: Tenager" required />
50-
<ErrorMessage name='lname' className='d-block invalid-feedback' component='span' />
5122
</div>
5223

5324
<div class="input__box">
5425
<span class="details">Email</span>
5526
<input type="email" name='email' placeholder="asibeh@gmail.com" required />
56-
<ErrorMessage name='email' className='d-block invalid-feedback' component='span' />
5727
</div>
5828
<div class="input__box">
5929
<span class="details">Phone Number</span>
6030
<input type="tel" name='phone' pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" placeholder="092-345-6787" required />
61-
<ErrorMessage name='phone' className='d-block invalid-feedback' component='span' />
6231
</div>
6332
</div>
6433
<div class="gender__details">
@@ -78,13 +47,9 @@ function ApplicationForm(){
7847
</div>
7948
</div>
8049
<div class="button">
81-
<button variant='danger' size='lg'
82-
block='block' type="submit" value="Apply" >
83-
{props.children}
84-
</button>
50+
<input type="submit" value="Apply" />
8551
</div>
8652
</form>
87-
</Formik>
8853
</div>
8954
);
9055
}

react/reactapp/src/components/Dashboard/form-style.css renamed to react/reactapp/src/components/Dashboard/formStyle.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ form .button input:hover {
140140
@media only screen and (max-width: 584px) {
141141
.form-container {
142142
max-width: 100%;
143+
height: 90%;
144+
margin-top: 35%;
145+
margin-bottom: 25%;
143146
}
144147

145148
form .user__details .input__box {
@@ -159,4 +162,5 @@ form .button input:hover {
159162
.user__details::-webkit-scrollbar {
160163
width: 0;
161164
}
165+
162166
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// navigation bar defined below
2+
// you are not required to install additional library
3+
// just checkout the css file in nav.css and modify the layout
4+
5+
import React, {useState, useEffect} from 'react'
6+
import { BrowserRouter, NavLink } from "react-router-dom";
7+
import './nav.css'
8+
9+
export default function Navbar() {
10+
const [toggleMenu, setToggleMenu] = useState(false)
11+
const [screenWidth, setScreenWidth] = useState(window.innerWidth)
12+
13+
useEffect(() =>{
14+
document.title = 'Sage Application'
15+
})
16+
const toggleNav = () => {
17+
setToggleMenu(!toggleMenu)
18+
}
19+
20+
useEffect(() => {
21+
22+
const changeWidth = () => {
23+
setScreenWidth(window.innerWidth);
24+
}
25+
26+
window.addEventListener('resize', changeWidth)
27+
28+
return () => {
29+
window.removeEventListener('resize', changeWidth)
30+
}
31+
32+
}, [])
33+
34+
return (
35+
36+
<nav>
37+
{(toggleMenu || screenWidth > 500) && (
38+
<ul className="list">
39+
<BrowserRouter>
40+
<NavLink to='/application'>
41+
<li className="items">Application</li>
42+
</NavLink>
43+
</BrowserRouter>
44+
45+
<li className="items">List Applicants</li>
46+
</ul>
47+
)}
48+
49+
<button onClick={toggleNav} className="btn">=</button>
50+
</nav>
51+
)
52+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
nav {
2+
position: fixed;
3+
top: 0;
4+
width: 100%;
5+
height: 50px;
6+
background: linear-gradient(45deg, #282c34, #282c34);
7+
float: right;
8+
}
9+
10+
11+
.list {
12+
list-style-type: none;
13+
background: linear-gradient(45deg, #282c34, #282c34);
14+
height: 100%;
15+
display: flex;
16+
justify-content: center;
17+
align-items: center;
18+
position: relative;
19+
}
20+
.items {
21+
margin-right: 20px;
22+
font-size: 20px;
23+
text-transform: uppercase;
24+
color: #f1f1f1;
25+
cursor: pointer;
26+
float: right;
27+
}
28+
29+
.btn {
30+
display: none;
31+
position: absolute;
32+
right: 5px;
33+
top: 1px;
34+
padding: 4px;
35+
color: #fff;
36+
font-size: 18px;
37+
float: right;
38+
}
39+
40+
41+
@media screen and (max-width: 500px){
42+
43+
.list {
44+
flex-direction: column;
45+
height: auto;
46+
}
47+
.items:nth-child(1){
48+
border-top: 1px solid rgba(255, 255, 255, 0.555);
49+
margin-top: 50px;
50+
}
51+
.items {
52+
width: 100%;
53+
border-top: 1px solid rgba(255, 255, 255, 0.555);
54+
text-align: center;
55+
margin-right: 0px;
56+
padding: 20px 0;
57+
}
58+
.btn {
59+
display: block;
60+
float: right;
61+
width: 10%;
62+
63+
}
64+
65+
}

react/reactapp/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import ReactDOM from 'react-dom/client';
33
import './index.css';
44
// import required css file
55
import './bmi.css';
6-
import App from './App';
6+
import App from './App2';
77
import AjaxApi from './AjaxApi';
8+
import ApplicationForm from './components/Dashboard/ApplicationForm'
89
// import your newly created function component here
910
import BmiCalculator from './Bmi';
1011

11-
import Login from './components/login/Login'; // Login component from components
12-
1312
import reportWebVitals from './reportWebVitals';
1413

1514
const root = ReactDOM.createRoot(document.getElementById('root'));
@@ -18,6 +17,7 @@ root.render(
1817
<React.StrictMode>
1918
<App />
2019

20+
2121
</React.StrictMode>
2222
);
2323

0 commit comments

Comments
 (0)