-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
497 additions
and
88 deletions.
There are no files selected for viewing
Empty file.
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,29 @@ | ||
import { fetchTokenPages } from '../../../contentful/tokenPage' | ||
import Explore from '../../components/explore/Explore' | ||
import SectionWrapper from '../../components/shared/SectionWrapper' | ||
// import { fetchMarketData } from '../../utils/mango' | ||
import { draftMode } from 'next/headers' | ||
|
||
async function ExplorePage() { | ||
// const marketData = await fetchMarketData() | ||
const tokens = await fetchTokenPages({ | ||
preview: draftMode().isEnabled, | ||
}) | ||
|
||
return ( | ||
<SectionWrapper> | ||
<h1 className="text-5xl mb-10">Explore</h1> | ||
<ul> | ||
{tokens && tokens?.length ? ( | ||
<Explore tokens={tokens} /> | ||
) : ( | ||
<div className="p-6 rounded-xl border border-th-bkg-3"> | ||
<p className="text-center">Nothing to see here...</p> | ||
</div> | ||
)} | ||
</ul> | ||
</SectionWrapper> | ||
) | ||
} | ||
|
||
export default ExplorePage |
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,43 @@ | ||
'use client' | ||
|
||
import { TokenPageWithData } from '../../../contentful/tokenPage' | ||
import { Table, Td, Th, TrBody, TrHead } from '../shared/TableElements' | ||
|
||
const Explore = ({ tokens }: { tokens: TokenPageWithData[] }) => { | ||
return ( | ||
<Table> | ||
<thead> | ||
<TrHead> | ||
<Th className="text-left">Token</Th> | ||
<Th className="text-left">Price</Th> | ||
<Th className="text-left">Change</Th> | ||
</TrHead> | ||
</thead> | ||
<tbody> | ||
{tokens.map((token) => { | ||
const { tokenName, slug, symbol, birdeyeData } = token | ||
const price = birdeyeData?.price || '–' | ||
const change24Hour = birdeyeData?.priceChange24hPercent | ||
? `${birdeyeData.priceChange24hPercent.toFixed(2)}%` | ||
: '–' | ||
return ( | ||
<TrBody key={slug}> | ||
<Td> | ||
<p>{tokenName}</p> | ||
<p>{symbol}</p> | ||
</Td> | ||
<Td> | ||
<p>{price}</p> | ||
</Td> | ||
<Td> | ||
<p>{change24Hour}</p> | ||
</Td> | ||
</TrBody> | ||
) | ||
})} | ||
</tbody> | ||
</Table> | ||
) | ||
} | ||
|
||
export default Explore |
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,120 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { MouseEventHandler, ReactNode, forwardRef } from 'react' | ||
import { LinkButton } from './Button' | ||
import { ArrowSmallDownIcon } from '@heroicons/react/20/solid' | ||
import { SortConfig } from '../../hooks/useSortableData' | ||
|
||
export const Table = ({ | ||
children, | ||
className, | ||
}: { | ||
children: ReactNode | ||
className?: string | ||
}) => <table className={`m-0 min-w-full p-0 ${className}`}>{children}</table> | ||
|
||
export const TrHead = ({ | ||
children, | ||
className, | ||
}: { | ||
children: ReactNode | ||
className?: string | ||
}) => <tr className={`border-b border-th-bkg-3 ${className}`}>{children}</tr> | ||
|
||
export const Th = ({ | ||
children, | ||
className, | ||
id, | ||
xBorder = false, | ||
}: { | ||
children?: ReactNode | ||
className?: string | ||
id?: string | ||
xBorder?: boolean | ||
}) => ( | ||
<th | ||
className={`whitespace-nowrap px-2 py-3 text-xs font-normal text-th-fgd-3 first:pl-6 last:pr-6 xl:px-4 ${ | ||
xBorder ? 'border-x border-th-bkg-3' : '' | ||
} ${className}`} | ||
id={id} | ||
scope="col" | ||
> | ||
{children} | ||
</th> | ||
) | ||
|
||
interface TrBodyProps { | ||
children: ReactNode | ||
className?: string | ||
onClick?: () => void | ||
onMouseEnter?: (x: any) => void | ||
onMouseLeave?: MouseEventHandler | ||
} | ||
|
||
export const TrBody = forwardRef<HTMLTableRowElement, TrBodyProps>( | ||
(props, ref) => { | ||
const { children, className, onClick, onMouseEnter, onMouseLeave } = props | ||
return ( | ||
<tr | ||
className={`border-y border-th-bkg-3 ${className}`} | ||
onClick={onClick} | ||
onMouseEnter={onMouseEnter} | ||
onMouseLeave={onMouseLeave} | ||
ref={ref} | ||
> | ||
{children} | ||
</tr> | ||
) | ||
}, | ||
) | ||
|
||
TrBody.displayName = 'TrBody' | ||
|
||
export const Td = ({ | ||
children, | ||
className, | ||
xBorder = false, | ||
}: { | ||
children: ReactNode | ||
className?: string | ||
xBorder?: boolean | ||
}) => ( | ||
<td | ||
className={`px-2 py-3 first:pl-6 last:pr-6 xl:px-4 ${ | ||
xBorder ? 'border-x border-th-bkg-3' : '' | ||
} ${className}`} | ||
> | ||
{children} | ||
</td> | ||
) | ||
|
||
export const SortableColumnHeader = ({ | ||
sort, | ||
sortConfig, | ||
sortKey, | ||
title, | ||
titleClass, | ||
}: { | ||
sort: (key: string) => void | ||
sortConfig: SortConfig | null | ||
sortKey: string | ||
title: string | ||
titleClass?: string | ||
}) => { | ||
return ( | ||
<LinkButton | ||
className="flex items-center font-normal" | ||
onClick={() => sort(sortKey)} | ||
> | ||
<span className={`text-th-fgd-3 ${titleClass}`}>{title}</span> | ||
<ArrowSmallDownIcon | ||
className={`default-transition ml-1 h-4 w-4 flex-shrink-0 ${ | ||
sortConfig?.key === sortKey | ||
? sortConfig?.direction === 'ascending' | ||
? 'rotate-180' | ||
: 'rotate-360' | ||
: null | ||
}`} | ||
/> | ||
</LinkButton> | ||
) | ||
} |
Oops, something went wrong.