Skip to content

Commit

Permalink
event cards
Browse files Browse the repository at this point in the history
  • Loading branch information
sonylomo committed Apr 18, 2024
1 parent c059880 commit 451c451
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 111 deletions.
16 changes: 9 additions & 7 deletions src/APP/pages/community/CommunityPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ function CommunityPage() {
}, []);

return (
<div className="max-w-[1440px] mx-auto">
<WelcomeSection />
<EventsSection showAllEventsLink />
{/* <ChaptersSection /> */}
{/* <PartnerSection /> */}
<GallerySection />
</div>
<section className="bg-[#d9d9d9]/30 ">
<div className="max-w-[1440px] mx-auto">
<WelcomeSection />
<EventsSection showAllEventsLink />
{/* <ChaptersSection /> */}
{/* <PartnerSection /> */}
<GallerySection />
</div>
</section>
);
}

Expand Down
218 changes: 139 additions & 79 deletions src/APP/pages/events/sections/eventsSection/Events.jsx
Original file line number Diff line number Diff line change
@@ -1,101 +1,161 @@
import React from "react";
import { Link } from "react-router-dom";
/* eslint-disable operator-linebreak */
/* eslint-disable camelcase */
/* eslint-disable indent */
/* eslint-disable linebreak-style */
import PropTypes from "prop-types";

import formatEventDates from "../../../../../utilities/formatEventDate";
import { LazyLoadImage } from "react-lazy-load-image-component";
import { Link } from "react-router-dom";
import { LocationTag } from "../../../community/sections/eventsSection/SingleEvents/sections";
import {
lightEventCard,
darkEventCard,
} from "../../../../../assets/images/community";
import formatEventDates from "../../../../../utilities/formatEventDate";
import { format, parseISO } from "date-fns";
import {
clock,
tag,
calendar,
globe,
} from "../../../../../assets/images/icons";

function Events({ events, isVertical }) {
const verticalContainer =
"my-6 grid grid-cols-1 gap-x-3 gap-y-10 sm:grid-cols-2 lg:grid-cols-5 xl:gap-x-8";
const horizontalContainer =
"flex overflow-x-auto px-0 md:px-4 gap-2 sm:gap-4 w-full";

// Event Card classes
const verticalWrapper =
"max-w-sm bg-white border border-gray-200 rounded-lg h-auto";
const horizontalWrapper =
"m-3 md:m-6 bg-white rounded-lg w-4/5 sm:w-72 flex flex-shrink-0";
function Events({ events }) {
// const formattedDate = format(parseISO(start_date), "do, MMMM");

return (
<div className={isVertical ? verticalContainer : horizontalContainer}>
{events && Array.isArray(events)
? events.map(
({
id,
name,
start_date,
start_time,
end_date,
end_time,
location,
mode,
poster,
city,
}) => {
const date = formatEventDates(
start_date,
start_time,
end_date,
end_time
);
<div
className="my-8 grid grid-cols-1 gap-8 sm:grid-cols-3 max-w-1216 mx-auto pb-10"
style={{
gridAutoColumns: "max-content",
gridTemplateRows: "minmax(550px, 400px)",
}}
>
{events &&
Array.isArray(events) &&
events.map(
({
id,
name,
start_date,
start_time,
end_date,
end_time,
location,
mode,
poster,
city,
}) => {
// const date = formatEventDates(
// start_date,
// start_time,
// end_date,
// end_time
// );

const buttonColor =
mode === "Virtual"
? "bg-red-800 hover:bg-red-800"
: "bg-blue-800 hover:bg-blue-800";
return (
<div
key={id}
className={isVertical ? verticalWrapper : horizontalWrapper}
style={{
boxShadow:
"0px 4px 10px 0px rgba(4, 8, 13, 0.05), 0px 2px 4px 0px rgba(4, 8, 13, 0.25)",
}}
>
<Link to={`/events/${id}`} className="cursor-pointer">
<LazyLoadImage
className="rounded-t-lg w-full h-56 object-contain"
src={poster}
alt={name}
/>
const [hours, minutes] = start_time.split(":");

<div className="p-5 text-[#323433] w-full">
<h5 className="mb-2 text-sm font-semibold">{name}</h5>
const date = new Date();
date.setHours(hours);
date.setMinutes(minutes);

<p className="mb-3 font-medium text-xs whitespace-wrap">
{date} EAT
return (
<Link
key={id}
to={`/events/${id}`}
className="cursor-pointer w-4/5 sm:w-96 h-full"
>
<div className="relative">
<LazyLoadImage
className=" rounded-t-lg size-full object-cover"
src={
mode.toLowerCase() === "physical"
? lightEventCard
: darkEventCard
}
alt="Location Icon"
/>
<div className="absolute bottom-0 p-6 space-y-4">
<LocationTag
isVirtual={mode.toLowerCase() !== "physical"}
/>
<p
className={`text-2xl font-medium ${
mode.toLowerCase() === "physical"
? "text-green-dark"
: "text-white"
}`}
>
{name}
</p>
</div>
</div>

<div className="p-5 w-full bg-white rounded-b-lg space-y-4">
<div className="flex flex-between">
<div className="space-y-4">
<p className="flex gap-2 items-center">
<LazyLoadImage
src={calendar}
alt="calendar icon"
className="size-5"
/>
{format(parseISO(start_date), "do, MMMM")}
</p>
<p className="mb-3 font-normal text-xs">
{location}{" "}
{mode.toLowerCase() === "physical" && (
<span>{city}</span>

<p className="flex gap-2 items-center">
<LazyLoadImage
src={globe}
alt="globe icon"
className="size-5"
/>
{mode.toLowerCase() === "physical" ? (
location
) : (
<a
href={location}
target="_blank"
rel="noreferrer noopener"
className="text-primary"
>
Online
</a>
)}
</p>
<button
type="button"
className={`text-white ${buttonColor} focus:outline-none focus:ring-4 focus:ring-red-800 font-medium rounded-full text-xs px-3 py-1 text-center mr-2 mb-2`}
>
{mode}
</button>
</div>
</Link>
<div className="space-y-4">
<p className="flex gap-2 items-center justify-end">
<LazyLoadImage
src={clock}
alt="clock icon"
className="size-5"
/>
{format(date, "HHmm") + " HRS"}
</p>
<p className="flex gap-2 items-center justify-end">
<LazyLoadImage
src={tag}
alt="tag icon"
className="size-5"
/>
Development
</p>
</div>
</div>

<button className=" font-semibold text-green-dark hover:text-white bg-transparent border border-green-dark hover:border-none hover:bg-gradient-to-b to-primary from-green-dark py-3 px-4 md:px-8 focus:outline-none rounded-lg text-sm md:text-base w-full text-center">
Learn More
</button>
</div>
);
}
)
: ""}
</Link>
);
}
)}
</div>
);
}

export default Events;

Events.defaultProps = {
isVertical: true,
};

Events.propTypes = {
events: PropTypes.array,
isVertical: PropTypes.bool.isRequired,
};
58 changes: 33 additions & 25 deletions src/APP/pages/events/sections/eventsSection/EventsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import Error500 from "../../../errorPages/Error500";
import Events from "./Events";
import EventsTab from "./EventsTab";
import EventsUpdateSection from "./EventsUpdateSection";

import { LazyLoadImage } from "react-lazy-load-image-component";
import { Link } from "react-router-dom";
import { arrowRight } from "../../../../../assets/images/icons";
function EventsSection({ showTabs, showAllEventsLink }) {
const [filters, setFilters] = useState({});

Expand Down Expand Up @@ -44,43 +46,49 @@ function EventsSection({ showTabs, showAllEventsLink }) {
}, [filters]);

return (
<section className="py-2 md:py-6">
<section className="py-2 md:py-6 size-full ">
<div className="mx-auto w-full flex flex-row items-center gap-2 md:gap-4 my-8">
<div className="w-full h-0.5 rounded-sm bg-gray-300" />
<h4 className="min-w-fit text-primary text-sm leading-loose px-4 bg-gradient-to-r from-[#D7F4EB] to-white py-2 rounded-full font-semibold border-2 border-gray-300 uppercase">
<h3 className="min-w-fit text-primary text-sm leading-loose px-4 bg-gradient-to-r from-[#D7F4EB] to-white py-2 rounded-full font-semibold border-2 border-gray-300 uppercase">
Our Events
</h4>
</h3>
<div className="w-full h-0.5 bg-gray-300" />
</div>
{isErrorTopEvents && <p>Error loading cities!</p>}
{isLoadingTopEvents && <p className="text-primary">Loading cities...</p>}
{isSuccessTopEvents && (
<EventsUpdateSection
cityFilter={filters}
topEventsCities={topEventsCities}
updateCityFilter={updateCityFilter}
showAllEventsLink={showAllEventsLink}
/>
)}

{showTabs && <EventsTab updateRecentFilter={updateRecentFilter} />}

<h4 className="md:text-3xl text-2xl font-semibold title-font text-green-dark text-center">
Notable events within the <br />
SpaceYaTech ecosphere
</h4>
{isError && <Error500 />}
{isPending && (
<div className="flex flex-col items-center justify-center gap-4 py-10">
<Loader />
<p className="text-lg font-medium text-primary">Loading events...</p>
</div>
)}
{isSuccess && (
<>
{topEventsData?.count === 0 ? (
<p>No events found!</p>
) : (
<Events events={topEventsData?.results} isVertical={false} />
)}
</>
)}
{isSuccess &&
(topEventsData?.count === 0 ? (
<p>No events found!</p>
) : (
<Events events={topEventsData?.results} />
))}
<div>
<Link
to="/all-events"
className="flex items-center border rounded-full bg-white p-1 w-fit mx-auto"
>
<div className="flex items-center bg-green-light rounded-full px-3 py-1.5 gap-2">
<span className="capitalize text-green-header text-sm font-semibold">
View more
</span>
<LazyLoadImage
src={arrowRight}
alt="arrow right"
className="size-5"
/>
</div>
</Link>
</div>
</section>
);
}
Expand Down
Binary file added src/assets/images/community/darkEventCard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/images/community/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Akinyi from "./Akinyi.png";
import akinyiux from "./akinyiux.png";
import community from "./community.png";
import darkEventCard from "./darkEventCard.png";
import eakinyi from "./eakinyi.png";
import Emmy from "./Emmy.png";
import eventCardPhysical from "./event-card-bg-physical.png";
Expand All @@ -20,6 +21,7 @@ import google from "./google.png";
import google2 from "./google2.png";
import Group from "./Group.png";
import individualchapter from "./individualchapter.png";
import lightEventCard from "./lightEventCard.png";
import MasterBase from "./MasterBase.png";
import mentorlst from "./mentorlst.png";
import Mombasa from "./Mombasa.png";
Expand Down Expand Up @@ -76,4 +78,6 @@ export {
eventCardPhysical,
eventsPhysicalBg,
eventsVirtualBg,
lightEventCard,
darkEventCard,
};
Binary file added src/assets/images/community/lightEventCard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/icons/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/icons/clock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/images/icons/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 451c451

Please sign in to comment.