const React = require('react'); const PropTypes = require('prop-types'); const classnames = require('classnames'); const Icon = require('stremio-icons/dom'); const { Modal } = require('stremio-router'); const Button = require('../Button'); const useBinaryState = require('../useBinaryState'); const styles = require('./styles'); const MetaLinks = ({ label, links, href }) => { return (
{label}
{links.map((link, index) => ( ))}
); }; const ActionButton = ({ icon, label, ...props }) => { return ( ); }; const MetaPreview = ({ className, compact, id, type, name, logo, background, duration, releaseInfo, released, description, genres, writers, directors, cast, imdbId, imdbRating, inLibrary, trailer, share, toggleIsInLibrary }) => { const [shareModalOpen, openShareModal, closeShareModal] = useBinaryState(false); const releaseInfoText = React.useMemo(() => { const releasedDate = new Date(released); return typeof releaseInfo === 'string' && releaseInfo.length > 0 ? releaseInfo : !isNaN(releasedDate.getFullYear()) ? releasedDate.getFullYear() : null; }, [releaseInfo, released]); const logoOnError = React.useCallback((event) => { event.currentTarget.style.display = 'none'; }, []); const hrefForGenre = React.useCallback((genre) => { return `#/discover/${type}//${genre}`; }, [type]); const hrefForCrew = React.useCallback((name) => { return `#/search?q=${name}`; }, []); return (
{ typeof logo === 'string' && logo.length > 0 ? : null } { (typeof releaseInfoText === 'string' && releaseInfoText.length > 0) || (typeof duration === 'string' && duration.length > 0) ?
{ typeof releaseInfoText === 'string' && releaseInfoText.length > 0 ?
{releaseInfoText}
: null } { typeof duration === 'string' && duration.length > 0 ?
{duration}
: null }
: null } { typeof name === 'string' && name.length > 0 ?
{name}
: null } { typeof description === 'string' && description.length > 0 ?
{description}
: null } { Array.isArray(genres) && genres.length > 0 ? : null } { Array.isArray(cast) && cast.length > 0 ? : null } { Array.isArray(writers) && writers.length > 0 && !compact ? : null } { Array.isArray(directors) && directors.length > 0 && !compact ? : null }
{ typeof toggleIsInLibrary === 'function' ? : null } { typeof trailer === 'string' && trailer.length > 0 ? : null } { typeof imdbId === 'string' && imdbId.length > 0 ? 0 ? `${imdbRating} / 10` : null} href={`https://imdb.com/title/${imdbId}`} target={'_blank'} /> : null } { typeof share === 'string' && share.length > 0 && !compact ? { shareModalOpen ?
{ event.stopPropagation(); closeShareModal(); }} style={{ width: '100%', height: '100%', backgroundColor: 'var(--color-surfacedarker40)' }} /> : null } : null }
); }; MetaPreview.propTypes = { className: PropTypes.string, compact: PropTypes.bool, id: PropTypes.string, type: PropTypes.string, name: PropTypes.string, logo: PropTypes.string, background: PropTypes.string, duration: PropTypes.string, releaseInfo: PropTypes.string, released: PropTypes.string, description: PropTypes.string, genres: PropTypes.arrayOf(PropTypes.string), writers: PropTypes.arrayOf(PropTypes.string), directors: PropTypes.arrayOf(PropTypes.string), cast: PropTypes.arrayOf(PropTypes.string), imdbId: PropTypes.string, imdbRating: PropTypes.string, inLibrary: PropTypes.bool, trailer: PropTypes.string, share: PropTypes.string, toggleIsInLibrary: PropTypes.func }; module.exports = MetaPreview;