Skip to content

Commit

Permalink
Merge pull request #17 from ubccsss/shiyu_branch
Browse files Browse the repository at this point in the history
Navbar
  • Loading branch information
sl-81 authored Mar 6, 2024
2 parents fd1f4ea + 4d28028 commit 2f164f2
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 25 deletions.
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
41 changes: 40 additions & 1 deletion frontend/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 frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.2"
},
"devDependencies": {
"@types/react": "^18.2.43",
Expand Down
2 changes: 1 addition & 1 deletion frontend/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
autoprefixer: {}
},
}
120 changes: 112 additions & 8 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,114 @@
import './index.css'
function App() {

import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import "./index.css";
import Navbar from "./components/Navbar";
import ShoppingList from "./components/ShoppingList";
const App = () => {
return (
<>
</>
)
}
<Router>
<Routes>
<Route path="/" element={<ShoppingList />} />
<Route
path="/store"
element={
<Navbar
title="Login"
needbuttons={true}
isofficerpage={false}
needtitle={true}
/>
}
/>
<Route
path="/officer"
element={
<Navbar
title="Login"
needbuttons={false}
isofficerpage={true}
needtitle={true}
/>
}
/>
<Route
path="/officer/mainmenu"
element={
<Navbar
title="Login"
needbuttons={true}
isofficerpage={true}
needtitle={true}
/>
}
/>
<Route
path="/officer/itemdetail/:id"
element={
<Navbar
title="Login"
needbuttons={true}
isofficerpage={true}
needtitle={true}
/>
}
/>
<Route
path="/officer/reimburse"
element={
<Navbar
title="Login"
needbuttons={true}
isofficerpage={true}
needtitle={true}
/>
}
/>
<Route
path="/officer/inventory"
element={
<Navbar
title="Login"
needbuttons={true}
isofficerpage={true}
needtitle={true}
/>
}
/>
<Route
path="/officer/shoppinglist"
element={
<Navbar
title="Login"
needbuttons={true}
isofficerpage={true}
needtitle={true}
/>
}
/>
<Route
path="/officer/additem"
element={
<Navbar
title="Login"
needbuttons={true}
isofficerpage={true}
needtitle={true}
/>
}
/>
<Route
path="/officer/transaction"
element={
<Navbar
title="Login"
needbuttons={true}
isofficerpage={true}
needtitle={true}
/>
}
/>
</Routes>
</Router>
);
};

export default App
export default App;
45 changes: 45 additions & 0 deletions frontend/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import "../index.css";
import { Link } from "react-router-dom";
interface NavbarProps {
title: string;
needbuttons: boolean;
isofficerpage: boolean;
needtitle: boolean;
}

const Navbar = ({
title,
needbuttons,
isofficerpage,
needtitle,
}: NavbarProps) => {
return (
<div className={isofficerpage ? "darkmode" : "lightmode"}>
{needbuttons && (
<div className="flex justify-end right-4 p-4 text-black-700">
<Link to="/officer/mainmenu" className="btn-o mr-4">
Back to Main
</Link>

<Link to="/officer" className="btn-o">
Logout
</Link>
</div>
)}
{needtitle && (
<div className="relative top-15 text-center text-6xl ">
{title}
<hr
className={
isofficerpage
? "h-px my-6 bg-white border-1 w-4/5 mx-auto"
: "h-px my-6 bg-black border-1 w-4/5 mx-auto"
}
/>
</div>
)}
</div>
);
};

export default Navbar;
17 changes: 17 additions & 0 deletions frontend/src/components/ShoppingList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import "../index.css";
import Navbar from "./Navbar";
const ShoppingList = () => {
return (
<div className="lightmode min-h-screen">
<Navbar
title="Shopping List"
needbuttons={true}
isofficerpage={false}
needtitle={true}
/>
<div className="text-white">hello!!</div>
</div>
);
};

export default ShoppingList;
18 changes: 17 additions & 1 deletion frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind utilities;

.btn-o {
@apply w-40 h-10 bg-[#D9C4E3] rounded-[5px] text-xl text-black flex items-center justify-center;
}

.btn-c {
@apply w-40 h-10 bg-[#4991BA] rounded-[5px] text-xl text-white flex items-center justify-center;
}

.darkmode {
@apply bg-zinc-800 text-white;
}

.lightmode {
@apply bg-white text-black;
}
14 changes: 7 additions & 7 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./index.css";

ReactDOM.createRoot(document.getElementById('root')!).render(
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
</React.StrictMode>
);
8 changes: 2 additions & 6 deletions frontend/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
}

};

0 comments on commit 2f164f2

Please sign in to comment.