Skip to content

Commit

Permalink
Merge pull request #2 from erinwolff/navbar_branch
Browse files Browse the repository at this point in the history
Navbar branch
  • Loading branch information
WolffM authored Jan 30, 2024
2 parents 208b8fb + ad96cb9 commit facc61f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,15 @@
max-height: calc(90% - 1.2em);
margin-top: 5px; /* Adjust this if needed */
animation-delay: 1.5s; /* Starts fading in after 1.5s */
}

.Navbar {
display: flex;
justify-content: center;
}

.navButton {
width: 10em;
height: 3em;
margin: 1em;
}
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import './App.css';
import Navbar from './Navbar';

function App() {
const [images, setImages] = useState([]);
Expand All @@ -15,7 +16,7 @@ function App() {
let index = 1;

while (mounted) {
const imagePath = `./assets/${index}.png`;
const imagePath = process.env.PUBLIC_URL + '/assets/' + `${index}` + '.png';

try {
const response = await fetch(imagePath);
Expand Down Expand Up @@ -79,6 +80,7 @@ function App() {
) : (
<>
<h1 className="comic-title">Checkmate Productions</h1>
<Navbar images={images} setCurrentImageIndex={setCurrentImageIndex} currentImageIndex={currentImageIndex}/>
<div className="viewer-container">
<h2 className="comic-subtitle" key={subtitle}>{subtitle}</h2>
<img
Expand Down
21 changes: 21 additions & 0 deletions src/Navbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default function Navbar({setCurrentImageIndex, images, currentImageIndex}) {
const handlePreviousClick = () => {
if (currentImageIndex > 0) {
setCurrentImageIndex((prevIndex) => prevIndex - 1);
}
};

const handleNextClick = () => {
if (currentImageIndex < images.length - 1) {
setCurrentImageIndex((prevIndex) => prevIndex + 1);
}
};


return (
<div className="Navbar">
<button className="navButton" onClick={handlePreviousClick}>Previous</button>
<button className="navButton" onClick={handleNextClick}>Next</button>
</div>
)
}

0 comments on commit facc61f

Please sign in to comment.