Skip to content

Commit

Permalink
Add scrolling photo bar (#9) (#10)
Browse files Browse the repository at this point in the history
* Add scrolling photo bar (#9)

* add static photobar component with development placeholders

* add scrolling animation (currently hardcoded duration and rotation)

* increase gap between photos; add classes for slight left/right rotations

* remove margins for h3

* remove absolute positioning

* add header for photo bar; make photos hyperlinks; import and loop over people for photos

* add inline styling to dynamically adjust animation length based on number of people

* rename timePerPerson to secondsPerPerson

* remove margins for text elements; standardize photo width/height; change animation timing function to linear; position photo bar above footer

* add photo bar

* adjust padding values

* add people data file for photo bar

---------

Co-authored-by: Darin <[email protected]>

* slow down animation

---------

Co-authored-by: dweber2022 <[email protected]>
Co-authored-by: Darin <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2024
1 parent 082f879 commit f4cce22
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Header } from "./components/Header/Header.tsx";
import { PhotoBar } from "./components/PhotoBar/PhotoBar.tsx";
import { Footer } from "./components/Footer/Footer.tsx";
import { Navigation } from "./components/Navigation/Navigation.tsx";
import { SampleSection } from "./components/Sections/SampleSection.tsx";
Expand All @@ -13,6 +14,7 @@ export const App = () => {
{/* sections can go here */}
<SampleSection />

<PhotoBar />
<Footer />
</MainWrapper>
);
Expand Down
4 changes: 0 additions & 4 deletions src/components/Footer/Footer.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
@use "../../shared/colors";

#footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
Expand Down
47 changes: 47 additions & 0 deletions src/components/PhotoBar/People.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export interface IPerson {
name: string;
position: string;
img: string; // images should have square dimensions
link?: string;
}

const People: ReadonlyArray<IPerson> = [
{
name: "Branden Ghena",
position: "Professor",
img: "https://www.mccormick.northwestern.edu/images/research-and-faculty/directory/ghena-branden.jpg",
link: "https://brandenghena.com/",
},
{
name: "FirstName LastName",
position: "Placeholder",
img: "https://www.thispersondoesnotexist.com",
},
{
name: "FirstName LastName",
position: "Placeholder",
img: "https://www.thispersondoesnotexist.com",
},
{
name: "FirstName LastName",
position: "Placeholder",
img: "https://www.thispersondoesnotexist.com",
},
{
name: "FirstName LastName",
position: "Placeholder",
img: "https://www.thispersondoesnotexist.com",
},
{
name: "FirstName LastName",
position: "Placeholder",
img: "https://www.thispersondoesnotexist.com",
},
{
name: "FirstName LastName",
position: "Placeholder",
img: "https://www.thispersondoesnotexist.com",
},
];

export default People;
76 changes: 76 additions & 0 deletions src/components/PhotoBar/PhotoBar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@use "../../shared/colors";

#photobar {
margin-top: auto;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;

h2 {
margin: 0rem;
text-align: center;
}

.photobar__animation {
animation-name: scroll-left;
animation-timing-function: linear;
animation-iteration-count: infinite;
display: flex;
flex-direction: row;
gap: 4rem;
justify-content: space-evenly;
align-items: center;
padding: 4rem 0rem;
width: max-content;

a {
color: colors.$global-very-dark-green;
}

.photobar__flexbox {
display: flex;
flex-direction: column;
flex-shrink: 0;
align-items: center;
background-color: colors.$global-light;
padding: 1rem;
width: 12rem;

.photobar__image {
img {
width: 100%;
height: 100%;
}
}

h3 {
font-size: 1rem;
text-align: center;
margin: 0rem;
}

p {
text-align: center;
margin: 0rem;
}
}

.photobar__rotate_right {
transform: rotate(5deg);
}

.photobar__rotate_left {
transform: rotate(-5deg);
}
}
}

@keyframes scroll-left {
from {
transform: translateX(100vw);
}
to {
transform: translateX(-100%);
}
}
40 changes: 40 additions & 0 deletions src/components/PhotoBar/PhotoBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import "./PhotoBar.scss";
import { IPerson } from "./People";
import People from "./People";

interface IPhotoBar {}

export const PhotoBar: React.FC<IPhotoBar> = () => {
const secondsPerPerson = 5;
return (
<div id="photobar">
<h2>Meet our Team</h2>
<div
className="photobar__animation"
style={{
animationDuration: `${(People.length * secondsPerPerson).toString()}s`,
}}
>
{People.map((person: IPerson, i) => (
<a
href={person.link ? person.link : "javascript:void(0);"}
rel="noreferrer"
>
<div
key={i}
className={`photobar__flexbox ${i % 2 === 0 ? "photobar__rotate_right" : "photobar__rotate_left"}`}
>
<div className="photobar__image">
<img className="photo" src={person.img} />
</div>
<h3>{person.name}</h3>
<p>{person.position}</p>
</div>
</a>
))}
</div>
</div>
);
};

export default PhotoBar;

0 comments on commit f4cce22

Please sign in to comment.