-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UXIT-1539] Events Page · Schedule #704
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e48b079
Include schedule config to Events
mirhamasala be50bc8
Style day events cards
mirhamasala 00247b8
Style desktop Schedule with TabGroup
mirhamasala 16b7c59
Show Schedule
mirhamasala be2c54c
Test data
mirhamasala 7b1a1db
Add SpeakersSection component for displaying speakers in the event page
mirhamasala 6dee0f4
CR
mirhamasala edd7eee
Refactor ScheduleTabs component to filter out days without events
mirhamasala f90e0bb
CR
mirhamasala bd073b5
CR
mirhamasala a38e9ef
CR
mirhamasala 01dff48
Revert data
mirhamasala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { z } from 'zod' | ||
|
||
const EventSchema = z | ||
.object({ | ||
title: z.string(), | ||
description: z.string(), | ||
start: z.coerce.date(), | ||
end: z.coerce.date().optional(), | ||
location: z.string(), | ||
url: z.string().url().optional(), | ||
}) | ||
.strict() | ||
|
||
const EventDaySchema = z | ||
.object({ | ||
date: z.coerce.date(), | ||
events: z.array(EventSchema), | ||
}) | ||
.strict() | ||
|
||
export const ScheduleSchema = z | ||
.object({ | ||
title: z.string().optional(), | ||
days: z.array(EventDaySchema), | ||
}) | ||
.strict() | ||
|
||
export type Schedule = z.infer<typeof ScheduleSchema> |
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,17 @@ | ||
import type { Event } from '@/types/eventType' | ||
|
||
import { PageSection } from '@/components/PageSection' | ||
|
||
import { ScheduleTabs } from './ScheduleTabs' | ||
|
||
type ScheduleSectionProps = { | ||
schedule: NonNullable<Event['schedule']> | ||
} | ||
|
||
export function ScheduleSection({ schedule }: ScheduleSectionProps) { | ||
return ( | ||
<PageSection kicker="Join Us" title={schedule.title || 'Schedule'}> | ||
<ScheduleTabs schedule={schedule} /> | ||
</PageSection> | ||
) | ||
} |
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,101 @@ | ||
'use client' | ||
|
||
import { useRef } from 'react' | ||
|
||
import { Tab, TabGroup, TabList, TabPanel, TabPanels } from '@headlessui/react' | ||
import theme from 'tailwindcss/defaultTheme' | ||
import { useIsMounted, useMediaQuery } from 'usehooks-ts' | ||
|
||
import type { Event } from '@/types/eventType' | ||
|
||
import { BasicCard } from '@/components/BasicCard' | ||
import { Heading } from '@/components/Heading' | ||
import { TextLink } from '@/components/TextLink' | ||
|
||
import { formatDate, formatTime } from '../utils/dateUtils' | ||
|
||
type ScheduleTabsProps = { | ||
schedule: NonNullable<Event['schedule']> | ||
} | ||
|
||
const { screens } = theme | ||
|
||
export function ScheduleTabs({ schedule }: ScheduleTabsProps) { | ||
const tabGroupRef = useRef<HTMLDivElement>(null) | ||
const isMounted = useIsMounted() | ||
const isScreenBelowLg = useMediaQuery( | ||
`(max-width: ${parseInt(screens.md, 10) - 1}px)`, | ||
) | ||
|
||
const validDays = schedule.days | ||
.filter((day) => day.events.length > 0) | ||
.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()) | ||
|
||
function scrollToTabGroup() { | ||
if (isMounted() && isScreenBelowLg && tabGroupRef.current) { | ||
tabGroupRef.current.scrollIntoView({ | ||
behavior: 'smooth', | ||
block: 'start', | ||
}) | ||
} | ||
} | ||
|
||
return ( | ||
<TabGroup | ||
ref={tabGroupRef} | ||
className="relative grid gap-6" | ||
onChange={scrollToTabGroup} | ||
> | ||
<TabList className="sticky top-0 -m-2 flex gap-4 overflow-auto bg-brand-800 p-2 lg:static"> | ||
{validDays.map((day) => ( | ||
<Tab | ||
key={formatDate(day.date)} | ||
className="whitespace-nowrap rounded-lg p-3 font-bold text-brand-300 focus:brand-outline data-[hover]:bg-brand-700 data-[selected]:bg-brand-700 data-[selected]:text-brand-400" | ||
> | ||
{formatDate(day.date)} | ||
</Tab> | ||
))} | ||
</TabList> | ||
<TabPanels> | ||
{validDays.map((day) => ( | ||
<TabPanel | ||
key={formatDate(day.date)} | ||
className="rounded-lg focus:brand-outline" | ||
> | ||
<div className="grid gap-4"> | ||
{day.events.map((event) => ( | ||
<BasicCard key={event.title}> | ||
<div className="grid gap-6 lg:grid-cols-3"> | ||
<div className="flex gap-6 text-brand-300 lg:flex-col lg:gap-1"> | ||
<div className="text-sm font-bold"> | ||
<span>{formatTime(event.start)}</span> | ||
{event.end && <span> – {formatTime(event.end)}</span>} | ||
</div> | ||
<span className="text-sm">{event.location}</span> | ||
</div> | ||
<div className="lg:col-span-2"> | ||
<Heading tag="h3" variant="lg"> | ||
{event.title} | ||
</Heading> | ||
<p className="mb-4 mt-2 max-w-readable"> | ||
{event.description} | ||
</p> | ||
{event.url && ( | ||
<TextLink href={event.url}>View Details</TextLink> | ||
)} | ||
</div> | ||
</div> | ||
</BasicCard> | ||
))} | ||
</div> | ||
</TabPanel> | ||
))} | ||
</TabPanels> | ||
</TabGroup> | ||
) | ||
} | ||
|
||
function isScreenBelowLg() { | ||
return window.matchMedia(`(max-width: ${parseInt(screens.md, 10) - 1}px)`) | ||
.matches | ||
} | ||
Comment on lines
+98
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already rely on |
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,28 @@ | ||
import type { Event } from '@/types/eventType' | ||
|
||
import { CardGrid } from '@/components/CardGrid' | ||
import { KeyMemberCard } from '@/components/KeyMemberCard' | ||
import { PageSection } from '@/components/PageSection' | ||
|
||
type SpeakersSectionProps = { | ||
speakers: NonNullable<Event['speakers']> | ||
} | ||
|
||
export function SpeakersSection({ speakers }: SpeakersSectionProps) { | ||
return ( | ||
<PageSection kicker="speakers" title="Speakers"> | ||
<CardGrid cols="mdTwo"> | ||
{speakers.map((speaker) => ( | ||
<KeyMemberCard | ||
key={speaker.name} | ||
{...speaker} | ||
image={{ | ||
...speaker.image, | ||
alt: `Photo of ${speaker.name}`, | ||
}} | ||
/> | ||
))} | ||
</CardGrid> | ||
</PageSection> | ||
) | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a function
scrollToSection
in the maturity modelutils
folder, in case it can be extracted in the globalutils
reused here. Not sure, I haven't tried.Super cool you added this by the way, smooth UX!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided not to extract the
scrollToSection
function for now because it is tightly coupled to the concept of aSectionHash
.By the way, this made me notice that the function
scrollToSection
usesdocument.querySelector
, which in React is considered an anti-pattern because it directly manipulates the DOM outside of React’s control. Instead, React encourages the use ofrefs
to interact with DOM elements.Something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed!