outpout category image on Asset page, refactor Asset components
@ -3,7 +3,6 @@ import { Route, Switch } from 'react-router-dom'
|
||||
import withTracker from './hoc/withTracker'
|
||||
|
||||
import About from './routes/About'
|
||||
import Details from './routes/Details/'
|
||||
import Home from './routes/Home'
|
||||
import NotFound from './routes/NotFound'
|
||||
import Publish from './routes/Publish/'
|
||||
@ -13,6 +12,7 @@ import History from './routes/History'
|
||||
import Channels from './routes/Channels'
|
||||
import Styleguide from './routes/Styleguide'
|
||||
|
||||
import Asset from './components/templates/Asset'
|
||||
import Channel from './components/templates/Channel'
|
||||
|
||||
const Routes = () => (
|
||||
@ -22,7 +22,7 @@ const Routes = () => (
|
||||
<Route component={withTracker(About)} path="/about" />
|
||||
<Route component={withTracker(Publish)} path="/publish" />
|
||||
<Route component={withTracker(Search)} path="/search" />
|
||||
<Route component={withTracker(Details)} path="/asset/:did" />
|
||||
<Route component={withTracker(Asset)} path="/asset/:did" />
|
||||
<Route component={withTracker(Faucet)} path="/faucet" />
|
||||
<Route component={withTracker(History)} path="/history" />
|
||||
<Route component={withTracker(Channels)} exact path="/channels" />
|
||||
|
@ -11,3 +11,10 @@
|
||||
opacity: .8;
|
||||
transition: .2s ease-out;
|
||||
}
|
||||
|
||||
.header {
|
||||
composes: categoryImage;
|
||||
height: 8rem;
|
||||
margin-top: $spacer;
|
||||
opacity: .5;
|
||||
}
|
||||
|
@ -138,13 +138,18 @@ const categoryImageFile = (category: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
export default class CategoryImage extends PureComponent<{ category: string }> {
|
||||
export default class CategoryImage extends PureComponent<{
|
||||
category: string
|
||||
header?: boolean
|
||||
}> {
|
||||
public render() {
|
||||
const image = categoryImageFile(this.props.category)
|
||||
|
||||
return (
|
||||
<div
|
||||
className={styles.categoryImage}
|
||||
className={
|
||||
this.props.header ? styles.header : styles.categoryImage
|
||||
}
|
||||
style={{
|
||||
backgroundImage: `url(${image})`
|
||||
}}
|
||||
|
@ -3,10 +3,10 @@ import { Link } from 'react-router-dom'
|
||||
import moment from 'moment'
|
||||
import Dotdotdot from 'react-dotdotdot'
|
||||
import cx from 'classnames'
|
||||
import styles from './Asset.module.scss'
|
||||
import styles from './AssetTeaser.module.scss'
|
||||
import CategoryImage from '../atoms/CategoryImage'
|
||||
|
||||
const Asset = ({
|
||||
const AssetTeaser = ({
|
||||
asset,
|
||||
list,
|
||||
minimal
|
||||
@ -55,4 +55,4 @@ const Asset = ({
|
||||
)
|
||||
}
|
||||
|
||||
export default Asset
|
||||
export default AssetTeaser
|
@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'
|
||||
import { Logger } from '@oceanprotocol/squid'
|
||||
import { User } from '../../context'
|
||||
import Spinner from '../atoms/Spinner'
|
||||
import Asset from '../molecules/Asset'
|
||||
import AssetTeaser from '../molecules/AssetTeaser'
|
||||
import styles from './AssetsLatest.module.scss'
|
||||
|
||||
interface AssetsLatestState {
|
||||
@ -62,7 +62,11 @@ export default class AssetsLatest extends PureComponent<{}, AssetsLatestState> {
|
||||
) : latestAssets && latestAssets.length ? (
|
||||
<div className={styles.latestAssets}>
|
||||
{latestAssets.map((asset: any) => (
|
||||
<Asset key={asset.id} asset={asset} minimal />
|
||||
<AssetTeaser
|
||||
key={asset.id}
|
||||
asset={asset}
|
||||
minimal
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
|
@ -3,7 +3,7 @@ import { Link } from 'react-router-dom'
|
||||
import { Logger } from '@oceanprotocol/squid'
|
||||
import { User } from '../../context'
|
||||
import Spinner from '../atoms/Spinner'
|
||||
import Asset from '../molecules/Asset'
|
||||
import AssetTeaser from '../molecules/AssetTeaser'
|
||||
import styles from './AssetsUser.module.scss'
|
||||
|
||||
export default class AssetsUser extends PureComponent<
|
||||
@ -82,7 +82,7 @@ export default class AssetsUser extends PureComponent<
|
||||
)
|
||||
.filter(asset => !!asset)
|
||||
.map((asset: any) => (
|
||||
<Asset
|
||||
<AssetTeaser
|
||||
list={this.props.list}
|
||||
key={asset.id}
|
||||
asset={asset}
|
||||
|
@ -3,7 +3,7 @@ import { Link } from 'react-router-dom'
|
||||
import { User } from '../../context'
|
||||
import { Logger } from '@oceanprotocol/squid'
|
||||
import Spinner from '../atoms/Spinner'
|
||||
import Asset from '../molecules/Asset'
|
||||
import AssetTeaser from '../molecules/AssetTeaser'
|
||||
import styles from './ChannelTeaser.module.scss'
|
||||
import channels from '../../data/channels.json'
|
||||
|
||||
@ -85,7 +85,7 @@ export default class ChannelTeaser extends Component<
|
||||
) : channelAssets && channelAssets.length ? (
|
||||
<div className={styles.channelResults}>
|
||||
{channelAssets.map((asset: any) => (
|
||||
<Asset key={asset.id} asset={asset} />
|
||||
<AssetTeaser key={asset.id} asset={asset} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
|
@ -1,4 +1,4 @@
|
||||
@import '../../styles/variables';
|
||||
@import '../../../styles/variables';
|
||||
|
||||
.metaPrimary {
|
||||
margin-bottom: $spacer;
|
@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import Moment from 'react-moment'
|
||||
import { DDO, MetaData, File } from '@oceanprotocol/squid'
|
||||
import Markdown from '../../components/atoms/Markdown'
|
||||
import Markdown from '../../atoms/Markdown'
|
||||
import styles from './AssetDetails.module.scss'
|
||||
import AssetFilesDetails from './AssetFilesDetails'
|
||||
|
@ -1,4 +1,4 @@
|
||||
@import '../../styles/variables';
|
||||
@import '../../../styles/variables';
|
||||
|
||||
.buttonMain {
|
||||
margin: auto;
|
@ -5,7 +5,7 @@ import { render, fireEvent } from 'react-testing-library'
|
||||
import { DDO } from '@oceanprotocol/squid'
|
||||
import { StateMock } from '@react-mock/state'
|
||||
import ReactGA from 'react-ga'
|
||||
import { User } from '../../context'
|
||||
import { User } from '../../../context'
|
||||
import AssetFile, { messages } from './AssetFile'
|
||||
|
||||
const file = {
|
@ -1,9 +1,9 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import { Logger, DDO, File } from '@oceanprotocol/squid'
|
||||
import filesize from 'filesize'
|
||||
import Button from '../../components/atoms/Button'
|
||||
import Spinner from '../../components/atoms/Spinner'
|
||||
import { User } from '../../context'
|
||||
import Button from '../../atoms/Button'
|
||||
import Spinner from '../../atoms/Spinner'
|
||||
import { User } from '../../../context'
|
||||
import styles from './AssetFile.module.scss'
|
||||
import ReactGA from 'react-ga'
|
||||
|
@ -1,4 +1,4 @@
|
||||
@import '../../styles/variables';
|
||||
@import '../../../styles/variables';
|
||||
|
||||
.files {
|
||||
text-align: center;
|
@ -4,8 +4,8 @@ import React from 'react'
|
||||
import { render } from 'react-testing-library'
|
||||
import { DDO } from '@oceanprotocol/squid'
|
||||
import AssetFilesDetails from './AssetFilesDetails'
|
||||
import { User } from '../../context'
|
||||
import { userMockConnected } from '../../../__mocks__/user-mock'
|
||||
import { User } from '../../../context'
|
||||
import { userMockConnected } from '../../../../__mocks__/user-mock'
|
||||
|
||||
describe('AssetFilesDetails', () => {
|
||||
it('renders without crashing', () => {
|
@ -1,8 +1,8 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import { DDO, File } from '@oceanprotocol/squid'
|
||||
import AssetFile from './AssetFile'
|
||||
import { User } from '../../context'
|
||||
import Web3message from '../../components/organisms/Web3message'
|
||||
import { User } from '../../../context'
|
||||
import Web3message from '../../organisms/Web3message'
|
||||
import styles from './AssetFilesDetails.module.scss'
|
||||
|
||||
export default class AssetFilesDetails extends PureComponent<{
|
@ -1,11 +1,12 @@
|
||||
import React, { Component } from 'react'
|
||||
import { DDO, MetaData, Logger } from '@oceanprotocol/squid'
|
||||
import Route from '../../components/templates/Route'
|
||||
import Spinner from '../../components/atoms/Spinner'
|
||||
import { User } from '../../context'
|
||||
import Route from '../Route'
|
||||
import Spinner from '../../atoms/Spinner'
|
||||
import { User } from '../../../context'
|
||||
import AssetDetails from './AssetDetails'
|
||||
import stylesApp from '../../App.module.scss'
|
||||
import Content from '../../components/atoms/Content'
|
||||
import stylesApp from '../../../App.module.scss'
|
||||
import Content from '../../atoms/Content'
|
||||
import CategoryImage from '../../atoms/CategoryImage'
|
||||
|
||||
interface DetailsProps {
|
||||
location: Location
|
||||
@ -46,7 +47,17 @@ export default class Details extends Component<DetailsProps, DetailsState> {
|
||||
const { metadata, ddo } = this.state
|
||||
|
||||
return metadata.base.name !== '' ? (
|
||||
<Route title={metadata.base.name}>
|
||||
<Route
|
||||
title={metadata.base.name}
|
||||
image={
|
||||
metadata.base.categories && (
|
||||
<CategoryImage
|
||||
header
|
||||
category={metadata.base.categories[0]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
>
|
||||
<Content>
|
||||
<AssetDetails metadata={metadata} ddo={ddo} />
|
||||
</Content>
|
@ -4,7 +4,7 @@ import { History } from 'history'
|
||||
import Spinner from '../../components/atoms/Spinner'
|
||||
import Route from '../../components/templates/Route'
|
||||
import { User } from '../../context'
|
||||
import Asset from '../../components/molecules/Asset'
|
||||
import AssetTeaser from '../molecules/AssetTeaser'
|
||||
import Pagination from '../../components/molecules/Pagination'
|
||||
import styles from './Channel.module.scss'
|
||||
import Content from '../../components/atoms/Content'
|
||||
@ -101,7 +101,7 @@ export default class Channel extends PureComponent<ChannelProps, ChannelState> {
|
||||
) : this.state.results && this.state.results.length ? (
|
||||
<div className={styles.results}>
|
||||
{this.state.results.map((asset: any) => (
|
||||
<Asset key={asset.id} asset={asset} />
|
||||
<AssetTeaser key={asset.id} asset={asset} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
|
@ -8,12 +8,14 @@ import Markdown from '../atoms/Markdown'
|
||||
const Route = ({
|
||||
title,
|
||||
description,
|
||||
image,
|
||||
wide,
|
||||
children,
|
||||
className
|
||||
}: {
|
||||
title: string
|
||||
description?: string
|
||||
image?: any
|
||||
children: any
|
||||
wide?: boolean
|
||||
className?: string
|
||||
@ -29,6 +31,7 @@ const Route = ({
|
||||
<header className={styles.header}>
|
||||
<Content wide={wide}>
|
||||
<h1 className={styles.title}>{title}</h1>
|
||||
{image && image}
|
||||
{description && (
|
||||
<Markdown
|
||||
text={description}
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 224 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 178 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 197 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 246 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 217 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 210 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 278 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 284 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 186 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 226 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 279 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 209 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 269 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 209 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 282 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 109 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 158 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 183 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 423 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 227 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 196 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 112 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 318 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 204 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 140 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 326 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 222 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 182 KiB |
@ -5,7 +5,7 @@ import { Logger } from '@oceanprotocol/squid'
|
||||
import Spinner from '../components/atoms/Spinner'
|
||||
import Route from '../components/templates/Route'
|
||||
import { User } from '../context'
|
||||
import Asset from '../components/molecules/Asset'
|
||||
import AssetTeaser from '../components/molecules/AssetTeaser'
|
||||
import Pagination from '../components/molecules/Pagination'
|
||||
import styles from './Search.module.scss'
|
||||
import Content from '../components/atoms/Content'
|
||||
@ -119,7 +119,7 @@ export default class Search extends PureComponent<SearchProps, SearchState> {
|
||||
) : this.state.results && this.state.results.length ? (
|
||||
<div className={styles.results}>
|
||||
{this.state.results.map((asset: any) => (
|
||||
<Asset key={asset.id} asset={asset} />
|
||||
<AssetTeaser key={asset.id} asset={asset} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
|