Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Frontend navbar finished maybe? (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yousef-Taha1 authored Jun 10, 2024
1 parent d84ce58 commit 0390054
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 71 deletions.
42 changes: 42 additions & 0 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-oidc-context": "^3.1.0",
"react-router-dom": "^6.23.1",
"reactjs-popup": "^2.0.6"
},
"devDependencies": {
Expand Down
26 changes: 5 additions & 21 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ function App() {
if (auth.isAuthenticated) {
return (
<div style={{ backgroundColor: '#F5F5DC'}}>
<div>
<div><Navbar /> </div>
{/*
<h1 >WELCOME TO TEAMAGOCHI GANG</h1>
<h1 className='font-extrabold text-9xl' >
<a href="https://www.youtube.com/watch?v=sf0PJsknZiM">CARTI </a>
Expand All @@ -41,28 +43,10 @@ function App() {
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} />
</div>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}[]
</button>
<button onClick={() => void auth.removeUser()}>Log out</button>
<img src={"./android-chrome-384x384.png"} alt="Logo" style={{ width: '384px', height: '384px', marginLeft: '5px' }} /> */}
</div>
<p className="read-the-docs">
Hello
</p>
<div>Hello {auth.user?.profile.sub}</div>

<div>Hello {auth.user?.profile?.preferred_username || 'User'}</div>
</div>
);
}
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/Components/Friends.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

const Friends = () => (
<div>
<h1>Friends Page</h1>
<p>Welcome to the Friends Page!</p>
</div>
);

export default Friends;
10 changes: 10 additions & 0 deletions frontend/src/Components/Inventory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

const Inventory = () => (
<div>
<h1>Inventory Page</h1>
<p>Welcome to the Inventory Page!</p>
</div>
);

export default Inventory;
106 changes: 56 additions & 50 deletions frontend/src/Components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,75 +1,81 @@
import React, { useState } from "react";
import {BrowserRouter as Router, Link, Route, Routes} from "react-router-dom";
import Inventory from '../Inventory.tsx';
import Settings from '../Settings.tsx';
import Friends from '../Friends.tsx';
import PetPage from '../PetPage.tsx';
import { useAuth } from "react-oidc-context";
import './navbar.css';

const Navbar = () =>{
const Navbar = () => {
const auth = useAuth();
const [activePage, setActivePage] = useState("Pet Page");

const loginButtonStyles = {
color: '#fff', // White text color
backgroundColor: '#006400',
fontWeight: 'bold', // Bold font weight
// Add any other custom styles as needed
color: '#fff',
backgroundColor: '#006400',
fontWeight: 'bold',
};

const navbarItemStyles = {
marginRight: '20px', // Adjust the margin between navbar items
marginRight: '20px',
};

const handlePageClick = (page) => {
setActivePage(page);
};

return (
<div>
<nav className="navbar navbar-expand-lg navbar-dark bg-success">
<img src={"./android-chrome-192x192.png"} alt="Logo" style={{ width: '30px', height: '30px', marginLeft: '5px' }} />
<a className="navbar-brand" href="#"> TEAMAGOCHI</a>
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<div>
<Router>
<nav className="navbar navbar-expand-lg navbar-dark bg-success">
<img src={"./android-chrome-192x192.png"} alt="Logo" style={{ width: '30px', height: '30px', marginLeft: '5px' }} />
<a className="navbar-brand" href="#">TEAMAGOCHI</a>
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>

<div className="collapse navbar-collapse flex-row-reverse" id="navbarSupportedContent" style={navbarItemStyles}>
<ul className="navbar-nav ">
<li className={`nav-item ${activePage === 'Pet Page' ? 'active' : ''}`}>
<a className="nav-link" href="#" style={navbarItemStyles} onClick={() => handlePageClick('Pet Page')}>Pet Page</a>
</li>
<li className={`nav-item ${activePage === 'Inventory' ? 'active' : ''}`}>
<a className="nav-link" href="#" style={navbarItemStyles} onClick={() => handlePageClick('Inventory')}>Inventory</a>
</li>
<li className={`nav-item ${activePage === 'Friends' ? 'active' : ''}`}>
<a className="nav-link" href="#" style={navbarItemStyles} onClick={() => handlePageClick('Friends')}>Friends</a>
</li>
<li className={`nav-item ${activePage === 'Settings' ? 'active' : ''}`}>
<a className="nav-link" href="#" style={navbarItemStyles} onClick={() => handlePageClick('Settings')}>Settings</a>
</li>
{/* <li className="nav-item dropdown" style={navbarItemStyles}>
<a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style={navbarItemStyles}>
Settings
</a>
<div className="dropdown-menu" aria-labelledby="navbarDropdown">
<a className="dropdown-item" href="#">Action</a>
<a className="dropdown-item" href="#">Another action</a>
<div className="dropdown-divider"></div>
<a className="dropdown-item" href="#">Something else here</a>
<div className="collapse navbar-collapse flex-row-reverse" id="navbarSupportedContent" style={navbarItemStyles}>
<ul className="navbar-nav">
{auth.isAuthenticated ? (
<>
<li className={`nav-item ${activePage === 'Pet Page' ? 'active' : ''}`}>
<Link className="nav-link" to="/PetPage" style={navbarItemStyles} onClick={() => handlePageClick('Pet Page')}>Pet Page</Link>
</li>
<li className={`nav-item ${activePage === 'Inventory' ? 'active' : ''}`}>
<Link className="nav-link" to="/inventory" style={navbarItemStyles} onClick={() => handlePageClick('Inventory')}>Inventory</Link>
</li>
<li className={`nav-item ${activePage === 'Friends' ? 'active' : ''}`}>
<Link className="nav-link" to="/Friends" style={navbarItemStyles} onClick={() => handlePageClick('Friends')}>Friends</Link>
</li>
<li className={`nav-item ${activePage === 'Settings' ? 'active' : ''}`}>
<Link className="nav-link" to="/Settings" style={navbarItemStyles} onClick={() => handlePageClick('Settings')}>Settings</Link>
</li>
<li className="navbar-item">
<button className="nav-link" onClick={() => auth.removeUser()} style={loginButtonStyles}>Log out</button>
</li>
</>
) : (
<li className="navbar-item">
<a className="nav-link" href="#" onClick={() => auth.signinRedirect()} style={loginButtonStyles}>Log in</a>
</li>
)}
</ul>
</div>
</li> */}
{auth.isAuthenticated ? (
<li className="navbar-item">
<button className="nav-link" onClick={() => auth.removeUser()} style={loginButtonStyles}>Log out</button>
</li>
) : (
<li className="navbar-item">
<a className="nav-link" href="#" onClick={() => auth.signinRedirect()} style={loginButtonStyles}>Log in</a>
</li>
)}

</ul>
</div>
</nav>
</nav>
<Routes>
<Route path="/inventory" element={<Inventory />} />
<Route path="/Settings" element={<Settings />} />
<Route path="/Friends" element={<Friends />} />
<Route path="/PetPage" element={<PetPage />} />
</Routes>
</Router>
</div>
)
}

<<<<<<< HEAD
export default Navbar;
=======
export default Navbar
>>>>>>> d84ce58873962e255ae93e1ec5fcd937a2e765f9
10 changes: 10 additions & 0 deletions frontend/src/Components/PetPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

const PetPage = () => (
<div>
<h1>Pet Page</h1>
<p>Welcome to the Pet Page!</p>
</div>
);

export default PetPage;
Empty file.

0 comments on commit 0390054

Please sign in to comment.