From a67fa5603eed232a826ab13c84b13a0165539852 Mon Sep 17 00:00:00 2001 From: svetlagasheva Date: Tue, 11 Sep 2018 17:10:48 +0300 Subject: [PATCH] 'LibraryItemList' component --- src/common/LibraryItemList/LibraryItemList.js | 147 ++++++++++++++++++ src/common/LibraryItemList/index.js | 3 + src/common/LibraryItemList/styles.less | 83 ++++++++++ src/common/index.js | 4 +- src/routes/Board/Board.js | 9 +- 5 files changed, 241 insertions(+), 5 deletions(-) create mode 100644 src/common/LibraryItemList/LibraryItemList.js create mode 100644 src/common/LibraryItemList/index.js create mode 100644 src/common/LibraryItemList/styles.less diff --git a/src/common/LibraryItemList/LibraryItemList.js b/src/common/LibraryItemList/LibraryItemList.js new file mode 100644 index 000000000..db64dff3c --- /dev/null +++ b/src/common/LibraryItemList/LibraryItemList.js @@ -0,0 +1,147 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import Icon from 'stremio-icons/dom'; +import styles from './styles'; + +class LibraryItemList extends Component { + renderPoster() { + if(this.props.poster.length === 0) { + return null; + } + // src? + return ( +
+ +
+ ); + } + + renderPlay() { + return ( +
+ +
+ ); + } + + renderTitle() { + if(this.props.title.length === 0) { + return null; + } + + return ( + {this.props.title} + ); + } + + renderType() { + if(this.props.type.length === 0) { + return null; + } + + return ( + {this.props.type} + ); + } + + renderYear() { + if(this.props.year.length === 0) { + return null; + } + + return ( + {this.props.year} + ); + } + + renderDateAdded() { + if(this.props.dateAdded.length === 0) { + return null; + } + + return ( + {this.props.dateAdded} + ); + } + + renderViews() { + return ( + {this.props.views} + ); + } + + renderHours() { + return ( + {this.props.hours} + ); + } + + renderLastViewed() { + if(this.props.lastViewed.length === 0) { + return null; + } + + return ( + {this.props.lastViewed} + ); + } + + renderTrailerIcon() { + return ( +
+ +

Trailer

+
+ ); + } + + renderAddlibIcon() { + return ( +
+ +

Add to Library

+
+ ); + } + + render() { + return ( +
+ {this.renderPoster()} + {this.renderPlay()} + {this.renderTitle()} + {this.renderType()} + {this.renderYear()} + {this.renderDateAdded()} + {this.renderViews()} + {this.renderHours()} + {this.renderLastViewed()} + {this.renderTrailerIcon()} + {this.renderAddlibIcon()} +
+ ); + } +} + +LibraryItemList.propTypes = { + poster: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + type: PropTypes.string.isRequired, + year: PropTypes.string.isRequired, + dateAdded: PropTypes.string.isRequired, + views: PropTypes.number.isRequired, + hours: PropTypes.number.isRequired, + lastViewed: PropTypes.string.isRequired +}; +LibraryItemList.defaultProps = { + poster: '', + title: '', + type: '', + year: '', + dateAdded: '', + views: 0, + hours: 0, + lastViewed: '' +}; + +export default LibraryItemList; \ No newline at end of file diff --git a/src/common/LibraryItemList/index.js b/src/common/LibraryItemList/index.js new file mode 100644 index 000000000..d622d92a3 --- /dev/null +++ b/src/common/LibraryItemList/index.js @@ -0,0 +1,3 @@ +import LibraryItemList from './LibraryItemList'; + +export default LibraryItemList; diff --git a/src/common/LibraryItemList/styles.less b/src/common/LibraryItemList/styles.less new file mode 100644 index 000000000..41ff2b60b --- /dev/null +++ b/src/common/LibraryItemList/styles.less @@ -0,0 +1,83 @@ +@import 'stremio-colors'; +.library-item { + width: 90%; + display: flex; + padding: 8px; + align-items: center; + color: @colorwhite60; + border-top: 1px solid @colorwhite20; + .poster-container { + display: flex; + height: 110px; + margin-right: 20px; + .poster { + width: 75px; + } + } + .play-container { + width: 52px; + height: 52px; + position: absolute; + padding: 16px 19px; + margin: 0px 11.5px; + .play { + width: 20px; + height: 20px; + fill: @colortransparent; + } + } + .title { + width: 170px; + color: @colorwhite; + } + .type, .year, .views, .hours { + width: 100px; + } + .date-added, .last-viewed { + width: 130px; + } + .icon-container { + width: 100px; + height: 100px; + padding-top: 24px; + text-align: center; + visibility: hidden; + .trailer-icon { + width: 22px; + fill: @colorwhite; + } + .addlib-icon { + width: 34px; + fill: @colorwhite; + } + } + &:hover, &:focus { + cursor: pointer; + color: @colorblack; + background-color: @colorwhite; + .play-container { + border-radius: 50%; + background-color: @colorwhite; + .play { + fill: @colormedium; + } + } + .title { + color: @colorblack; + } + .icon-container { + visibility: visible; + .trailer-icon, .addlib-icon, .trailer, .addlib { + fill: @colorprim; + color: @colorprim; + } + &:hover, &:focus { + background-color: @colorblack20; + .trailer-icon, .addlib-icon, .trailer, .addlib { + fill: @colorprimdark; + color: @colorprimdark; + } + } + } + } +} \ No newline at end of file diff --git a/src/common/index.js b/src/common/index.js index 416f86147..91ae89c6d 100644 --- a/src/common/index.js +++ b/src/common/index.js @@ -6,6 +6,7 @@ import MetadataItem from './MetadataItem'; import Router from './Router'; import Stream from './Stream'; import Episode from './Episode'; +import LibraryItemList from './LibraryItemList'; export { Checkbox, @@ -15,5 +16,6 @@ export { MetadataItem, Router, Stream, - Episode + Episode, + LibraryItemList }; diff --git a/src/routes/Board/Board.js b/src/routes/Board/Board.js index 77d06d245..0c1a5aac6 100644 --- a/src/routes/Board/Board.js +++ b/src/routes/Board/Board.js @@ -3,6 +3,7 @@ import { Catalogs } from 'stremio-aggregators'; import { addons } from 'stremio-services'; import { Stream } from 'stremio-common'; import { Episode } from 'stremio-common'; +import { LibraryItemList } from 'stremio-common'; class Board extends PureComponent { constructor(props) { @@ -31,10 +32,10 @@ class Board extends PureComponent { render() { return (
- - - - + + + +
); }