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

View File

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

View File

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