-
Notifications
You must be signed in to change notification settings - Fork 73
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 #140 from SewonKim0/events-redesign
Events redesign
- Loading branch information
Showing
21 changed files
with
152 additions
and
11 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
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
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,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; |
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
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>; |
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.