Skip to content

Commit

Permalink
Update navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-karlsson committed Mar 27, 2024
1 parent f7933e7 commit f84233e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
23 changes: 13 additions & 10 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function App() {
const [foods, setFoods] = useState([]);
const pages = ["landing", "welcome", "topics", "foods", "council"];
const [currentView, setCurrentView] = useState(pages[0]);
const [isOverlayActive, setIsOverlayActive] = useState(true);
const [backgroundImageURL, setBackgroundImageURL] = useState(
"/images/backgrounds/zoomed-out.jpg"
);
Expand All @@ -26,8 +27,6 @@ function App() {
width: "100vw",
};

const isActiveOverlay = currentView !== "council";

useEffect(() => {
if (currentView === pages[0]) {
setBackgroundImageURL("/images/backgrounds/zoomed-out.jpeg");
Expand All @@ -53,30 +52,34 @@ function App() {

// Set new view

if (pages[nextIndex] == "council") {
toggleOverlay();
}

setCurrentView(pages[nextIndex]);
}

// Placeholder for goBack function implementation
function goBack() {}

function showOverlay(page) {
console.log(page);
function toggleOverlay() {
setIsOverlayActive(!isOverlayActive);
}

return (
<div className="App" style={backgroundStyle}>
<Overlay isActive={isActiveOverlay}>
{currentView === pages[0] ? (
<Overlay isActive={isOverlayActive && currentView !== "council"}>
{currentView === "landing" ? (
<Landing onContinueForward={continueForward} />
) : currentView === pages[1] ? (
) : currentView === "welcome" ? (
<Welcome humanName={humanName} onContinueForward={continueForward} />
) : currentView === pages[2] ? (
) : currentView === "topics" ? (
<Topics onContinueForward={continueForward} />
) : currentView === pages[3] ? (
) : currentView === "foods" ? (
<Foods topic={topic} onContinueForward={continueForward} />
) : (
<div>
<Navbar topic={topic} onShowOverlay={showOverlay} />
<Navbar topic={topic} onToggleOverlay={toggleOverlay} />
<Council options={{ humanName, topic, foods }} />
</div>
)}
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { capitalizeFirstLetter } from "../utils";

function Navbar({ topic, onShowOverlay }) {
function Navbar({ topic, onToggleOverlay }) {
const navbarStyle = {
paddingTop: "10px",
display: "flex",
Expand Down Expand Up @@ -40,7 +40,7 @@ function Navbar({ topic, onShowOverlay }) {
<a
className="link"
href="#"
onClick={() => onShowOverlay("about")}
onClick={() => onToggleOverlay("about")}
style={linkItemStyle}
>
ABOUT
Expand All @@ -50,7 +50,7 @@ function Navbar({ topic, onShowOverlay }) {
<a
className="link"
href="#"
onClick={() => onShowOverlay("settings")}
onClick={() => onToggleOverlay("settings")}
style={linkItemStyle}
>
SETTINGS
Expand All @@ -60,7 +60,7 @@ function Navbar({ topic, onShowOverlay }) {
<a
className="link"
href="#"
onClick={() => onShowOverlay("contact")}
onClick={() => onToggleOverlay("contact")}
style={linkItemStyle}
>
CONTACT
Expand All @@ -70,7 +70,7 @@ function Navbar({ topic, onShowOverlay }) {
<a
className="link"
href="#"
onClick={() => onShowOverlay("share")}
onClick={() => onToggleOverlay("share")}
style={linkItemStyle}
>
SHARE
Expand Down

0 comments on commit f84233e

Please sign in to comment.