mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
search results tweaks
This commit is contained in:
parent
78f4d3a12e
commit
7cb54cbd06
@ -3,13 +3,21 @@
|
|||||||
.header {
|
.header {
|
||||||
margin-top: $spacer;
|
margin-top: $spacer;
|
||||||
margin-bottom: $spacer;
|
margin-bottom: $spacer;
|
||||||
|
}
|
||||||
|
|
||||||
h1 {
|
.title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
.description {
|
||||||
margin-top: $spacer / 2;
|
margin-top: $spacer / 2;
|
||||||
font-size: $font-size-large;
|
font-size: $font-size-large;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titleReverse {
|
||||||
|
color: $brand-grey-light;
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: $brand-grey-dark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,14 @@ import meta from '../../data/meta.json'
|
|||||||
const Route = ({
|
const Route = ({
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
titleReverse,
|
||||||
wide,
|
wide,
|
||||||
children,
|
children,
|
||||||
className
|
className
|
||||||
}: {
|
}: {
|
||||||
title: string
|
title: string
|
||||||
description?: string
|
description?: string
|
||||||
|
titleReverse?: boolean
|
||||||
children: any
|
children: any
|
||||||
wide?: boolean
|
wide?: boolean
|
||||||
className?: string
|
className?: string
|
||||||
@ -26,8 +28,22 @@ const Route = ({
|
|||||||
<Content wide={wide}>
|
<Content wide={wide}>
|
||||||
<article>
|
<article>
|
||||||
<header className={styles.header}>
|
<header className={styles.header}>
|
||||||
<h1>{title}</h1>
|
<h1
|
||||||
{description && <p>{description}</p>}
|
className={
|
||||||
|
titleReverse ? styles.titleReverse : styles.title
|
||||||
|
}
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: title
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{description && (
|
||||||
|
<p
|
||||||
|
className={styles.description}
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: description
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import queryString from 'query-string'
|
import queryString from 'query-string'
|
||||||
|
import { Logger } from '@oceanprotocol/squid'
|
||||||
import Spinner from '../components/atoms/Spinner'
|
import Spinner from '../components/atoms/Spinner'
|
||||||
import Route from '../components/templates/Route'
|
import Route from '../components/templates/Route'
|
||||||
import { User } from '../context/User'
|
import { User } from '../context/User'
|
||||||
@ -21,8 +22,21 @@ export default class Search extends Component<SearchProps, SearchState> {
|
|||||||
|
|
||||||
public async componentDidMount() {
|
public async componentDidMount() {
|
||||||
const searchParams = queryString.parse(this.props.location.search)
|
const searchParams = queryString.parse(this.props.location.search)
|
||||||
|
|
||||||
|
const queryRequest = {
|
||||||
|
offset: 500,
|
||||||
|
page: 1,
|
||||||
|
query: {
|
||||||
|
text: searchParams.text
|
||||||
|
},
|
||||||
|
sort: {
|
||||||
|
text: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const assets = await this.context.ocean.assets.search(searchParams.text)
|
const assets = await this.context.ocean.assets.search(searchParams.text)
|
||||||
this.setState({ results: assets, isLoading: false })
|
this.setState({ results: assets, isLoading: false })
|
||||||
|
Logger.log(`Loaded ${assets.length} assets`)
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderResults = () =>
|
public renderResults = () =>
|
||||||
@ -39,8 +53,14 @@ export default class Search extends Component<SearchProps, SearchState> {
|
|||||||
)
|
)
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
const searchTerm = queryString.parse(this.props.location.search).text
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Route title="Search Results" wide>
|
<Route
|
||||||
|
title={`Search Results for <span>${searchTerm}</span>`}
|
||||||
|
titleReverse
|
||||||
|
wide
|
||||||
|
>
|
||||||
{this.renderResults()}
|
{this.renderResults()}
|
||||||
</Route>
|
</Route>
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user