1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

creating minimal asset teaser

This commit is contained in:
Jamie Hewitt 2022-10-28 13:12:30 +03:00
parent 9c3dc9fefe
commit 59ffd167ba
3 changed files with 28 additions and 19 deletions

View File

@ -28,6 +28,7 @@ declare type AssetListProps = {
onPageChange?: React.Dispatch<React.SetStateAction<number>> onPageChange?: React.Dispatch<React.SetStateAction<number>>
className?: string className?: string
noPublisher?: boolean noPublisher?: boolean
minimal?: boolean
} }
export default function AssetList({ export default function AssetList({
@ -38,7 +39,8 @@ export default function AssetList({
isLoading, isLoading,
onPageChange, onPageChange,
className, className,
noPublisher noPublisher,
minimal
}: AssetListProps): ReactElement { }: AssetListProps): ReactElement {
const { chainIds } = useUserPreferences() const { chainIds } = useUserPreferences()
const { accountId } = useWeb3() const { accountId } = useWeb3()
@ -85,6 +87,7 @@ export default function AssetList({
asset={assetWithPrice} asset={assetWithPrice}
key={assetWithPrice.id} key={assetWithPrice.id}
noPublisher={noPublisher} noPublisher={noPublisher}
minimal={minimal}
/> />
)) ))
) : ( ) : (

View File

@ -14,11 +14,13 @@ import { useUserPreferences } from '@context/UserPreferences'
declare type AssetTeaserProps = { declare type AssetTeaserProps = {
asset: AssetExtended asset: AssetExtended
noPublisher?: boolean noPublisher?: boolean
minimal?: boolean
} }
export default function AssetTeaser({ export default function AssetTeaser({
asset, asset,
noPublisher noPublisher,
minimal
}: AssetTeaserProps): ReactElement { }: AssetTeaserProps): ReactElement {
const { name, type, description } = asset.metadata const { name, type, description } = asset.metadata
const { datatokens } = asset const { datatokens } = asset
@ -51,13 +53,15 @@ export default function AssetTeaser({
<Dotdotdot tagName="h1" clamp={3} className={styles.title}> <Dotdotdot tagName="h1" clamp={3} className={styles.title}>
{name.slice(0, 200)} {name.slice(0, 200)}
</Dotdotdot> </Dotdotdot>
{!noPublisher && <Publisher account={owner} minimal />} {!noPublisher && !minimal && <Publisher account={owner} minimal />}
</header> </header>
<div className={styles.content}> {!minimal && (
<Dotdotdot tagName="p" clamp={3}> <div className={styles.content}>
{removeMarkdown(description?.substring(0, 300) || '')} <Dotdotdot tagName="p" clamp={3}>
</Dotdotdot> {removeMarkdown(description?.substring(0, 300) || '')}
</div> </Dotdotdot>
</div>
)}
{isUnsupportedPricing ? ( {isUnsupportedPricing ? (
<strong>No pricing schema available</strong> <strong>No pricing schema available</strong>
) : ( ) : (

View File

@ -5,7 +5,7 @@ import { useUserPreferences } from '@context/UserPreferences'
import { SortTermOptions } from '../../../@types/aquarius/SearchQuery' import { SortTermOptions } from '../../../@types/aquarius/SearchQuery'
import styles from './index.module.css' import styles from './index.module.css'
import { useCancelToken } from '@hooks/useCancelToken' import { useCancelToken } from '@hooks/useCancelToken'
import Link from 'next/link' import AssetList from '@shared/AssetList'
export default function RelatedAssets({ export default function RelatedAssets({
tags, tags,
@ -19,6 +19,7 @@ export default function RelatedAssets({
const { chainIds } = useUserPreferences() const { chainIds } = useUserPreferences()
const newCancelToken = useCancelToken() const newCancelToken = useCancelToken()
const [relatedAssets, setRelatedAssets] = useState<Asset[]>() const [relatedAssets, setRelatedAssets] = useState<Asset[]>()
const [isLoading, setIsLoading] = useState<boolean>()
function generateQuery( function generateQuery(
size: number, size: number,
@ -52,13 +53,14 @@ export default function RelatedAssets({
} }
useEffect(() => { useEffect(() => {
setIsLoading(true)
async function getAssets() { async function getAssets() {
const tagQuery = generateBaseQuery(generateQuery(3, true, false)) const tagQuery = generateBaseQuery(generateQuery(3, true, false))
const tagResults = (await queryMetadata(tagQuery, newCancelToken())) const tagResults = (await queryMetadata(tagQuery, newCancelToken()))
.results .results
console.log(tagResults, tagResults.length)
if (tagResults.length === 3) { if (tagResults.length === 3) {
setRelatedAssets(tagResults) setRelatedAssets(tagResults)
setIsLoading(false)
} else { } else {
const ownerQuery = generateBaseQuery( const ownerQuery = generateBaseQuery(
generateQuery(3 - tagResults.length, false, true) generateQuery(3 - tagResults.length, false, true)
@ -67,7 +69,7 @@ export default function RelatedAssets({
.results .results
const bothResults = tagResults.concat(ownerResults) const bothResults = tagResults.concat(ownerResults)
setRelatedAssets(bothResults) setRelatedAssets(bothResults)
console.log(tagResults, tagResults.length) setIsLoading(false)
} }
} }
getAssets() getAssets()
@ -76,14 +78,14 @@ export default function RelatedAssets({
return ( return (
<section className={styles.section}> <section className={styles.section}>
<h3>Related Assets</h3> <h3>Related Assets</h3>
<ul> {relatedAssets && (
{relatedAssets && <AssetList
relatedAssets.map((asset) => ( assets={relatedAssets}
<li key={asset?.id}> showPagination={false}
<Link href={`/asset/${asset?.id}`}>{asset.metadata.name}</Link> isLoading={isLoading}
</li> minimal={true}
))} />
</ul> )}
</section> </section>
) )
} }