Skip to content

Commit

Permalink
Change backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-karlsson committed Mar 26, 2024
1 parent 82e3875 commit d17c067
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
Binary file added client/public/images/backgrounds/zoomed-in.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed client/public/images/council-background-test.png
Binary file not shown.
Binary file removed client/public/images/council-background.jpg
Binary file not shown.
22 changes: 18 additions & 4 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "./App.css";
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import Overlay from "./components/Overlay";
import Landing from "./components/Landing";
import Welcome from "./components/Welcome";
Expand All @@ -15,7 +15,7 @@ function App() {
const pages = ["landing", "welcome", "topics", "foods", "council"];
const [currentView, setCurrentView] = useState(pages[0]);
const [backgroundImageURL, setBackgroundImageURL] = useState(
"/images/welcome-background.jpg"
"/images/backgrounds/zoomed-out.jpg"
);

const backgroundStyle = {
Expand All @@ -26,9 +26,18 @@ function App() {
width: "100vw",
};

const isActive = currentView !== "council";
const isActiveOverlay = currentView !== "council";

useEffect(() => {
if (currentView === pages[0]) {
setBackgroundImageURL("/images/backgrounds/zoomed-out.jpeg");
} else {
setBackgroundImageURL("/images/backgrounds/zoomed-in.jpeg");
}
}, [currentView]);

function continueForward(props) {
// Set properties
if (props && props.hasOwnProperty("humanName")) {
setHumanName(props.humanName);
} else if (props && props.hasOwnProperty("topic")) {
Expand All @@ -37,8 +46,13 @@ function App() {
setFoods(props.foods);
}

// Update index

const currentIndex = pages.indexOf(currentView);
const nextIndex = (currentIndex + 1) % pages.length; // Use modulus to cycle back to the start

// Set new view

setCurrentView(pages[nextIndex]);
}

Expand All @@ -47,7 +61,7 @@ function App() {

return (
<div className="App" style={backgroundStyle}>
<Overlay isActive={isActive}>
<Overlay isActive={isActiveOverlay}>
{currentView === pages[0] ? (
<Landing onContinueForward={continueForward} />
) : currentView === pages[1] ? (
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { capitalizeFirstLetter } from "../utils";

function Navbar({ topic }) {
const navbarStyle = {
Expand Down Expand Up @@ -32,7 +33,7 @@ function Navbar({ topic }) {
COUNCIL OF FOODS
</a>
</h3>
<h4>{topic}</h4>
<h4>{capitalizeFirstLetter(topic)}</h4>
</div>
<div style={{ display: "flex" }}>
<h3 style={navbarItemStyle}>
Expand Down

0 comments on commit d17c067

Please sign in to comment.