query for actual tags, channel teaser tweaks

This commit is contained in:
Matthias Kretschmann 2019-05-24 18:31:01 +02:00
parent 64304644f4
commit 144fce56a3
Signed by: m
GPG Key ID: 606EEEF3C479A91F
9 changed files with 23 additions and 25 deletions

View File

@ -29,13 +29,14 @@
.title { .title {
font-size: $font-size-h4; font-size: $font-size-h4;
margin-top: $spacer * 3;
text-align: center; text-align: center;
margin-bottom: $spacer;
color: $brand-grey-light; color: $brand-grey-light;
border-bottom: 1px solid $brand-grey-lighter;
padding-bottom: $spacer / 4;
margin-top: $spacer * 3;
margin-bottom: $spacer / 2;
@media (min-width: $break-point--small) { @media (min-width: $break-point--small) {
text-align: left; text-align: left;
margin-bottom: $spacer / 2;
} }
} }

View File

@ -4,7 +4,7 @@
width: 100%; width: 100%;
@media (min-width: $break-point--medium) { @media (min-width: $break-point--medium) {
padding-top: $spacer * 2; padding-top: $spacer / 2;
display: flex; display: flex;
} }

View File

@ -25,7 +25,7 @@ export default class ChannelTeaser extends Component<
// Get channel content // Get channel content
public channel = channels.items public channel = channels.items
.filter(({ slug }) => slug === this.props.channel) .filter(({ tag }) => tag === this.props.channel)
.map(channel => channel)[0] .map(channel => channel)[0]
public state = { public state = {
@ -44,9 +44,7 @@ export default class ChannelTeaser extends Component<
offset: 4, offset: 4,
page: 1, page: 1,
query: { query: {
// TODO: replace dummy category tags: [this.channel.tag],
// categories: [this.channel.title],
categories: ['Engineering'],
price: [-1, 1] price: [-1, 1]
}, },
sort: { sort: {
@ -57,7 +55,8 @@ export default class ChannelTeaser extends Component<
try { try {
const search = await ocean.aquarius.queryMetadata(searchQuery) const search = await ocean.aquarius.queryMetadata(searchQuery)
this.setState({ this.setState({
channelAssets: search.results, // TODO: remove hacky way of getting the latest 2 assets
channelAssets: search.results.splice(2, 2, ''),
isLoadingChannel: false isLoadingChannel: false
}) })
} catch (error) { } catch (error) {
@ -68,13 +67,13 @@ export default class ChannelTeaser extends Component<
public render() { public render() {
const { channelAssets, isLoadingChannel } = this.state const { channelAssets, isLoadingChannel } = this.state
const { title, slug, teaser } = this.channel const { title, tag, teaser } = this.channel
return ( return (
<div className={styles.channel}> <div className={styles.channel}>
<div> <div>
<header className={styles.channelHeader}> <header className={styles.channelHeader}>
<Link to={`/channels/${slug}`}> <Link to={`/channels/${tag}`}>
<h2 className={styles.channelTitle}>{title}</h2> <h2 className={styles.channelTitle}>{title}</h2>
<CategoryImage category={title} /> <CategoryImage category={title} />

View File

@ -34,7 +34,7 @@ interface ChannelState {
export default class Channel extends PureComponent<ChannelProps, ChannelState> { export default class Channel extends PureComponent<ChannelProps, ChannelState> {
// get content data based on received channel param // get content data based on received channel param
public channel = channels.items public channel = channels.items
.filter(({ slug }) => slug === this.props.match.params.channel) .filter(({ tag }) => tag === this.props.match.params.channel)
.map(channel => channel)[0] .map(channel => channel)[0]
public state = { public state = {
@ -60,9 +60,7 @@ export default class Channel extends PureComponent<ChannelProps, ChannelState> {
offset, offset,
page: currentPage, page: currentPage,
query: { query: {
// TODO: replace dummy category tags: [this.channel.tag],
// categories: [this.state.title],
categories: ['Engineering'],
price: [-1, 1] price: [-1, 1]
}, },
sort: { sort: {
@ -88,9 +86,7 @@ export default class Channel extends PureComponent<ChannelProps, ChannelState> {
// react-pagination starts counting at 0, we start at 1 // react-pagination starts counting at 0, we start at 1
let toPage = data.selected + 1 let toPage = data.selected + 1
this.props.history.push({ this.props.history.push({ search: `?page=${toPage}` })
search: `?page=${toPage}`
})
await this.setState({ currentPage: toPage, isLoading: true }) await this.setState({ currentPage: toPage, isLoading: true })
await this.getChannelAssets() await this.getChannelAssets()

View File

@ -4,13 +4,13 @@
"items": [ "items": [
{ {
"title": "AI For Good", "title": "AI For Good",
"slug": "ai-for-good", "tag": "ai-for-good",
"teaser": "AI for Good is an initiative to promote the use of artificial intelligence for good causes.", "teaser": "AI for Good is an initiative to promote the use of artificial intelligence for good causes.",
"description": "[AI for Good](https://ai4good.org) is an initiative to promote the use of artificial intelligence for taking action on the UN SDGs such as fighting poverty, climate change, improving healthcare, etc. The AI for Good Commons channel is aimed at helping scale AI for Good by enabling open datasets to be published and shared and connecting AI problem owners with problem solvers." "description": "[AI for Good](https://ai4good.org) is an initiative to promote the use of artificial intelligence for taking action on the UN SDGs such as fighting poverty, climate change, improving healthcare, etc. The AI for Good Commons channel is aimed at helping scale AI for Good by enabling open datasets to be published and shared and connecting AI problem owners with problem solvers."
}, },
{ {
"title": "Test Channel", "title": "Test Channel",
"slug": "test-channel", "tag": "test-channel",
"teaser": "Hello teaser.", "teaser": "Hello teaser.",
"description": "Hello description." "description": "Hello description."
} }

View File

@ -12,7 +12,7 @@ class Channels extends Component {
{channels.items.map(channel => ( {channels.items.map(channel => (
<ChannelTeaser <ChannelTeaser
key={channel.title} key={channel.title}
channel={channel.slug} channel={channel.tag}
/> />
))} ))}
</Content> </Content>

View File

@ -16,14 +16,15 @@
.title { .title {
font-size: $font-size-h4; font-size: $font-size-h4;
margin-top: $spacer * 3;
text-align: center; text-align: center;
margin-bottom: $spacer;
color: $brand-grey-light; color: $brand-grey-light;
border-bottom: 1px solid $brand-grey-lighter;
padding-bottom: $spacer / 4;
margin-top: $spacer * 3;
margin-bottom: $spacer / 2;
@media (min-width: $break-point--small) { @media (min-width: $break-point--small) {
text-align: left; text-align: left;
margin-bottom: $spacer / $line-height;
} }
} }

View File

@ -68,6 +68,7 @@ export default class Home extends Component<HomeProps, HomeState> {
</Content> </Content>
<Content wide> <Content wide>
<h2 className={styles.title}>Featured Channel</h2>
<ChannelTeaser channel="ai-for-good" /> <ChannelTeaser channel="ai-for-good" />
<AssetsLatest /> <AssetsLatest />
</Content> </Content>

View File

@ -15,7 +15,7 @@
}, },
{ {
"name": "aquarius", "name": "aquarius",
"version": "~0.2.2" "version": "~0.2.6"
}, },
{ {
"name": "squid-js", "name": "squid-js",