From d9ee95a008375bc46ed6fd0b744fed964639f55d Mon Sep 17 00:00:00 2001 From: NikolaBorislavovHristov Date: Tue, 28 May 2019 17:50:08 +0300 Subject: [PATCH] MetaPreview wip --- src/common/MetaPreview/MetaPreview.js | 148 ++++++++++++++++++++++++++ src/common/MetaPreview/index.js | 3 + src/common/MetaPreview/styles.less | 118 ++++++++++++++++++++ src/common/index.js | 2 + 4 files changed, 271 insertions(+) create mode 100644 src/common/MetaPreview/MetaPreview.js create mode 100644 src/common/MetaPreview/index.js create mode 100644 src/common/MetaPreview/styles.less diff --git a/src/common/MetaPreview/MetaPreview.js b/src/common/MetaPreview/MetaPreview.js new file mode 100644 index 000000000..3817c2d46 --- /dev/null +++ b/src/common/MetaPreview/MetaPreview.js @@ -0,0 +1,148 @@ +const React = require('react'); +const classnames = require('classnames'); +const Icon = require('stremio-icons/dom'); +const { Input } = require('stremio-navigation'); +const styles = require('./styles'); + +const MetaPreview = ({ className, compact, id, type, name, logo = '', background = '', duration = '', releaseInfo = '', released, description, genres = [], writers = [], directors = [], cast = [], imdbId = '', imdbRating = '', inLibrary = false, trailer = '', share = '', toggleLibraryOnClick }) => { + const logoOnError = React.useCallback((event) => { + event.currentTarget.style.display = 'none'; + }, []); + const releaseInfoText = releaseInfo.length > 0 ? + releaseInfo + : + released instanceof Date && !isNaN(released.getFullYear()) ? + released.getFullYear() + : + ''; + return ( +
+
+ + { + releaseInfoText.length > 0 || duration.length > 0 ? +
+ { + releaseInfoText.length > 0 ? +
{releaseInfoText}
+ : + null + } + { + duration.length > 0 ? +
{duration}
+ : + null + } +
+ : + null + } + { + name.length > 0 ? +
+
{name}
+
+ : + null + } + { + description.length > 0 ? +
+
{description}
+
+ : + null + } + { + genres.length > 0 ? +
+
Genres:
+ {genres.map((genre) => ( + + {genre} + + ))} +
+ : + null + } +
+ {/* + { + writers.length > 0 ? +
+
Writers
+ {writers.map((writer) => ( + + {writer} + + ))} +
+ : + null + } + { + cast.length > 0 ? +
+
Cast
+ {cast.map((actor) => ( + + {actor} + + ))} +
+ : + null + } +
+ { + trailer.length > 0 ? + + +
Trailer
+ + : + null + } + { + imdbId.length > 0 ? + + + { + imdbRating.length > 0 ? +
{imdbRating} / 10
+ : + null + } + + : + null + } + + +
{inLibrary ? 'Remove from Library' : 'Add to library'}
+ + { + share.length > 0 ? + + +
Share
+ { + shareModalOpen ? + + + + : + null + } + + : + null + } +
*/} +
+ ); +}; + +module.exports = MetaPreview; diff --git a/src/common/MetaPreview/index.js b/src/common/MetaPreview/index.js new file mode 100644 index 000000000..5c06344a2 --- /dev/null +++ b/src/common/MetaPreview/index.js @@ -0,0 +1,3 @@ +const MetaItemPreview = require('./MetaPreview'); + +module.exports = MetaItemPreview; diff --git a/src/common/MetaPreview/styles.less b/src/common/MetaPreview/styles.less new file mode 100644 index 000000000..dab5b60d0 --- /dev/null +++ b/src/common/MetaPreview/styles.less @@ -0,0 +1,118 @@ +.meta-preview-container { + background-color: var(--color-backgrounddarker); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + background-origin: border-box; + color: var(--color-surfacelighter); + + &.compact { + .meta-preview-content { + + .logo { + width: 100%; + object-position: center; + background-color: var(--color-surfacedark20); + } + + .duration-release-info-container { + justify-content: space-evenly; + + .duration, .release-info { + margin-left: 0.4em; + margin-right: 0.4em; + } + } + } + } + + .meta-preview-content { + width: 100%; + height: 100%; + padding: 0.8em; + background-color: var(--color-backgrounddarker60); + + .logo { + max-width: 100%; + height: 7em; + margin-bottom: 0.8em; + object-fit: contain; + object-position: left center; + } + + .duration-release-info-container { + width: 100%; + display: flex; + flex-direction: row; + align-items: flex-start; + justify-content: flex-start; + flex-wrap: wrap; + + .duration, .release-info { + flex-grow: 0; + flex-shrink: 1; + margin-bottom: 0.8em; + margin-right: 0.8em; + line-height: 1.1em; + max-height: 2.2em; + text-align: center; + word-wrap: break-word; + word-break: break-word; + } + } + + .name-container { + width: 100%; + margin-bottom: 0.8em; + + .name { + font-size: 1.3em; + line-height: 1.2em; + max-height: 3.6em; + word-wrap: break-word; + word-break: break-word; + } + } + + .description-container { + width: 100%; + margin-bottom: 0.8em; + + .description { + font-size: 0.9em; + line-height: 1.15em; + max-height: 4.8em; + word-wrap: break-word; + word-break: break-word; + } + } + + .links-container { + width: 100%; + max-height: 3.2em; + margin-bottom: 0.8em; + + .title { + width: 100%; + white-space: nowrap; + text-overflow: ellipsis; + color: var(--color-surfacelight); + } + + .link { + display: inline-block; + max-width: 100%; + padding-right: 0.4em; + font-size: 0.9em; + line-height: 1.15em; + white-space: nowrap; + text-overflow: ellipsis; + color: var(--color-surfacelighter); + + &:hover { + text-decoration: underline; + } + } + } + } +} \ No newline at end of file diff --git a/src/common/index.js b/src/common/index.js index a0fa5d837..de3a88e81 100644 --- a/src/common/index.js +++ b/src/common/index.js @@ -3,6 +3,7 @@ const ColorPicker = require('./ColorPicker'); const Loader = require('./Loader'); const MainNavBar = require('./MainNavBar'); const MetaItem = require('./MetaItem'); +const MetaPreview = require('./MetaPreview'); const NavBar = require('./NavBar'); const Popup = require('./Popup'); const ShareModal = require('./ShareModal'); @@ -17,6 +18,7 @@ module.exports = { Loader, MainNavBar, MetaItem, + MetaPreview, NavBar, Popup, ShareModal,