Skip to content
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

Feature/event better medias #840

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/Card/CardEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const _CardEvent = ({ event }: CardEventProps) => {
imageUrl,
location,
availabilities,
thumbnailMedia,
} = event
const [now, setNow] = useState(new Date())
const dateStartAt = useMemo(() => new Date(startsAt), [startsAt])
Expand All @@ -48,21 +49,26 @@ const _CardEvent = ({ event }: CardEventProps) => {
)
})
}, [dateStartAt, event, id])

const eventTimeStatus = useMemo<"upcoming" | "ongoing" | "past">(() => {
const isLive = now > dateStartAt
if (!isLive) return "upcoming"
const isPast = now > new Date(endsAt)
if (isPast) return "past"
return "ongoing"
}, [dateStartAt, endsAt, now])

const styleBackground = {
backgroundImage: `linear-gradient(rgba(0, 0, 0, 0.54), rgba(0, 0, 0, 0.54)), url(${imageUrl})`,
backgroundImage: `linear-gradient(rgba(0, 0, 0, 0.54), rgba(0, 0, 0, 0.54)), url(${
thumbnailMedia?.url || imageUrl
})`,
}
const availabilitiesStr = useMemo(() => {
return availabilities
.map((availability) => availabilityLabels[availability])
.join(" and ")
}, [availabilities])

return (
<div className={style.card} style={styleBackground}>
<div>
Expand Down
11 changes: 11 additions & 0 deletions src/containers/Homepage/HomeFeaturedEvent.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.root {
display: block;
width: 100%;
height: 30vh;

img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
18 changes: 18 additions & 0 deletions src/containers/Homepage/HomeFeaturedEvent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { LiveMintingEvent } from "types/entities/LiveMinting"
import style from "./HomeFeaturedEvent.module.scss"
import cs from "classnames"
import Link from "next/link"

interface Props {
event: LiveMintingEvent
}
export function HomeFeaturedEvent({ event }: Props) {
console.log(event)
return (
<Link href={`/events/${event.id}/onboarding`}>
<a className={cs(style.root)}>
<img src={event.headerMedia!.url} alt={`${event.name} - banner`} />
</a>
</Link>
)
}
4 changes: 4 additions & 0 deletions src/containers/Homepage/Homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import { NFTArticle } from "../../types/entities/Article"
import { LiveMintingEvent } from "../../types/entities/LiveMinting"
import { HomeEvents } from "./HomeEvents"
import { HomeIncoming } from "./HomeIncoming"
import { HomeFeaturedEvent } from "./HomeFeaturedEvent"

interface HomepageProps {
generativeTokens: GenerativeToken[]
incomingTokens: GenerativeToken[]
randomGenerativeToken: GenerativeToken | null
articles: NFTArticle[]
events: LiveMintingEvent[]
featuredEvent: LiveMintingEvent | null
}

const _Homepage = ({
Expand All @@ -24,13 +26,15 @@ const _Homepage = ({
randomGenerativeToken,
articles,
events,
featuredEvent,
}: HomepageProps) => {
return (
<div className={style.container}>
<HomeHero
articles={articles}
randomGenerativeToken={randomGenerativeToken}
/>
{featuredEvent && <HomeFeaturedEvent event={featuredEvent} />}
{events.length > 0 && <HomeEvents events={events} />}
{incomingTokens.length > 0 && (
<HomeIncoming generativeTokens={incomingTokens} />
Expand Down
20 changes: 20 additions & 0 deletions src/pages/events/[id]/onboarding.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,23 @@
max-width: 800px;
margin: auto;
}

.header {
display: block;
width: 1000px;
margin: 0 auto;
max-width: 100%;

img {
width: 100%;
}
}

.h1 {
font-family: "Source Serif Pro", serif;
font-size: 2.35rem;
width: 800px;
margin: 0 auto;
margin-top: 2.2em;
max-width: 100%;
}
9 changes: 9 additions & 0 deletions src/pages/events/[id]/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ const EventsOnboardingPage: NextPage<Props> = ({ event, tokens }) => {

<main className={cs(layout["padding-small"])}>
<Spacing size="3x-large" />

<div className={cs(style.header)}>
{event.headerMedia && (
<img src={event.headerMedia.url} alt={`${event.name} header`} />
)}
</div>

<h1 className={cs(style.h1)}>{event.name}</h1>

<ArticleEvent
content={event.onboarding!.description}
className={cs(style.body)}
Expand Down
24 changes: 23 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import { Frag_UserBadge } from "../queries/fragments/user"
import { Homepage } from "../containers/Homepage/Homepage"
import { NFTArticle } from "../types/entities/Article"
import { Frag_EventCard } from "../queries/fragments/event"
import { LiveMintingEvent } from "../types/entities/LiveMinting"
import {
DashboardFeatured,
LiveMintingEvent,
} from "../types/entities/LiveMinting"

interface Props {
randomGenerativeToken: GenerativeToken | null
Expand All @@ -30,6 +33,7 @@ interface Props {
articles: NFTArticle[]
listings: Listing[]
events: LiveMintingEvent[]
featuredEvent: LiveMintingEvent | null
}

const Home: NextPage<Props> = ({
Expand All @@ -38,6 +42,7 @@ const Home: NextPage<Props> = ({
incomingTokens,
articles,
events,
featuredEvent,
}) => {
return (
<>
Expand Down Expand Up @@ -65,8 +70,10 @@ const Home: NextPage<Props> = ({
content="https://www.fxhash.xyz/images/og/og1.jpg"
/>
</Head>

<Homepage
events={events}
featuredEvent={featuredEvent}
articles={articles}
randomGenerativeToken={randomGenerativeToken}
generativeTokens={generativeTokens}
Expand All @@ -86,6 +93,7 @@ export async function getServerSideProps() {
const eventApolloClient = createApolloClientEvent()
const { data: dataEvent } = await eventApolloClient.query<{
events: LiveMintingEvent[]
featured: DashboardFeatured
}>({
query: gql`
${Frag_EventCard}
Expand All @@ -98,6 +106,19 @@ export async function getServerSideProps() {
id
...EventCard
}
featured(where: { id: 1 }) {
id
event {
id
name
headerMedia {
...MediaDetails
}
thumbnailMedia {
...MediaDetails
}
}
}
}
`,
variables: {
Expand Down Expand Up @@ -173,6 +194,7 @@ export async function getServerSideProps() {
incomingTokens: data.incomingTokens,
articles: data.articles,
events: dataEvent.events || [],
featuredEvent: dataEvent.featured?.event,
},
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/queries/events/events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { gql } from "@apollo/client"
import { Frag_EventMedia } from "queries/fragments/media"

export const Qu_event = gql`
${Frag_EventMedia}

query Event($where: EventWhereUniqueInput!) {
event(where: $where) {
id
Expand All @@ -12,11 +15,19 @@ export const Qu_event = gql`
endsAt
projectIds
freeLiveMinting
thumbnailMedia {
...MediaDetails
}
headerMedia {
...MediaDetails
}
}
}
`

export const Qu_eventDetails = gql`
${Frag_EventMedia}

query EventDetails($where: EventWhereUniqueInput!) {
event(where: $where) {
id
Expand All @@ -27,6 +38,12 @@ export const Qu_eventDetails = gql`
startsAt
endsAt
projectIds
thumbnailMedia {
...MediaDetails
}
headerMedia {
...MediaDetails
}
onboarding {
id
enabled
Expand Down
22 changes: 22 additions & 0 deletions src/queries/events/featured.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { gql } from "@apollo/client"
import { Frag_EventMedia } from "queries/fragments/media"

export const getFeaturedQuery = gql`
${Frag_EventMedia}

query GetFeatured {
featured(where: { id: 1 }) {
id
event {
id
name
headerMedia {
...MediaDetails
}
thumbnailMedia {
...MediaDetails
}
}
}
}
`
6 changes: 3 additions & 3 deletions src/queries/events/redeemable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { gql } from "@apollo/client"
import { Frag_EventMedia } from "queries/fragments/media"

export const Frag_RedeemableBaseDetails = gql`
fragment RedeemableBaseDetails on Consumable {
Expand All @@ -19,6 +20,7 @@ export const Qu_redeemableBase = gql`

export const Qu_redeemableDetails = gql`
${Frag_RedeemableBaseDetails}
${Frag_EventMedia}

query Consumables($where: ConsumableWhereInput) {
consumables(where: $where) {
Expand All @@ -37,9 +39,7 @@ export const Qu_redeemableDetails = gql`
medias {
index
media {
s3key
name
url
...MediaDetails
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/queries/fragments/event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { gql } from "@apollo/client"
import { Frag_EventMedia } from "./media"

export const Frag_EventCard = gql`
${Frag_EventMedia}

fragment EventCard on Event {
id
name
Expand All @@ -11,5 +14,11 @@ export const Frag_EventCard = gql`
imageUrl
availabilities
description
thumbnailMedia {
...MediaDetails
}
headerMedia {
...MediaDetails
}
}
`
8 changes: 8 additions & 0 deletions src/queries/fragments/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ export const Frag_MediaImage = gql`
processed
}
`

export const Frag_EventMedia = gql`
fragment MediaDetails on Media {
s3key
url
name
}
`
7 changes: 7 additions & 0 deletions src/types/entities/LiveMinting.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EventMedia } from "./EventMedia"
import { User } from "./User"

export enum EventStatus {
Expand Down Expand Up @@ -26,10 +27,16 @@ export interface LiveMintingEvent {
availabilities: EventAvailability[]
status: EventStatus
freeLiveMinting: boolean
thumbnailMedia?: EventMedia | null
headerMedia?: EventMedia | null
}

export type LiveMintingEventWithArtists = LiveMintingEvent & { artists: User[] }

export interface DashboardFeatured {
event: LiveMintingEvent | null
}

export interface LiveMintingPassGroup {
address: string
label: string
Expand Down