-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from volkovmqx/project-alpha
Project-alpha
- Loading branch information
Showing
22 changed files
with
879 additions
and
370 deletions.
There are no files selected for viewing
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.
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,35 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import useEmblaCarousel from 'embla-carousel-react' | ||
import { Title } from '@mantine/core'; | ||
|
||
export function EventCarousel({ eventApis, eventRefs, events, activeEvent, ci, conferenceTitle }) { | ||
const [emblaRef, emblaApi] = useEmblaCarousel({align: 'start', startIndex: activeEvent || 0}); | ||
useEffect(() => { | ||
if (emblaRef && emblaApi) { | ||
eventRefs.current[ci] = emblaRef; | ||
eventApis.current[ci] = emblaApi; | ||
} | ||
}, [emblaRef, emblaApi]); | ||
|
||
return ( | ||
<> | ||
<Title size={"48px"} mb={20}>{conferenceTitle}</Title> | ||
<div className="embla"> | ||
<div className="embla__viewport" ref={emblaRef}> | ||
<div className="embla__container"> | ||
{events.lectures.nodes.map((e, ei) => ( | ||
<div className={ci === 0 && (activeEvent || 0) === ei ? 'embla__slide active' : 'embla__slide'} key={ei}> | ||
<img | ||
className="embla__slide__img" | ||
src={e.images.thumbUrl} | ||
loading="lazy" | ||
alt={e.title} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} |
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,103 @@ | ||
import React, { useState, useRef, useEffect } from 'react'; | ||
import { GET_RECENT_CONFERENCES } from '../data'; | ||
import { Center, Loader, Container, Box } from '@mantine/core'; | ||
import { useWindowEvent, useListState } from '@mantine/hooks'; | ||
import { useQuery } from '@apollo/client'; | ||
import { Preview } from '../components/Preview'; | ||
import { Player } from '../components/Player'; | ||
import { handleArrowDown, handleArrowUp, handleArrowLeft, handleArrowRight } from '../helpers/helpers'; | ||
import { EventCarousel } from '../components/EventCarousel'; | ||
|
||
import '../styles.css'; | ||
|
||
export const Home = () => { | ||
const [playerIsOpen, setPlayerIsOpen] = useState(false) | ||
const [activeSlice, setActiveSlice] = useState(0) | ||
const [dataSlice, dataSliceHandlers] = useListState([]); | ||
const [isLoading, setIsLoading] = useState(false) | ||
const [activeEvents, setActiveEvents] = useState({ 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 }); | ||
|
||
const { loading, error, data, fetchMore } = useQuery(GET_RECENT_CONFERENCES, { | ||
variables: { offset: 0 }, | ||
}); | ||
|
||
useEffect(() => { | ||
if (!data) return | ||
if (data.conferencesRecent) { | ||
if (activeSlice == 0) { | ||
dataSliceHandlers.setState(data.conferencesRecent) | ||
} else { | ||
dataSliceHandlers.setState(data.conferencesRecent.slice(activeSlice, activeSlice + 6)) | ||
} | ||
setIsLoading(false) | ||
//setActiveSlice(activeSlice + 1) | ||
} | ||
}, [data]) | ||
|
||
const eventRefs = useRef([]); | ||
const eventApis = useRef([]); | ||
|
||
|
||
useWindowEvent('keydown', (e) => { | ||
if (!data) return | ||
if ((e.key === 'Escape' || e.key === 'Backspace' || e.keyCode == '461') && playerIsOpen) { | ||
// close the Player | ||
e.preventDefault() | ||
setPlayerIsOpen(false) | ||
|
||
} else if (e.key === 'Enter' && !playerIsOpen) { | ||
// go to the Event page | ||
setPlayerIsOpen(true) | ||
} else if (e.key === 'ArrowRight' && !playerIsOpen) { | ||
handleArrowRight(eventApis, activeEvents, activeSlice, setActiveEvents) | ||
} else if (e.key === 'ArrowLeft' && !playerIsOpen) { | ||
handleArrowLeft(eventApis, activeEvents, activeSlice, setActiveEvents) | ||
} else if (e.key === 'ArrowDown' && !playerIsOpen) { | ||
|
||
handleArrowDown(setActiveSlice, dataSlice, dataSliceHandlers, data, setIsLoading, fetchMore) | ||
} else if (e.key === 'ArrowUp' && !playerIsOpen) { | ||
handleArrowUp(setActiveSlice, dataSliceHandlers, data) | ||
} | ||
}) | ||
if (loading || dataSlice.length == 0) return <Center h={"100vh"} ><Loader color="gray" type="dots" size="xl" /></Center>; | ||
if (error) return <p>Error : {error.message}</p>; | ||
if (playerIsOpen) return <Player event={dataSlice[0].lectures.nodes[activeEvents[activeSlice] || 0]} conferenceTitle={dataSlice[0].title} /> | ||
return ( | ||
<Container fluid> | ||
<Preview | ||
event={dataSlice[0].lectures.nodes[activeEvents[activeSlice] || 0]} | ||
conferenceTitle={dataSlice[0].title} | ||
/> | ||
<div className="container"> | ||
<div className="embla_vertical"> | ||
<div className="embla__viewport"> | ||
<div className="embla__container embla__container_vertical"> | ||
{dataSlice.map((c, ci) => ( | ||
<div className="embla__slide" key={ci}> | ||
<EventCarousel | ||
eventRefs={eventRefs} | ||
eventApis={eventApis} | ||
events={c} | ||
activeEvent={activeEvents[ci + activeSlice]} | ||
ci={ci} | ||
conferenceTitle={c.title} | ||
|
||
/> | ||
</div> | ||
))} | ||
{isLoading && ( | ||
<div className="embla__slide"> | ||
<Box className='skeleton'> | ||
<div className='loaderContainer'> | ||
<Loader color="gray" type="dots" size="xl" /> | ||
</div> | ||
</Box> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</Container> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.