Skip to content

Commit

Permalink
Merge pull request #140 from SewonKim0/events-redesign
Browse files Browse the repository at this point in the history
Events redesign
  • Loading branch information
abigailzhou03 authored Apr 11, 2024
2 parents b785965 + a94cb20 commit 0962fe8
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type CardProps = {
};

const classes = {
base: 'bg-white border-gray-300 border dark:bg-neutral-900 dark:border-neutral-700 hover:bg-gray-200 dark:hover:bg-neutral-800 transition-colors',
base: 'group bg-white border-gray-300 border dark:bg-neutral-900 dark:border-neutral-700 hover:bg-gray-200 dark:hover:bg-neutral-800 transition-colors',
size: {
small: 'p-4 text-sm',
normal: 'p-8',
Expand Down
10 changes: 7 additions & 3 deletions src/components/EventsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface EventsListProps {
count?: number;
}

const getDateText = (event: Event) => {
export const getDateText = (event: Event) => {
const day = Intl.DateTimeFormat(undefined, {
month: 'long',
day: 'numeric',
Expand All @@ -26,11 +26,15 @@ const EventsList = ({ events, count }: EventsListProps) => {
<>
<div className='grid gap-12 grid-cols-1 sm:grid-cols-2'>
{events.map((event) => (
<Card shadow='none' key={event.title}>
<Card shadow='none' link={!event.imgsList ? undefined : `/event?index=${event.eventIndex}`} key={event.title}>
<div className='-m-8 mb-0'>
<img className='w-full h-48 rounded-t-lg object-cover' src={event.cover} alt='' />
</div>
<h3 className='mt-6 text-xl font-bold'>{event.title}</h3>
<div className='flex justify-between items-center p-2 pt-3'>
<h3 className='text-xl font-bold'>{event.title}</h3>
{!event.imgsList ? null :
<div className='group-hover:bg-neutral-600 border-2 px-3 py-2 text-lg rounded-md transition-colors'> View </div>}
</div>
<ul className='text-zinc-600 dark:text-zinc-400'>
<li className='my-2 flex gap-x-2'>
<Clock className='flex-shrink-0 inline-block' />
Expand Down
4 changes: 2 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Footer() {
<p>NYU’s premier open source club</p>
<div className='flex flex-row gap-x-4'>
{SOCIAL_ICONS.map(({ to, getMark }) => (
<a key={to} href={to} target='_blank' rel='noopener noreferrer'>
<a className='hover:scale-110' key={to} href={to} target='_blank' rel='noopener noreferrer'>
{getMark()}
</a>
))}
Expand All @@ -26,7 +26,7 @@ function Footer() {
<p>
<a
href='https://discord.com/invite/75jgtXy7rz'
className='text-purple-400 font-bold'
className='text-purple-400 font-bold hover:text-pink-200'
target='_blank'
rel='noopener noreferrer'
>
Expand Down
16 changes: 13 additions & 3 deletions src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function NavBar() {
const { currentTheme, toggleCurrentTheme } = useThemeContext();
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState<boolean>(false);

// close nav links menu on browser resize
useEffect(() => {
const handleResize = () => setIsMobileMenuOpen(false);
window.addEventListener('resize', handleResize);
Expand All @@ -28,19 +29,26 @@ function NavBar() {
return (
<header>
<nav className='flex max-w-5xl mx-auto items-center justify-between flex-wrap p-8'>
{/* BUGS Icon */}
<div className='flex items-center flex-shrink-0'>
<Link to='/' className='text-xl font-bold dark:text-stone-100'>
BUGS
</Link>
</div>

{/* Open/Close Mobile Menu */}
<div className='block md:hidden'>
<button className='flex w-10 h-10 items-center justify-center' onClick={toggleMobileMenu}>
<button
className={`${currentTheme === "light" ? "text-black" : "text-white"} flex w-10 h-10 items-center justify-center`}
onClick={toggleMobileMenu}>
{isMobileMenuOpen ? <Cancel /> : <Menu />}
</button>
</div>

{/* Nav Links (for mobile & desktop) */}
<div
className={`${
isMobileMenuOpen ? 'h-44' : 'h-0'
isMobileMenuOpen ? '' : 'h-0'
} w-full block truncate flex-grow mt-2 transition-height duration-100 md:mt-0 md:flex md:items-center md:w-auto md:h-auto`}
>
<div className='md:flex md:flex-row md:flex-grow md:space-x-12 md:justify-center'>
Expand All @@ -54,7 +62,9 @@ function NavBar() {
</Link>
))}
</div>
<div className='md:flex md:flex-row gap-2'>

{/* Join Button & Light/Dark Toggle */}
<div className='flex flex-row gap-2'>
<a href='https://discord.gg/75jgtXy7rz'>
<Button variant='secondary' className='px-6'>
Join
Expand Down
50 changes: 50 additions & 0 deletions src/components/Slider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { useState } from "react";
import { NavArrowLeft, NavArrowRight } from 'iconoir-react';

type SliderProps = {
children: React.ReactNode[];
}

function Slider({ children }: SliderProps) {
const [sliderIndex, setSliderIndex] = useState(0);

return (<div className="overflow-hidden relative rounded-xl">
{/* Slider Content */}
<div className="flex transition-transform"
style={{
transform: `translateX(-${sliderIndex * 100}%)`,
}}>
{children.map((element, elementIndex) =>
<div className="flex-none w-full bg-orange-900" key={elementIndex}>
{element}
</div>
)}
</div>

{/* Left Button */}
<button className="absolute left-0 top-1/2 border-2 border-l-0 border-white rounded-r-xl -translate-y-1/2 hover:bg-opacity-[0.3] hover:bg-white"
style={{
display: sliderIndex === 0 ? "none" : "block"
}}
onClick={() => {
if (sliderIndex === 0) {
return;
}
setSliderIndex(sliderIndex - 1);
}}> <NavArrowLeft width={50} height={80} /> </button>

{/* Right Button */}
<button className="absolute right-0 top-1/2 border-2 border-r-0 border-white rounded-l-xl -translate-y-1/2 hover:bg-opacity-[0.3] hover:bg-white"
style={{
display: sliderIndex === children.length - 1 ? "none" : "block"
}}
onClick={() => {
if (sliderIndex === children.length - 1) {
return;
}
setSliderIndex(sliderIndex + 1);
}}> <NavArrowRight width={50} height={80} /> </button>
</div>);
}

export default Slider;
17 changes: 17 additions & 0 deletions src/data/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export interface Event {
endTime: string;
location: string;
cover: string;
imgsList?: string[];
eventIndex?: number;
}

export const EVENTS: Event[] = [
Expand All @@ -17,6 +19,13 @@ export const EVENTS: Event[] = [
endTime: '6 PM',
location: 'WWH Room 101',
cover: '/images/events/bugssxgoogle.jpg',
imgsList: ['/images/events-pictures/google/1.jpg',
'/images/events-pictures/google/2.jpg',
'/images/events-pictures/google/3.jpg',
'/images/events-pictures/google/4.jpg',
'/images/events-pictures/google/5.jpg',
'/images/events-pictures/google/6.jpg'
],
},
{
title: 'BUGS Kickoff Event',
Expand All @@ -35,6 +44,14 @@ export const EVENTS: Event[] = [
endTime: '6:30 PM',
location: 'WWH Room 101',
cover: '/images/events/anubis.jpg',
imgsList: ['/images/events-pictures/anubis/1.jpg',
'/images/events-pictures/anubis/2.jpg',
'/images/events-pictures/anubis/3.jpg',
'/images/events-pictures/anubis/4.jpg',
'/images/events-pictures/anubis/5.jpg',
'/images/events-pictures/anubis/6.jpg',
'/images/events-pictures/anubis/7.jpg'
]
},
{
title: 'Tech Fest',
Expand Down
58 changes: 58 additions & 0 deletions src/pages/event.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import * as React from 'react';
import { Event, EVENTS } from '../data/events';
import type { HeadFC, PageProps } from 'gatsby';
import Layout from '../components/Layout';
import { Clock, PinAlt } from 'iconoir-react';
import { getDateText } from '../components/EventsList';
import Slider from '../components/Slider';

const EventsPage: React.FC<PageProps> = ({ location }) => {
// get event index via query var
const queryParams = new URLSearchParams(location.search);
const index = parseInt( queryParams.get('index') ?? '0' );
if (isNaN(index) || index < 0 || index >= EVENTS.length) {
return <Layout> <h1> Error: Invalid page </h1> </Layout>;
}

// get event data
const event = EVENTS[index];

if (!event.imgsList) {
return <Layout> <h1> Error: Invalid event - images not found </h1> </Layout>;
}

return (
<Layout>
<div className='max-w-5xl mx-auto px-8 flex flex-col py-8'>
<h1 className='text-2xl'> {event.title} </h1>

<ul className='text-zinc-600 dark:text-zinc-400 m-3'>
<li className='my-2 flex gap-x-2'>
<Clock className='flex-shrink-0 inline-block' />
{getDateText(event)}
</li>
<li className='my-2 flex gap-x-2'>
<PinAlt className='flex-shrink-0 inline-block' />
{event.location}
</li>
</ul>

<p className="mb-5"> {event.description} </p>

<Slider>
{event.imgsList.map((imgSrc, imgIndex) =>
<img
src={imgSrc}
width="100%" height="auto"
key={imgIndex}
/>)}
</Slider>
</div>
</Layout>
);
};

export default EventsPage;

// TODO: edit the page title accordingly
export const Head: HeadFC = () => <title>Events</title>;
6 changes: 4 additions & 2 deletions src/pages/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import Layout from '../components/Layout';
import EventsList from '../components/EventsList';

const EventsPage: React.FC<PageProps> = () => {
// assign event indices for id, split to past & upcoming events
const currDate = new Date().setHours(0, 0, 0, 0);
const upcomingEvents = EVENTS.filter(({ date }: Event) => date.getTime() >= currDate).sort(
const eventsWithIndices = EVENTS.map((event, eventIndex) => ({ ...event, eventIndex }));
const upcomingEvents = eventsWithIndices.filter(({ date }: Event) => date.getTime() >= currDate).sort(
(a: Event, b: Event) => a.date.getTime() - b.date.getTime(),
);
const pastEvents = EVENTS.filter(({ date }: Event) => date.getTime() < currDate).sort(
const pastEvents = eventsWithIndices.filter(({ date }: Event) => date.getTime() < currDate).sort(
(a: Event, b: Event) => b.date.getTime() - a.date.getTime(),
);

Expand Down
Binary file added static/images/events-pictures/anubis/1.jpg
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 static/images/events-pictures/anubis/2.jpg
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 static/images/events-pictures/anubis/3.jpg
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 static/images/events-pictures/anubis/4.jpg
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 static/images/events-pictures/anubis/5.jpg
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 static/images/events-pictures/anubis/6.jpg
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 static/images/events-pictures/anubis/7.jpg
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 static/images/events-pictures/google/1.jpg
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 static/images/events-pictures/google/2.jpg
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 static/images/events-pictures/google/3.jpg
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 static/images/events-pictures/google/4.jpg
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 static/images/events-pictures/google/5.jpg
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 static/images/events-pictures/google/6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0962fe8

Please sign in to comment.