mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
search result tweaks
This commit is contained in:
parent
8c7d2b7891
commit
c1064f84f8
@ -7,14 +7,13 @@
|
|||||||
.tag {
|
.tag {
|
||||||
color: var(--color-secondary);
|
color: var(--color-secondary);
|
||||||
font-size: var(--font-size-small);
|
font-size: var(--font-size-small);
|
||||||
font-weight: var(--font-weight-bold);
|
padding: 0.1rem 1.2rem 0.1rem 1.2rem;
|
||||||
padding: 0.2rem 1.2rem 0.2rem 1.2rem;
|
margin-left: calc(var(--spacer) / 8);
|
||||||
margin-left: calc(var(--spacer) / 16);
|
margin-right: calc(var(--spacer) / 8);
|
||||||
margin-right: calc(var(--spacer) / 16);
|
margin-bottom: calc(var(--spacer) / 4);
|
||||||
margin-bottom: calc(var(--spacer) / 8);
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
border: 1px solid var(--brand-grey-light);
|
border: 1px solid var(--brand-grey-lighter);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@ -25,10 +24,6 @@
|
|||||||
color: var(--color-primary);
|
color: var(--color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag:first-of-type {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.more {
|
.more {
|
||||||
font-size: var(--font-size-mini);
|
font-size: var(--font-size-mini);
|
||||||
margin-left: calc(var(--spacer) / 8);
|
margin-left: calc(var(--spacer) / 8);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
.foot {
|
.foot {
|
||||||
font-weight: var(--font-weight-bold);
|
font-weight: var(--font-weight-bold);
|
||||||
|
margin-top: calc(var(--spacer) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.foot p {
|
.foot p {
|
||||||
|
@ -2,7 +2,6 @@ import React from 'react'
|
|||||||
import { Link } from 'gatsby'
|
import { Link } from 'gatsby'
|
||||||
import Dotdotdot from 'react-dotdotdot'
|
import Dotdotdot from 'react-dotdotdot'
|
||||||
import { MetaDataMarket } from '../../@types/MetaData'
|
import { MetaDataMarket } from '../../@types/MetaData'
|
||||||
import Tags from '../atoms/Tags'
|
|
||||||
import Price from '../atoms/Price'
|
import Price from '../atoms/Price'
|
||||||
import styles from './AssetTeaser.module.css'
|
import styles from './AssetTeaser.module.css'
|
||||||
|
|
||||||
@ -16,14 +15,7 @@ const AssetTeaser: React.FC<AssetTeaserProps> = ({
|
|||||||
metadata
|
metadata
|
||||||
}: AssetTeaserProps) => {
|
}: AssetTeaserProps) => {
|
||||||
const { name, price } = metadata.main
|
const { name, price } = metadata.main
|
||||||
|
const { description, access } = metadata.additionalInformation
|
||||||
const {
|
|
||||||
description,
|
|
||||||
copyrightHolder,
|
|
||||||
tags,
|
|
||||||
categories,
|
|
||||||
access
|
|
||||||
} = metadata.additionalInformation
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className={styles.teaser}>
|
<article className={styles.teaser}>
|
||||||
@ -37,14 +29,10 @@ const AssetTeaser: React.FC<AssetTeaserProps> = ({
|
|||||||
<Dotdotdot tagName="p" clamp={3}>
|
<Dotdotdot tagName="p" clamp={3}>
|
||||||
{description || ''}
|
{description || ''}
|
||||||
</Dotdotdot>
|
</Dotdotdot>
|
||||||
|
|
||||||
{tags && (
|
|
||||||
<Tags className={styles.tags} items={tags} max={3} noLinks />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer className={styles.foot}>
|
<footer className={styles.foot}>
|
||||||
<Price price={price} small />
|
<Price price={price} />
|
||||||
</footer>
|
</footer>
|
||||||
</Link>
|
</Link>
|
||||||
</article>
|
</article>
|
||||||
|
@ -12,35 +12,14 @@ export default function MetaFull({
|
|||||||
metadata: MetaDataMarket
|
metadata: MetaDataMarket
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { dateCreated, datePublished, author, license } = metadata.main
|
const { dateCreated, datePublished, author, license } = metadata.main
|
||||||
let dateRange
|
const { categories } = metadata.additionalInformation
|
||||||
if (metadata && metadata.additionalInformation) {
|
|
||||||
;({ dateRange } = metadata.additionalInformation)
|
|
||||||
}
|
|
||||||
|
|
||||||
// In practice dateRange will always be defined, but in the rare case it isn't
|
|
||||||
// we put something to prevent errors
|
|
||||||
if (!dateRange) {
|
|
||||||
dateRange = [dateCreated, dateCreated]
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.metaFull}>
|
<div className={styles.metaFull}>
|
||||||
<MetaItem title="Author" content={author} />
|
<MetaItem title="Author" content={author} />
|
||||||
<MetaItem title="License" content={license} />
|
<MetaItem title="License" content={license} />
|
||||||
<MetaItem
|
<MetaItem title="Category" content={categories[0]} />
|
||||||
title="Data Created"
|
<MetaItem title="Data Created" content={<Time date={dateCreated} />} />
|
||||||
content={
|
|
||||||
dateRange && dateRange[0] !== dateRange[1] ? (
|
|
||||||
<>
|
|
||||||
<Time date={dateRange[0]} />
|
|
||||||
{' – '}
|
|
||||||
<Time date={dateRange[1]} />
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Time date={dateRange[0]} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<MetaItem
|
<MetaItem
|
||||||
title="Data Published"
|
title="Data Published"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement, ReactNode } from 'react'
|
||||||
import styles from './MetaItem.module.css'
|
import styles from './MetaItem.module.css'
|
||||||
|
|
||||||
export default function MetaItem({
|
export default function MetaItem({
|
||||||
@ -6,7 +6,7 @@ export default function MetaItem({
|
|||||||
content
|
content
|
||||||
}: {
|
}: {
|
||||||
title: string
|
title: string
|
||||||
content: any
|
content: ReactNode
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
return (
|
return (
|
||||||
<div className={styles.metaItem}>
|
<div className={styles.metaItem}>
|
||||||
|
@ -12,6 +12,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.samples {
|
.samples {
|
||||||
composes: box from '../../atoms/Box.module.css';
|
|
||||||
margin-top: calc(var(--spacer) / 2);
|
margin-top: calc(var(--spacer) / 2);
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,14 @@ import { ListItem } from '../../atoms/Lists'
|
|||||||
import MetaItem from './MetaItem'
|
import MetaItem from './MetaItem'
|
||||||
import styles from './MetaSecondary.module.css'
|
import styles from './MetaSecondary.module.css'
|
||||||
import { MetaDataMarket } from '../../../@types/MetaData'
|
import { MetaDataMarket } from '../../../@types/MetaData'
|
||||||
|
import Tags from '../../atoms/Tags'
|
||||||
|
|
||||||
export default function MetaSecondary({
|
export default function MetaSecondary({
|
||||||
metadata
|
metadata
|
||||||
}: {
|
}: {
|
||||||
metadata: MetaDataMarket
|
metadata: MetaDataMarket
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
let links
|
const { links, tags } = metadata.additionalInformation
|
||||||
if (metadata && metadata.additionalInformation) {
|
|
||||||
;({ links } = metadata.additionalInformation)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className={styles.metaSecondary}>
|
<aside className={styles.metaSecondary}>
|
||||||
@ -33,6 +31,8 @@ export default function MetaSecondary({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{tags && tags.length > 0 && <Tags items={tags} />}
|
||||||
</aside>
|
</aside>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import React, { ReactElement } from 'react'
|
|||||||
import Time from '../../atoms/Time'
|
import Time from '../../atoms/Time'
|
||||||
import { Link } from 'gatsby'
|
import { Link } from 'gatsby'
|
||||||
import Markdown from '../../atoms/Markdown'
|
import Markdown from '../../atoms/Markdown'
|
||||||
import Tags from '../../atoms/Tags'
|
|
||||||
import MetaFull from './MetaFull'
|
import MetaFull from './MetaFull'
|
||||||
import MetaSecondary from './MetaSecondary'
|
import MetaSecondary from './MetaSecondary'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
@ -20,7 +19,7 @@ export default function AssetContent({
|
|||||||
did
|
did
|
||||||
}: AssetContentProps): ReactElement {
|
}: AssetContentProps): ReactElement {
|
||||||
const { datePublished } = metadata.main
|
const { datePublished } = metadata.main
|
||||||
const { description, categories, tags } = metadata.additionalInformation
|
const { description, categories } = metadata.additionalInformation
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className={styles.grid}>
|
<article className={styles.grid}>
|
||||||
@ -38,8 +37,6 @@ export default function AssetContent({
|
|||||||
|
|
||||||
<Markdown text={description || ''} />
|
<Markdown text={description || ''} />
|
||||||
|
|
||||||
{tags && tags.length > 0 && <Tags items={tags} />}
|
|
||||||
|
|
||||||
<MetaSecondary metadata={metadata} />
|
<MetaSecondary metadata={metadata} />
|
||||||
|
|
||||||
<MetaFull did={did} metadata={metadata} />
|
<MetaFull did={did} metadata={metadata} />
|
||||||
|
@ -10,17 +10,21 @@
|
|||||||
@media (min-width: 55rem) {
|
@media (min-width: 55rem) {
|
||||||
.grid {
|
.grid {
|
||||||
grid-column-gap: calc(var(--spacer) * 3);
|
grid-column-gap: calc(var(--spacer) * 3);
|
||||||
grid-template-columns: minmax(0, 1fr) 3fr;
|
grid-template-columns: minmax(0, 3fr) 1fr;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
'side search'
|
'search side'
|
||||||
'side results';
|
'results side';
|
||||||
}
|
}
|
||||||
|
|
||||||
.search {
|
.search {
|
||||||
grid-area: search;
|
grid-area: search;
|
||||||
}
|
}
|
||||||
|
|
||||||
.side {
|
.side {
|
||||||
grid-area: side;
|
grid-area: side;
|
||||||
|
margin-top: calc(var(--spacer) * 2.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
.results {
|
.results {
|
||||||
grid-area: results;
|
grid-area: results;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import { SearchPriceFilter } from '../../molecules/SearchPriceFilter'
|
|||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import queryString from 'query-string'
|
import queryString from 'query-string'
|
||||||
import { getResults } from './utils'
|
import { getResults } from './utils'
|
||||||
|
import Loader from '../../atoms/Loader'
|
||||||
|
|
||||||
export declare type SearchPageProps = {
|
export declare type SearchPageProps = {
|
||||||
text: string | string[]
|
text: string | string[]
|
||||||
@ -22,14 +23,16 @@ export default function SearchPage({
|
|||||||
const parsed = queryString.parse(location.search)
|
const parsed = queryString.parse(location.search)
|
||||||
const { text, tag } = parsed
|
const { text, tag } = parsed
|
||||||
const [queryResult, setQueryResult] = useState<QueryResult>()
|
const [queryResult, setQueryResult] = useState<QueryResult>()
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function initSearch() {
|
async function initSearch() {
|
||||||
const queryResult = await getResults(parsed)
|
const queryResult = await getResults(parsed)
|
||||||
setQueryResult(queryResult)
|
setQueryResult(queryResult)
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
initSearch()
|
initSearch()
|
||||||
}, [parsed])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={styles.grid}>
|
<section className={styles.grid}>
|
||||||
@ -42,7 +45,9 @@ export default function SearchPage({
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<div className={styles.results}>
|
<div className={styles.results}>
|
||||||
{queryResult && queryResult.results.length > 0 ? (
|
{loading ? (
|
||||||
|
<Loader />
|
||||||
|
) : queryResult && queryResult.results.length > 0 ? (
|
||||||
<AssetList queryResult={queryResult} />
|
<AssetList queryResult={queryResult} />
|
||||||
) : (
|
) : (
|
||||||
<div className={styles.empty}>No results found.</div>
|
<div className={styles.empty}>No results found.</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user