From ce81777030f2e425cba44508839ec385329c587d Mon Sep 17 00:00:00 2001 From: claudiaHash <49017601+claudiaHash@users.noreply.github.com> Date: Mon, 22 Feb 2021 16:25:27 +0200 Subject: [PATCH] view algorithms on homepage (#388) * view algorithms on homepage * linting error fixed * view algos on rinkeby/mainnet, added algos on search * global color system tweak, apply on asset teaser system * create subtle hierarchical distinction between background & content * output asset type * add asset type as css class * bonus side effect: a nicer dark mode theme on OLED screens * add icon assets * compute/download icons added to asset teaser * tooltip content fix * tooltip content width fix tooltip message shortened * max-width added * links renamed, all algos section removed * datatoken tooltip removed * spacing tweaks * visual separation of asset & access type, flip order * spacing/font size tweaks, aligning things * fix search Signed-off-by: mihaisc * light mode color tweak * change dataset display name Signed-off-by: mihaisc * data set label fixed * query updated for data sets and algos Co-authored-by: claudia.holhos Co-authored-by: Matthias Kretschmann Co-authored-by: mihaisc --- src/components/atoms/Box.module.css | 2 +- src/components/atoms/Tooltip.module.css | 1 - .../molecules/AssetTeaser.module.css | 41 ++++++--- src/components/molecules/AssetTeaser.tsx | 33 ++++--- src/components/molecules/SearchBar.module.css | 4 + src/components/pages/Home.tsx | 4 +- .../templates/Search/filterPrice.module.css | 4 + .../templates/Search/filterPrice.tsx | 90 ++++++++++++++----- src/components/templates/Search/index.tsx | 20 ++++- .../templates/Search/sort.module.css | 2 + src/components/templates/Search/sort.tsx | 3 +- src/components/templates/Search/utils.ts | 29 +++++- src/global/_variables.css | 8 +- src/images/compute.svg | 5 ++ src/images/download.svg | 3 + 15 files changed, 189 insertions(+), 60 deletions(-) create mode 100644 src/images/compute.svg create mode 100644 src/images/download.svg diff --git a/src/components/atoms/Box.module.css b/src/components/atoms/Box.module.css index 6d5929b52..f9c4591db 100644 --- a/src/components/atoms/Box.module.css +++ b/src/components/atoms/Box.module.css @@ -1,6 +1,6 @@ .box { display: block; - background: var(--background-body); + background: var(--background-content); border-radius: var(--border-radius); border: 1px solid var(--border-color); box-shadow: 0 6px 17px 0 var(--box-shadow-color); diff --git a/src/components/atoms/Tooltip.module.css b/src/components/atoms/Tooltip.module.css index 637c33369..fb44c7cc9 100644 --- a/src/components/atoms/Tooltip.module.css +++ b/src/components/atoms/Tooltip.module.css @@ -5,7 +5,6 @@ .content { composes: box from './Box.module.css'; padding: calc(var(--spacer) / 4); - width: calc(100% - var(--spacer) / 3); max-width: 25rem; font-size: var(--font-size-small); } diff --git a/src/components/molecules/AssetTeaser.module.css b/src/components/molecules/AssetTeaser.module.css index ed773919d..b7310b51e 100644 --- a/src/components/molecules/AssetTeaser.module.css +++ b/src/components/molecules/AssetTeaser.module.css @@ -14,6 +14,10 @@ flex-direction: column; } +.algorithm .link { + background-color: var(--background-body); +} + .content { margin-top: calc(var(--spacer) / 2); overflow-wrap: break-word; @@ -49,18 +53,6 @@ margin: 0; } -.accessLabel { - font-size: var(--font-size-mini); - width: auto; - position: absolute; - top: 0; - right: 0; - color: var(--brand-black); - background: var(--brand-grey-lighter); - padding: 0.2rem 0.5rem; - border-bottom-left-radius: var(--border-radius); -} - .symbol { display: block; } @@ -69,3 +61,28 @@ font-size: var(--font-size-mini); margin-top: calc(var(--spacer) / 2); } + +.typeDetails { + position: absolute; + top: calc(var(--spacer) / 3); + right: calc(var(--spacer) / 3); + width: auto; + font-size: var(--font-size-mini); +} + +.icon { + fill: var(--brand-grey-light); + width: 1.1em; + height: 1.1em; + vertical-align: baseline; + margin-bottom: -0.2em; + display: inline-block; +} + +.typeLabel { + display: inline-block; + text-transform: uppercase; + border-right: 1px solid var(--border-color); + padding-right: calc(var(--spacer) / 3.5); + margin-right: calc(var(--spacer) / 4); +} diff --git a/src/components/molecules/AssetTeaser.tsx b/src/components/molecules/AssetTeaser.tsx index 68b5eb6db..5aa9c73d8 100644 --- a/src/components/molecules/AssetTeaser.tsx +++ b/src/components/molecules/AssetTeaser.tsx @@ -5,10 +5,11 @@ import Price from '../atoms/Price' import styles from './AssetTeaser.module.css' import { DDO } from '@oceanprotocol/lib' import removeMarkdown from 'remove-markdown' -import Tooltip from '../atoms/Tooltip' import Publisher from '../atoms/Publisher' import { useMetadata } from '@oceanprotocol/react' import Time from '../atoms/Time' +import { ReactComponent as Compute } from '../../images/compute.svg' +import { ReactComponent as Download } from '../../images/download.svg' declare type AssetTeaserProps = { ddo: DDO @@ -17,27 +18,35 @@ declare type AssetTeaserProps = { const AssetTeaser: React.FC = ({ ddo }: AssetTeaserProps) => { const { owner } = useMetadata(ddo) const { attributes } = ddo.findServiceByType('metadata') - const { name } = attributes.main + const { name, type } = attributes.main const { dataTokenInfo } = ddo - const isCompute = Boolean(ddo.findServiceByType('compute')) + const accessType = ddo.service[1].type return ( -
+
- - {dataTokenInfo?.symbol} - +
{dataTokenInfo?.symbol}

{name}

- {isCompute &&
Compute
} + +
diff --git a/src/components/molecules/SearchBar.module.css b/src/components/molecules/SearchBar.module.css index 3dabd9077..c40741f52 100644 --- a/src/components/molecules/SearchBar.module.css +++ b/src/components/molecules/SearchBar.module.css @@ -11,3 +11,7 @@ .form label { display: none; } + +.form input { + background-color: var(--background-content); +} diff --git a/src/components/pages/Home.tsx b/src/components/pages/Home.tsx index 01a318748..68b54a3e9 100644 --- a/src/components/pages/Home.tsx +++ b/src/components/pages/Home.tsx @@ -111,7 +111,7 @@ export default function HomePage(): ReactElement { style="text" to="/search?priceType=pool&sort=liquidity&sortOrder=desc" > - All data sets with pool → + Data sets and algorithms with pool → } /> @@ -121,7 +121,7 @@ export default function HomePage(): ReactElement { query={queryLatest} action={ } /> diff --git a/src/components/templates/Search/filterPrice.module.css b/src/components/templates/Search/filterPrice.module.css index 27fb4735f..79d825f7a 100644 --- a/src/components/templates/Search/filterPrice.module.css +++ b/src/components/templates/Search/filterPrice.module.css @@ -31,3 +31,7 @@ button.filter, background: var(--font-color-text); border-color: var(--background-body); } + +.filterList:first-of-type{ + margin-bottom: calc(var(--spacer) / 6); +} \ No newline at end of file diff --git a/src/components/templates/Search/filterPrice.tsx b/src/components/templates/Search/filterPrice.tsx index c2b2da8fa..620138eba 100644 --- a/src/components/templates/Search/filterPrice.tsx +++ b/src/components/templates/Search/filterPrice.tsx @@ -2,23 +2,37 @@ import React, { ReactElement } from 'react' import { useNavigate } from '@reach/router' import styles from './filterPrice.module.css' import classNames from 'classnames/bind' -import { addExistingParamsToUrl, FilterByPriceOptions } from './utils' +import { + addExistingParamsToUrl, + FilterByPriceOptions, + FilterByTypeOptions +} from './utils' import Button from '../../atoms/Button' const cx = classNames.bind(styles) -const filterItems = [ +const filterItemsPrice = [ { display: 'all', value: undefined }, { display: 'fixed price', value: FilterByPriceOptions.Fixed }, { display: 'dynamic price', value: FilterByPriceOptions.Dynamic } ] +const filterItemsType = [ + { display: 'all', value: undefined }, + { display: 'algorithms', value: FilterByTypeOptions.Algorithm }, + { display: 'data sets', value: FilterByTypeOptions.Data } +] + export default function FilterPrice({ priceType, - setPriceType + setPriceType, + serviceType, + setServiceType }: { priceType: string setPriceType: React.Dispatch> + serviceType: string + setServiceType: React.Dispatch> }): ReactElement { const navigate = useNavigate() @@ -31,27 +45,59 @@ export default function FilterPrice({ navigate(urlLocation) } + async function applyTypeFilter(filterBy: string) { + let urlLocation = await addExistingParamsToUrl(location, 'serviceType') + if (filterBy) { + urlLocation = `${urlLocation}&serviceType=${filterBy}` + } + setServiceType(filterBy) + navigate(urlLocation) + } + return (
- {filterItems.map((e, index) => { - const filter = cx({ - [styles.selected]: e.value === priceType, - [styles.filter]: true - }) - return ( - - ) - })} +
+ {filterItemsType.map((e, index) => { + const filter = cx({ + [styles.selected]: e.value === serviceType, + [styles.filter]: true + }) + return ( + + ) + })} +
+
+ {filterItemsPrice.map((e, index) => { + const filter = cx({ + [styles.selected]: e.value === priceType, + [styles.filter]: true + }) + return ( + + ) + })} +
) } diff --git a/src/components/templates/Search/index.tsx b/src/components/templates/Search/index.tsx index e1d43079a..dc11ee940 100644 --- a/src/components/templates/Search/index.tsx +++ b/src/components/templates/Search/index.tsx @@ -21,10 +21,20 @@ export default function SearchPage({ }): ReactElement { const { config } = useOcean() const parsed = queryString.parse(location.search) - const { text, owner, tags, page, sort, sortOrder, priceType } = parsed + const { + text, + owner, + tags, + page, + sort, + sortOrder, + priceType, + serviceType + } = parsed const [queryResult, setQueryResult] = useState() const [loading, setLoading] = useState() const [price, setPriceType] = useState(priceType as string) + const [type, setType] = useState(serviceType as string) const [sortType, setSortType] = useState(sort as string) const [sortDirection, setSortDirection] = useState( sortOrder as string @@ -49,6 +59,7 @@ export default function SearchPage({ sort, page, priceType, + serviceType, sortOrder, config.metadataCacheUri ]) @@ -69,7 +80,12 @@ export default function SearchPage({ )}
- + { @@ -124,7 +143,8 @@ export async function getResults( categories, sort, sortOrder, - priceType + priceType, + serviceType } = params const metadataCache = new MetadataCache(metadataCacheUri, Logger) const searchQuery = getSearchQuery( @@ -136,7 +156,8 @@ export async function getResults( offset, sort, sortOrder, - priceType + priceType, + serviceType ) const queryResult = await metadataCache.queryMetadata(searchQuery) diff --git a/src/global/_variables.css b/src/global/_variables.css index 1f4d53acf..a27190ad1 100644 --- a/src/global/_variables.css +++ b/src/global/_variables.css @@ -25,8 +25,9 @@ /* Only use these vars for most color referencing for easy light/dark mode */ --font-color-text: #41474e; --font-color-heading: #141414; - --background-body: #fff; + --background-body: #fafafa; --background-body-transparent: rgba(255, 255, 255, 0.8); + --background-content: #fff; --background-highlight: #f7f7f7; --border-color: #e2e2e2; --box-shadow-color: rgba(0, 0, 0, 0.05); @@ -70,8 +71,9 @@ .dark { --font-color-text: #e2e2e2; --font-color-heading: #f7f7f7; - --background-body: #141414; - --background-body-transparent: rgba(20, 20, 20, 0.9); + --background-body: rgb(10, 10, 10); + --background-body-transparent: rgba(10, 10, 10, 0.9); + --background-content: #141414; --background-highlight: #201f1f; --border-color: #303030; --box-shadow-color: rgba(0, 0, 0, 0.2); diff --git a/src/images/compute.svg b/src/images/compute.svg new file mode 100644 index 000000000..0e144af6d --- /dev/null +++ b/src/images/compute.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/images/download.svg b/src/images/download.svg new file mode 100644 index 000000000..14b8981c4 --- /dev/null +++ b/src/images/download.svg @@ -0,0 +1,3 @@ + + +