From ed0df26a79fab9870277eb6372ef035fddda820d Mon Sep 17 00:00:00 2001 From: lukas Date: Sun, 7 Jun 2020 22:17:55 +0200 Subject: [PATCH] show video previews on tag click --- src/elements/Preview.js | 4 ++-- src/elements/VideoContainer.js | 8 ++++++-- src/pages/CategoryPage.js | 22 ++++++++++++++++------ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/elements/Preview.js b/src/elements/Preview.js index 43d48ce..0b95e1a 100644 --- a/src/elements/Preview.js +++ b/src/elements/Preview.js @@ -63,7 +63,7 @@ class Preview extends React.Component { } export class TagPreview extends React.Component { - constructor(props: P, context: any) { + constructor(props, context) { super(props, context); this.props = props; @@ -82,7 +82,7 @@ export class TagPreview extends React.Component { .then((response) => response.json() .then((result) => { console.log(result); - this.props.viewbinding.showVideo( + this.props.categorybinding( diff --git a/src/elements/VideoContainer.js b/src/elements/VideoContainer.js index 5ed8ac2..78c5d35 100644 --- a/src/elements/VideoContainer.js +++ b/src/elements/VideoContainer.js @@ -2,7 +2,7 @@ import React from "react"; import Preview from "./Preview"; class VideoContainer extends React.Component { - constructor(props: P, context: any) { + constructor(props, context) { super(props, context); this.data = props.data; @@ -12,6 +12,7 @@ class VideoContainer extends React.Component { selectionnr: null }; } + // stores current index of loaded elements loadindex = 0; @@ -31,6 +32,9 @@ class VideoContainer extends React.Component { movie_id={elem.movie_id} viewbinding={this.props.viewbinding}/> ))} + {/*todo css for no items to show*/} + {this.state.loadeditems.length === 0 ? + "no items to show!" : null} ); } @@ -70,4 +74,4 @@ class VideoContainer extends React.Component { } } -export default VideoContainer; \ No newline at end of file +export default VideoContainer; diff --git a/src/pages/CategoryPage.js b/src/pages/CategoryPage.js index 899656e..dead782 100644 --- a/src/pages/CategoryPage.js +++ b/src/pages/CategoryPage.js @@ -6,13 +6,14 @@ import "../css/CategoryPage.css" import {TagPreview} from "../elements/Preview"; class CategoryPage extends React.Component { - constructor(props: P, context: any) { + constructor(props, context) { super(props, context); this.props = props; this.state = { - loadedtags: [] + loadedtags: [], + selected: false }; } @@ -39,14 +40,17 @@ class CategoryPage extends React.Component {
- {this.state.loadedtags ? + {!this.state.selected ? + (this.state.loadedtags ? this.state.loadedtags.map((m) => ( + viewbinding={this.props.viewbinding} + categorybinding={this.setPage}/> )) : - "loading" + "loading") : + this.selectionelements }
@@ -54,6 +58,12 @@ class CategoryPage extends React.Component { ); } + setPage = (element) => { + this.selectionelements = element; + + this.setState({selected: true}); + }; + /** * load all available tags from db. */ @@ -73,4 +83,4 @@ class CategoryPage extends React.Component { } } -export default CategoryPage; \ No newline at end of file +export default CategoryPage;