-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from ChangePlusPlusVandy/APP-102
Adding picture rotunda
- Loading branch information
Showing
13 changed files
with
322 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
63 changes: 63 additions & 0 deletions
63
src/pages/DashboardPage/components/Rotunda/Rotunda.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.rotundaContainer { | ||
position: relative; | ||
width: 100%; | ||
overflow: hidden; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.imageContainer { | ||
display: flex; | ||
overflow-x: hidden; | ||
white-space: nowrap; | ||
transition: scroll-left 1s ease-in-out; /* Smoother transition for scrolling */ | ||
} | ||
|
||
.rotundaImage { | ||
width: 320px; | ||
height: 180px; | ||
flex-shrink: 0; | ||
margin-right: 10px; | ||
transition: transform 0.3s ease; | ||
} | ||
|
||
.rotundaImage:hover { | ||
transform: scale(1.05); | ||
} | ||
|
||
.arrow { | ||
position: absolute; | ||
height: 100%; | ||
display: flex; /* Enable flexbox */ | ||
align-items: center; /* Center content vertically */ | ||
justify-content: center; /* Center content horizontally */ | ||
background-color: #fff; | ||
border: none; | ||
color: var(--miracle-color-blue); | ||
cursor: pointer; | ||
font-size: 24px; | ||
padding: 10px; | ||
z-index: 100; | ||
opacity: 0; | ||
transition: opacity 0.3s ease; | ||
} | ||
|
||
.arrow:hover { | ||
opacity: 1; | ||
} | ||
|
||
.Icon { | ||
font-size: 24px; | ||
top: 50%; | ||
} | ||
|
||
.arrow.left { | ||
background: linear-gradient(to left, rgba(255, 255, 255, 0), #fff); | ||
padding-right: 50px; | ||
} | ||
|
||
.arrow.right { | ||
right: 0px; | ||
background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff); | ||
padding-left: 50px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import styles from "./Rotunda.module.css"; | ||
import Icon from "../../../../components/CustomIcon/Icon"; | ||
import React, { useEffect, useRef, useState } from "react"; | ||
|
||
type RotundaProps = { | ||
images: string[]; | ||
}; | ||
|
||
const Rotunda: React.FC<RotundaProps> = ({ images }) => { | ||
const scrollRef = useRef<HTMLDivElement>(null); | ||
const [intervalId, setIntervalId] = useState<number | null>(null); | ||
const [scrollPosition, setScrollPosition] = useState(0); // State to track scroll position | ||
|
||
const scrollAmount = 330; // Image width + margin | ||
const totalWidth = scrollAmount * images.length; // Total width of one full set of images | ||
|
||
const scroll = () => { | ||
if (scrollRef.current) { | ||
const scrollElement = scrollRef.current; | ||
scrollElement.scrollLeft += scrollAmount; | ||
updateScrollPosition(scrollElement.scrollLeft); | ||
if (scrollElement.scrollLeft >= totalWidth) { | ||
scrollElement.scrollLeft -= totalWidth; | ||
updateScrollPosition(scrollElement.scrollLeft); | ||
} | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
const id = setInterval(scroll, 15000) as unknown as number; | ||
setIntervalId(id); | ||
return () => { | ||
clearInterval(id); | ||
if (scrollRef.current) { | ||
updateScrollPosition(scrollRef.current.scrollLeft); | ||
} | ||
}; | ||
}, []); | ||
|
||
const handleArrowClick = (direction: "left" | "right") => { | ||
if (scrollRef.current) { | ||
const scrollElement = scrollRef.current; | ||
if (direction === "right") { | ||
scrollElement.scrollLeft += scrollAmount; | ||
} else { | ||
scrollElement.scrollLeft -= scrollAmount; | ||
} | ||
updateScrollPosition(scrollElement.scrollLeft); | ||
if (scrollElement.scrollLeft >= totalWidth) { | ||
scrollElement.scrollLeft -= totalWidth; | ||
} else if (scrollElement.scrollLeft < 0) { | ||
scrollElement.scrollLeft += totalWidth; | ||
} | ||
updateScrollPosition(scrollElement.scrollLeft); | ||
} | ||
}; | ||
|
||
const updateScrollPosition = (position: number) => { | ||
setScrollPosition(position); | ||
}; | ||
|
||
const handleMouseEnter = () => { | ||
if (intervalId !== null) { | ||
clearInterval(intervalId); | ||
} | ||
}; | ||
const handleMouseLeave = () => { | ||
const id = setInterval(scroll, 15000) as unknown as number; | ||
setIntervalId(id); | ||
}; | ||
|
||
return ( | ||
<div className={styles.rotundaContainer}> | ||
{scrollPosition > 0 && ( | ||
<div | ||
className={`${styles.arrow} ${styles.left}`} | ||
onClick={() => handleArrowClick("left")} | ||
> | ||
<Icon glyph="arrow-left" /> | ||
</div> | ||
)} | ||
<div | ||
ref={scrollRef} | ||
className={styles.imageContainer} | ||
onMouseEnter={handleMouseEnter} | ||
onMouseLeave={handleMouseLeave} | ||
> | ||
{images.concat(images).map( | ||
( | ||
image, | ||
index, // Duplicate images for looping | ||
) => ( | ||
<img | ||
key={index} | ||
src={image} | ||
alt={`Slide ${index}`} | ||
className={styles.rotundaImage} | ||
/> | ||
), | ||
)} | ||
</div> | ||
<div | ||
className={`${styles.arrow} ${styles.right}`} | ||
onClick={() => handleArrowClick("right")} | ||
> | ||
<Icon glyph="arrow-right" /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Rotunda; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.