Skip to content

Commit

Permalink
Merge pull request #38 from ChangePlusPlusVandy/APP-102
Browse files Browse the repository at this point in the history
Adding picture rotunda
  • Loading branch information
jacoblurie29 authored Apr 15, 2024
2 parents 0e107e3 + 08a1b90 commit e65760d
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 22 deletions.
59 changes: 54 additions & 5 deletions src/pages/DashboardPage/DashboardPage.module.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
.welcomeMessage {
.dashboardContainer {
display: flex;
flex-direction: column;
}

.CardsContainer {
display: flex;
flex-direction: row;
width: 100%;
justify-content: space-between;
gap: 1rem;
}

.dashboardTitle {
font-size: 2rem;
font-weight: 600;
}

/* make purple border around flightsToday */
.cardStyle {
flex-basis: 33.3333%;
display: flex;
justify-content: flex-end;
align-items: flex-start;
height: 100px;
background: transparent;
border-radius: 5px;
Expand All @@ -24,11 +35,49 @@
rgba(250, 251, 252, 1) 33%,
rgb(237, 242, 249) 100%
);
flex-basis: 33.33%;
}

.flightNumber {
font-size: 4rem;
font-family: Arial, Helvetica, sans-serif;
padding: 1rem 0;
color: var(--miracle-color-blue);
}

.dashboardContainer h4 {
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 1rem;
color: var(--miracle-color-blue);
}

.quickLinkContainer {
display: flex;
flex-direction: row;
justify-content: center;
gap: 1rem;
color: #888787;
background: rgb(250, 251, 252);
background: linear-gradient(
90deg,
rgba(250, 251, 252, 1) 33%,
rgb(237, 242, 249) 100%
);
flex-basis: 33.33%;
border-radius: 5px;
border: 1px solid #e1dede;
padding: 2rem 1rem;
transition: all 0.3s;
}

.quickLinkText {
font-size: 1.25rem;
font-weight: 600;
color: var(--miracle-color-blue);
}

.quickLinkContainer:hover {
border: 1px solid var(--miracle-color-blue);
cursor: pointer;
transform: scale(1.01);
}
92 changes: 76 additions & 16 deletions src/pages/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import styles from "./DashboardPage.module.css";
import Rotunda from "./components/Rotunda/Rotunda";
import { useNavigationContext } from "../../context/Navigation.context";
import { Tabs } from "../../layout/SideBar/SideBar.definitions";
import { getDashboardData } from "../../api/queries";
import Divider from "../../components/Divider/Divider";
import { DividerSpacing } from "../../components/Divider/Divider.definitions";
import { useEffect } from "react";
import { useQuery } from "@tanstack/react-query";
import { useAuth } from "@clerk/clerk-react";
import { useAuth, useUser } from "@clerk/clerk-react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowUpRightFromSquare } from "@fortawesome/free-solid-svg-icons";
import { useNavigate } from "react-router-dom";
import type { DashboardData } from "./DashboardPage.definitions";

const DashboardPage = () => {
const { setCurrentTab } = useNavigationContext();
const { getToken } = useAuth();
const { user } = useUser();
const navigate = useNavigate();

const images = [
"src/pages/DashboardPage/components/MF_1.jpeg",
"src/pages/DashboardPage/components/MF_2.jpeg",
"src/pages/DashboardPage/components/MF_3.jpeg",
"src/pages/DashboardPage/components/MF_4.jpeg",
"src/pages/DashboardPage/components/MF_5.jpeg",
"src/pages/DashboardPage/components/MF_7.png",
"src/pages/DashboardPage/components/MF_8.webp",
];

const { data: dashboardData, isLoading: dashboardLoading } =
useQuery<DashboardData>({
Expand All @@ -28,25 +46,67 @@ const DashboardPage = () => {

return (
<>
<div className={styles.welcomeMessage}>
<div className={styles.cardStyle}>
<div className={styles.flightNumber}>
{dashboardData?.["Flights Today"]}
</div>
<div className={styles.flightsToday}>FLIGHTS TODAY</div>
<div className={styles.dashboardContainer}>
<div className={styles.dashboardTitle}>
Welcome back, {user?.firstName}!
</div>
<div className={styles.cardStyle}>
<div className={styles.flightNumber}>
{(Number(dashboardData?.["Flights This Week"]) || 0) +
(Number(dashboardData?.["Flights Today"]) || 0)}
<Divider spacing={DividerSpacing.LARGE} />
<div className={styles.CardsContainer}>
<div className={styles.cardStyle}>
<div className={styles.flightNumber}>
{dashboardData?.["Flights Today"]}
</div>
<div className={styles.flightsToday}>FLIGHTS TODAY</div>
</div>
<div className={styles.cardStyle}>
<div className={styles.flightNumber}>
{(Number(dashboardData?.["Flights This Week"]) || 0) +
(Number(dashboardData?.["Flights Today"]) || 0)}
</div>
<div className={styles.flightsWeek}>FLIGHTS THIS WEEK </div>
</div>
<div className={styles.cardStyle}>
<div className={styles.flightNumber}>
{dashboardData?.["All Total Flights"]}
</div>
<div className={styles.flightsEver}>FLIGHTS TOTAL</div>
</div>
<div className={styles.flightsWeek}>FLIGHTS THIS WEEK </div>
</div>
<div className={styles.cardStyle}>
<div className={styles.flightNumber}>
{dashboardData?.["All Total Flights"]}
<Divider spacing={DividerSpacing.LARGE} />
<h4>Take a look into Miracle Flights: </h4>
<Rotunda images={images} />
<Divider spacing={DividerSpacing.LARGE} />
<div className={styles.CardsContainer}>
<div
className={styles.quickLinkContainer}
onClick={() => navigate("/request")}
>
<div className={styles.quickLinkText}>REQUEST FLIGHT</div>
<FontAwesomeIcon
className={styles.quickLinkText}
icon={faArrowUpRightFromSquare}
/>
</div>
<div
className={styles.quickLinkContainer}
onClick={() => navigate("/passengers")}
>
<div className={styles.quickLinkText}>PASSENGERS</div>
<FontAwesomeIcon
className={styles.quickLinkText}
icon={faArrowUpRightFromSquare}
/>
</div>
<div
className={styles.quickLinkContainer}
onClick={() => navigate("/trips")}
>
<div className={styles.quickLinkText}>YOUR TRIPS</div>
<FontAwesomeIcon
className={styles.quickLinkText}
icon={faArrowUpRightFromSquare}
/>
</div>
<div className={styles.flightsEver}>FLIGHTS EVER</div>
</div>
</div>
</>
Expand Down
Binary file added src/pages/DashboardPage/components/MF_1.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 added src/pages/DashboardPage/components/MF_2.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 added src/pages/DashboardPage/components/MF_3.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 added src/pages/DashboardPage/components/MF_4.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 added src/pages/DashboardPage/components/MF_5.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 added src/pages/DashboardPage/components/MF_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/pages/DashboardPage/components/MF_8.webp
Binary file not shown.
63 changes: 63 additions & 0 deletions src/pages/DashboardPage/components/Rotunda/Rotunda.module.css
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;
}
112 changes: 112 additions & 0 deletions src/pages/DashboardPage/components/Rotunda/Rotunda.tsx
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;
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ span {
min-height: 10rem;
border-radius: 50%;
background-color: var(--miracle-color-medium);
display: flex;
justify-content: center;
align-items: center;
}

.childIcon {
min-width: 6rem;
min-height: 6rem;
color: white;
}

.info {
Expand Down
Loading

0 comments on commit e65760d

Please sign in to comment.