Skip to content

Commit

Permalink
feat: default close agenda on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Lettly committed Jun 12, 2024
1 parent 5bb634e commit 59e5931
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 37 deletions.
72 changes: 55 additions & 17 deletions src/Components/Agenda.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from './ui/accordion';
import {

Check failure on line 1 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Replace `⏎··Accordion,⏎··AccordionContent,⏎··AccordionItem,⏎··AccordionTrigger,⏎` with `·Accordion,·AccordionContent,·AccordionItem,·AccordionTrigger·`
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from './ui/accordion';
import mainTrack from '../assets/mainTrack.json';
import discoveryTrack from '../assets/discoveryTrack.json';
import { motion } from 'framer-motion';
Expand Down Expand Up @@ -27,7 +32,11 @@ const AgendaAccordion = () => {

const isMobile = width <= 1024;
return (
<div className="relative h-full pt-10 pb-5 bg-white " id="agenda" ref={containerRef}>
<div

Check failure on line 35 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Replace `⏎······className="relative·h-full·pt-10·pb-5·bg-white·"⏎······id="agenda"⏎······ref={containerRef}⏎····` with `·className="relative·h-full·pt-10·pb-5·bg-white·"·id="agenda"·ref={containerRef}`
className="relative h-full pt-10 pb-5 bg-white "
id="agenda"
ref={containerRef}
>
<motion.img
src={dino_mascot}
alt="Dino Mascot"
Expand All @@ -41,11 +50,15 @@ const AgendaAccordion = () => {
<Accordion
type="multiple"
// defaultValue="item-1"
defaultValue={['main_stage', 'discovery_track']}
defaultValue={!isMobile ? ['main_stage', 'discovery_track'] : []}
// collapsible
className="w-full lg:flex lg:justify-center lg:gap-4 lg:mt-10 lg:pl-10 lg:pr-10 "
>
<AccordionItem value="main_stage" className="border-b-0 rounded-lg lg:w-1/2" disabled={!isMobile}>
<AccordionItem

Check failure on line 57 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Replace `⏎············value="main_stage"⏎············className="border-b-0·rounded-lg·lg:w-1/2"⏎············disabled={!isMobile}⏎··········` with `·value="main_stage"·className="border-b-0·rounded-lg·lg:w-1/2"·disabled={!isMobile}`
value="main_stage"
className="border-b-0 rounded-lg lg:w-1/2"
disabled={!isMobile}
>
<AccordionTrigger
className="p-2 text-2xl font-bold text-purple-900 no-underline min-h-16 hover:no-underline"
showIcon={isMobile}
Expand Down Expand Up @@ -83,7 +96,7 @@ const ComingSoon = () => {

useEffect(() => {
const interval = setInterval(() => {
setAnimationText(prevText => {
setAnimationText((prevText) => {

Check failure on line 99 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Replace `(prevText)` with `prevText`
if (prevText === 'coming soon...') {
return 'coming soon';
} else {
Expand All @@ -99,7 +112,9 @@ const ComingSoon = () => {

return (
<div className="p-10">
<motion.p className="text-2xl font-medium text-center text-blue-900">{animationText}</motion.p>
<motion.p className="text-2xl font-medium text-center text-blue-900">

Check failure on line 115 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Replace `⏎········{animationText}⏎······` with `{animationText}`
{animationText}
</motion.p>
</div>
);
};
Expand All @@ -116,7 +131,13 @@ const Agenda = ({ talks }: { talks: AgendaItem[] }) => {
);
};

const TalkCard = ({ talk: agendaTalk, index }: { talk: AgendaItem; index: number }) => {
const TalkCard = ({

Check failure on line 134 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Replace `⏎··talk:·agendaTalk,⏎··index,⏎}:·{⏎··talk:·AgendaItem;⏎··index:·number;⏎` with `·talk:·agendaTalk,·index·}:·{·talk:·AgendaItem;·index:·number·`
talk: agendaTalk,
index,
}: {
talk: AgendaItem;
index: number;
}) => {
if (!agendaTalk || !agendaTalk.agenda_details.type === undefined) return null;

const pad = (time: number, size: number) => {
Expand All @@ -131,7 +152,8 @@ const TalkCard = ({ talk: agendaTalk, index }: { talk: AgendaItem; index: number
};

const title = agendaTalk?.talk?.title || agendaTalk?.break?.title;
const description = agendaTalk?.talk?.description || agendaTalk?.break?.inline_abstract;
const description =

Check failure on line 155 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Delete `⏎···`
agendaTalk?.talk?.description || agendaTalk?.break?.inline_abstract;
const name = agendaTalk?.talk?.name;
const duration = agendaTalk?.agenda_details.minutes || 0;
const profileImg = agendaTalk?.talk?.avatar;
Expand All @@ -142,7 +164,9 @@ const TalkCard = ({ talk: agendaTalk, index }: { talk: AgendaItem; index: number
const startTime = agendaTalk.agenda_details.start_time;
const endTime = agendaTalk.agenda_details.end_time;

const timeStampString = `${getTimestamp(startTime)} ${getTimestamp(endTime)}`;
const timeStampString = `${getTimestamp(startTime)} ${getTimestamp(

Check failure on line 167 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Replace `⏎····endTime⏎··` with `endTime`
endTime
)}`;

const calculateItemHeight = (duration: number) => {
const base = 10;
Expand All @@ -159,24 +183,35 @@ const TalkCard = ({ talk: agendaTalk, index }: { talk: AgendaItem; index: number
<div
id="talk"
className={`last:border-b-[1px] border-t-[1px] border-l-0 border-r-0 relative border-[#5d518488] flex px-4 justify-start items-center box-border ${
agendaTalk.agenda_details.type === 'talk' ? '' : 'bg-gradient-to-br from-pink-50 to-purple-100'
agendaTalk.agenda_details.type === 'talk'

Check failure on line 186 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Replace `⏎··········?·''⏎·········` with `·?·''`
? ''
: 'bg-gradient-to-br from-pink-50 to-purple-100'
}`}
style={{
minHeight: `${calculateItemHeight(duration)}px`
minHeight: `${calculateItemHeight(duration)}px`,

Check failure on line 191 in src/Components/Agenda.tsx

View workflow job for this annotation

GitHub Actions / lint_test

Delete `,`
}}
>
<div id="talk-details" className="flex items-center w-full gap-3 p-2 min-h-5">
<div
id="talk-details"
className="flex items-center w-full gap-3 p-2 min-h-5"
>
<div id="time-container" className="">
<p className="flex text-gray-600 ">{timeStampString}</p>
</div>
<div id="talk-content" className="w-full ">
<AccordionItem className="pb-1 border-0 " value={index + startTime + endTime}>
<AccordionItem
className="pb-1 border-0 "
value={index + startTime + endTime}
>
<AccordionTrigger
disabled={talkType === 'break' || name === PLACEHOLDER_NAME}
showIcon={talkType === 'talk' && name !== PLACEHOLDER_NAME}
className={`flex justify-start text-start my-auto
className={`flex justify-start text-start my-auto
${talkType === 'break' && 'text-purple-900 hover:no-underline py-0'}
${name === PLACEHOLDER_NAME && 'text-zinc-600 hover:no-underline pointer-events-none'}
${
name === PLACEHOLDER_NAME &&
'text-zinc-600 hover:no-underline pointer-events-none'
}
${isKeynote && 'text-fuchsia-700 font-bold'}
${talkType === 'talk' && 'pb-0 pt-0'}`}
>
Expand All @@ -195,7 +230,8 @@ const TalkCard = ({ talk: agendaTalk, index }: { talk: AgendaItem; index: number
href={agendaTalk.talk?.url}
target="_blank"
className={`underline underline-offset-2 ${
name === PLACEHOLDER_NAME && 'no-underline pointer-events-none'
name === PLACEHOLDER_NAME &&
'no-underline pointer-events-none'
}`}
>
{speakerNameTitle}
Expand Down Expand Up @@ -233,7 +269,9 @@ const TalkCard = ({ talk: agendaTalk, index }: { talk: AgendaItem; index: number
loading="lazy"
/>
) : (
!profileImg && <p className="text-xs font-light text-center">{name}</p>
!profileImg && (
<p className="text-xs font-light text-center">{name}</p>
)
)}
</a>
</div>
Expand Down
48 changes: 28 additions & 20 deletions src/Components/ui/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,40 @@ const AccordionItem = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className, ...props }, ref) => (
<AccordionPrimitive.Item ref={ref} className={cn('border-b', className)} {...props} />
<AccordionPrimitive.Item
ref={ref}
className={cn('border-b', className)}
{...props}
/>
));
AccordionItem.displayName = 'AccordionItem';

interface AccordionTriggerProps extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> {
interface AccordionTriggerProps
extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> {
showIcon?: boolean;
}

const AccordionTrigger = React.forwardRef<React.ElementRef<typeof AccordionPrimitive.Trigger>, AccordionTriggerProps>(
({ className, children, showIcon = true, ...props }, ref) => (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
ref={ref}
className={cn(
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
className
)}
{...props}
>
{children}
{showIcon && <ChevronDown className="w-4 h-4 transition-transform duration-200 shrink-0" />}
{/* <ChevronDown className="w-4 h-4 transition-transform duration-200 shrink-0" /> */}
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
)
);
const AccordionTrigger = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
AccordionTriggerProps
>(({ className, children, showIcon = true, ...props }, ref) => (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
ref={ref}
className={cn(
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
className
)}
{...props}
>
{children}
{showIcon && (
<ChevronDown className="w-4 h-4 transition-transform duration-200 shrink-0" />
)}
{/* <ChevronDown className="w-4 h-4 transition-transform duration-200 shrink-0" /> */}
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
));
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;

const AccordionContent = React.forwardRef<
Expand Down

0 comments on commit 59e5931

Please sign in to comment.