This commit is contained in:
Sean Yesmunt 2020-01-06 15:57:49 -05:00
parent 72b9f3efdd
commit 618b186ac1
21 changed files with 94 additions and 68 deletions

View file

@ -67,7 +67,7 @@
"@babel/register": "^7.0.0", "@babel/register": "^7.0.0",
"@exponent/electron-cookies": "^2.0.0", "@exponent/electron-cookies": "^2.0.0",
"@hot-loader/react-dom": "^16.8", "@hot-loader/react-dom": "^16.8",
"@lbry/components": "^3.0.4", "@lbry/components": "^3.0.5",
"@reach/menu-button": "^0.1.18", "@reach/menu-button": "^0.1.18",
"@reach/rect": "^0.2.1", "@reach/rect": "^0.2.1",
"@reach/tabs": "^0.1.5", "@reach/tabs": "^0.1.5",

View file

@ -6,7 +6,7 @@ type Props = {
channelUri: string, channelUri: string,
}; };
function LayoutWrapperDocument(props: Props) { function FileAuthor(props: Props) {
const { channelUri } = props; const { channelUri } = props;
return channelUri ? ( return channelUri ? (
@ -16,4 +16,4 @@ function LayoutWrapperDocument(props: Props) {
); );
} }
export default LayoutWrapperDocument; export default FileAuthor;

View file

@ -10,7 +10,7 @@ import {
} from 'lbry-redux'; } from 'lbry-redux';
import { THEME, AUTOPLAY } from 'constants/settings'; import { THEME, AUTOPLAY } from 'constants/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectNextUnplayedRecommended } from 'redux/selectors/content'; import { makeSelectNextUnplayedRecommended, makeSelectIsText } from 'redux/selectors/content';
import FileRender from './view'; import FileRender from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -24,6 +24,7 @@ const select = (state, props) => ({
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state), streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
autoplay: makeSelectClientSetting(AUTOPLAY)(state), autoplay: makeSelectClientSetting(AUTOPLAY)(state),
nextUnplayed: makeSelectNextUnplayedRecommended(props.uri)(state), nextUnplayed: makeSelectNextUnplayedRecommended(props.uri)(state),
isText: makeSelectIsText(props.uri)(state),
}); });
export default connect(select)(FileRender); export default connect(select)(FileRender);

View file

@ -29,6 +29,7 @@ import ThreeViewer from 'component/viewers/threeViewer';
type Props = { type Props = {
uri: string, uri: string,
mediaType: string, mediaType: string,
isText: true,
streamingUrl: string, streamingUrl: string,
contentType: string, contentType: string,
claim: StreamClaim, claim: StreamClaim,
@ -187,10 +188,10 @@ class FileRender extends React.PureComponent<Props> {
} }
render() { render() {
const { mediaType } = this.props; const { isText } = this.props;
return ( return (
<div className={classnames('file-render', { 'file-render--document': mediaType === 'text' })}> <div className={classnames('file-render', { 'file-render--document': isText })}>
<Suspense fallback={<div />}>{this.renderViewer()}</Suspense> <Suspense fallback={<div />}>{this.renderViewer()}</Suspense>
</div> </div>
); );

View file

@ -6,7 +6,7 @@ type Props = {
viewCount: string, viewCount: string,
}; };
function LayoutWrapperDocument(props: Props) { function FileViewCount(props: Props) {
const { viewCount } = props; const { viewCount } = props;
return ( return (
@ -17,4 +17,4 @@ function LayoutWrapperDocument(props: Props) {
); );
} }
export default LayoutWrapperDocument; export default FileViewCount;

View file

@ -16,6 +16,7 @@ import {
makeSelectShouldObscurePreview, makeSelectShouldObscurePreview,
selectPlayingUri, selectPlayingUri,
makeSelectCanAutoplay, makeSelectCanAutoplay,
makeSelectIsText,
} from 'redux/selectors/content'; } from 'redux/selectors/content';
import FileViewer from './view'; import FileViewer from './view';
@ -33,6 +34,7 @@ const select = (state, props) => ({
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)), hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
costInfo: makeSelectCostInfoForUri(props.uri)(state), costInfo: makeSelectCostInfoForUri(props.uri)(state),
isAutoPlayable: makeSelectCanAutoplay(props.uri)(state), isAutoPlayable: makeSelectCanAutoplay(props.uri)(state),
isText: makeSelectIsText(props.uri)(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -14,6 +14,7 @@ const SPACE_BAR_KEYCODE = 32;
type Props = { type Props = {
play: string => void, play: string => void,
mediaType: string, mediaType: string,
isText: boolean,
contentType: string, contentType: string,
isLoading: boolean, isLoading: boolean,
isPlaying: boolean, isPlaying: boolean,
@ -34,6 +35,7 @@ export default function FileViewerInitiator(props: Props) {
const { const {
play, play,
mediaType, mediaType,
isText,
contentType, contentType,
isPlaying, isPlaying,
fileInfo, fileInfo,
@ -50,7 +52,6 @@ export default function FileViewerInitiator(props: Props) {
const cost = costInfo && costInfo.cost; const cost = costInfo && costInfo.cost;
const forceVideo = ['application/x-ext-mkv', 'video/x-matroska'].includes(contentType); const forceVideo = ['application/x-ext-mkv', 'video/x-matroska'].includes(contentType);
const isPlayable = ['audio', 'video'].includes(mediaType) || forceVideo; const isPlayable = ['audio', 'video'].includes(mediaType) || forceVideo;
const isText = mediaType === 'text';
const fileStatus = fileInfo && fileInfo.status; const fileStatus = fileInfo && fileInfo.status;
const webStreamOnly = contentType === 'application/pdf' || mediaType === 'text'; const webStreamOnly = contentType === 'application/pdf' || mediaType === 'text';
const supported = IS_WEB ? (!cost && isStreamable) || webStreamOnly || forceVideo : true; const supported = IS_WEB ? (!cost && isStreamable) || webStreamOnly || forceVideo : true;

View file

@ -10,7 +10,12 @@ import {
makeSelectTitleForUri, makeSelectTitleForUri,
} from 'lbry-redux'; } from 'lbry-redux';
import { doClaimEligiblePurchaseRewards } from 'lbryinc'; import { doClaimEligiblePurchaseRewards } from 'lbryinc';
import { makeSelectIsPlaying, makeSelectShouldObscurePreview, selectPlayingUri } from 'redux/selectors/content'; import {
makeSelectIsPlaying,
makeSelectShouldObscurePreview,
selectPlayingUri,
makeSelectIsText,
} from 'redux/selectors/content';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { doSetPlayingUri } from 'redux/actions/content'; import { doSetPlayingUri } from 'redux/actions/content';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
@ -31,6 +36,7 @@ const select = (state, props) => {
streamingUrl: makeSelectStreamingUrlForUri(uri)(state), streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
isStreamable: makeSelectUriIsStreamable(uri)(state), isStreamable: makeSelectUriIsStreamable(uri)(state),
floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state), floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
isText: makeSelectIsText(uri)(state),
}; };
}; };

View file

@ -17,6 +17,7 @@ import useIsMobile from 'effects/use-is-mobile';
type Props = { type Props = {
mediaType: string, mediaType: string,
contentType: string, contentType: string,
isText: boolean,
isLoading: boolean, isLoading: boolean,
isPlaying: boolean, isPlaying: boolean,
fileInfo: FileListItem, fileInfo: FileListItem,
@ -50,6 +51,7 @@ export default function FileViewer(props: Props) {
claimRewards, claimRewards,
mediaType, mediaType,
contentType, contentType,
isText,
} = props; } = props;
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const [playTime, setPlayTime] = useState(); const [playTime, setPlayTime] = useState();
@ -124,7 +126,7 @@ export default function FileViewer(props: Props) {
} }
const hidePlayer = const hidePlayer =
mediaType === 'text' || isText ||
!isPlaying || !isPlaying ||
!uri || !uri ||
(!inline && (isMobile || !floatingPlayerEnabled || !['audio', 'video'].includes(mediaType))); (!inline && (isMobile || !floatingPlayerEnabled || !['audio', 'video'].includes(mediaType)));

View file

@ -7,8 +7,6 @@ import {
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
doPrepareEdit, doPrepareEdit,
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectMetadataForUri,
makeSelectThumbnailForUri,
} from 'lbry-redux'; } from 'lbry-redux';
import { makeSelectCostInfoForUri } from 'lbryinc'; import { makeSelectCostInfoForUri } from 'lbryinc';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
@ -24,8 +22,6 @@ const select = (state, props) => ({
costInfo: makeSelectCostInfoForUri(props.uri)(state), costInfo: makeSelectCostInfoForUri(props.uri)(state),
supportOption: makeSelectClientSetting(SETTINGS.SUPPORT_OPTION)(state), supportOption: makeSelectClientSetting(SETTINGS.SUPPORT_OPTION)(state),
title: makeSelectTitleForUri(props.uri)(state), title: makeSelectTitleForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -3,33 +3,30 @@ import * as React from 'react';
import { normalizeURI } from 'lbry-redux'; import { normalizeURI } from 'lbry-redux';
import FilePrice from 'component/filePrice'; import FilePrice from 'component/filePrice';
import FileAuthor from 'component/fileAuthor'; import FileAuthor from 'component/fileAuthor';
import FileThumbnail from 'component/fileThumbnail';
import FileViewCount from 'component/fileViewCount'; import FileViewCount from 'component/fileViewCount';
import FileActions from 'component/fileActions'; import FileActions from 'component/fileActions';
import FileDetails from 'component/fileDetails';
import TextViewer from 'component/textViewer'; import TextViewer from 'component/textViewer';
import DateTime from 'component/dateTime'; import DateTime from 'component/dateTime';
import RecommendedContent from 'component/recommendedContent'; import RecommendedContent from 'component/recommendedContent';
import CommentsList from 'component/commentsList'; import CommentsList from 'component/commentsList';
import CommentCreate from 'component/commentCreate'; import CommentCreate from 'component/commentCreate';
import MarkdownPreview from 'component/common/markdown-preview';
import ClaimUri from 'component/claimUri'; import ClaimUri from 'component/claimUri';
import FileViewerInitiator from 'component/fileViewerInitiator'; import FileViewerInitiator from 'component/fileViewerInitiator';
type Props = { type Props = {
uri: string, uri: string,
metadata: StreamMetadata,
title: string, title: string,
nsfw: boolean, nsfw: boolean,
claim: StreamClaim, claim: StreamClaim,
thumbnail: ?string, thumbnail: ?string,
}; };
function LayoutWrapperDocument(props: Props) { function LayoutWrapperText(props: Props) {
const { uri, claim, metadata, title, nsfw, thumbnail } = props; const { uri, claim, title, nsfw } = props;
const { description } = metadata;
return ( return (
<div className=""> <div>
<div className="main__document-wrapper"> <div className="main__document-wrapper">
<ClaimUri uri={uri} /> <ClaimUri uri={uri} />
@ -42,30 +39,15 @@ function LayoutWrapperDocument(props: Props) {
</span> </span>
<h1 className="media__title-text">{title}</h1> <h1 className="media__title-text">{title}</h1>
</div> </div>
</div>
<div className="media__document-thumbnail">
<FileThumbnail thumbnail={thumbnail} />
</div>
<div className="section main__document-wrapper">
<div className="section__subtitle">
<em>
<MarkdownPreview content={description} />
</em>
</div>
<div className="media__subtitle--between"> <div className="media__subtitle--between">
<DateTime uri={uri} show={DateTime.SHOW_DATE} /> <DateTime uri={uri} show={DateTime.SHOW_DATE} />
<FileViewCount uri={uri} /> <FileViewCount uri={uri} />
</div> </div>
<FileActions uri={uri} /> <div className="section">
<FileAuthor uri={uri} />
<div className="section__divider">
<hr />
</div> </div>
<FileAuthor uri={uri} />
<div className="section__divider"> <div className="section__divider">
<hr /> <hr />
</div> </div>
@ -73,14 +55,21 @@ function LayoutWrapperDocument(props: Props) {
{/* Render the initiator to trigger the view of the file */} {/* Render the initiator to trigger the view of the file */}
<FileViewerInitiator uri={uri} /> <FileViewerInitiator uri={uri} />
<TextViewer uri={uri} /> <TextViewer uri={uri} />
<div className="section__divider">
<hr />
</div>
</div> </div>
<div className="columns"> <div className="columns">
<div> <div>
<FileActions uri={uri} />
<div className="section__divider">
<hr />
</div>
<FileAuthor uri={uri} />
<div className="section">
<FileDetails uri={uri} />
</div>
<div className="section__title--small">{__('Comments')}</div> <div className="section__title--small">{__('Comments')}</div>
<section className="section"> <section className="section">
<CommentCreate uri={uri} /> <CommentCreate uri={uri} />
@ -95,4 +84,4 @@ function LayoutWrapperDocument(props: Props) {
); );
} }
export default LayoutWrapperDocument; export default LayoutWrapperText;

View file

@ -9,11 +9,11 @@ import {
makeSelectMetadataForUri, makeSelectMetadataForUri,
makeSelectChannelForClaimUri, makeSelectChannelForClaimUri,
selectBalance, selectBalance,
makeSelectMediaTypeForUri,
} from 'lbry-redux'; } from 'lbry-redux';
import { doFetchViewCount, makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc'; import { doFetchViewCount, makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc';
import { selectShowMatureContent } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions'; import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import { makeSelectIsText } from 'redux/selectors/content';
import FilePage from './view'; import FilePage from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -26,7 +26,7 @@ const select = (state, props) => ({
isSubscribed: makeSelectIsSubscribed(props.uri)(state), isSubscribed: makeSelectIsSubscribed(props.uri)(state),
channelUri: makeSelectChannelForClaimUri(props.uri, true)(state), channelUri: makeSelectChannelForClaimUri(props.uri, true)(state),
balance: selectBalance(state), balance: selectBalance(state),
mediaType: makeSelectMediaTypeForUri(props.uri)(state), isText: makeSelectIsText(props.uri)(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -22,7 +22,7 @@ type Props = {
markSubscriptionRead: (string, string) => void, markSubscriptionRead: (string, string) => void,
fetchViewCount: string => void, fetchViewCount: string => void,
balance: number, balance: number,
mediaType: string, isText: boolean,
}; };
class FilePage extends React.Component<Props> { class FilePage extends React.Component<Props> {
@ -75,9 +75,8 @@ class FilePage extends React.Component<Props> {
} }
render() { render() {
const { uri, claimIsMine, costInfo, fileInfo, balance, mediaType } = this.props; const { uri, claimIsMine, costInfo, fileInfo, balance, isText } = this.props;
const insufficientCredits = !claimIsMine && costInfo && costInfo.cost > balance; const insufficientCredits = !claimIsMine && costInfo && costInfo.cost > balance;
return ( return (
<Page className="main--file-page"> <Page className="main--file-page">
{!fileInfo && insufficientCredits && ( {!fileInfo && insufficientCredits && (
@ -93,7 +92,7 @@ class FilePage extends React.Component<Props> {
</div> </div>
)} )}
{mediaType === 'text' ? <LayoutWrapperText uri={uri} /> : <LayoutWrapperFile uri={uri} />} {isText ? <LayoutWrapperText uri={uri} /> : <LayoutWrapperFile uri={uri} />}
</Page> </Page>
); );
} }

View file

@ -127,3 +127,12 @@ export const makeSelectCanAutoplay = (uri: string) =>
return canAutoPlay; return canAutoPlay;
} }
); );
export const makeSelectIsText = (uri: string) =>
createSelector(
makeSelectMediaTypeForUri(uri),
mediaType => {
const isText = ['text', 'document'].includes(mediaType);
return isText;
}
);

View file

@ -6,6 +6,10 @@
.content__viewer--inline { .content__viewer--inline {
max-height: var(--inline-player-max-height); max-height: var(--inline-player-max-height);
@media (max-width: $breakpoint-small) {
margin-top: 10px;
}
} }
.content__viewer--floating { .content__viewer--floating {

View file

@ -4,10 +4,24 @@
z-index: 1; z-index: 1;
overflow: hidden; overflow: hidden;
max-height: var(--inline-player-max-height); max-height: var(--inline-player-max-height);
@media (max-width: $breakpoint-small) {
// margin-top: 10px;
}
} }
.file-render--document { .file-render--document {
max-height: none; max-height: none;
.content__loading {
background-color: transparent;
padding: 0;
margin: var(--spacing-xlarge) 0;
.content__loading-text {
color: var(--color-text);
}
}
} }
.file-render__viewer { .file-render__viewer {

View file

@ -102,8 +102,9 @@
} }
.main__document-wrapper { .main__document-wrapper {
width: 60%; width: 40em;
margin: auto; margin: auto;
margin-bottom: var(--spacing-xlarge);
@media (max-width: $breakpoint-small) { @media (max-width: $breakpoint-small) {
width: 100%; width: 100%;

View file

@ -20,26 +20,22 @@
} }
h1 { h1 {
font-size: 1.8em;
}
h2 {
font-size: 1.7em; font-size: 1.7em;
} }
h3 { h2 {
font-size: 1.6em;
}
h4 {
font-size: 1.5em; font-size: 1.5em;
} }
h5 { h3 {
font-size: 1.4em; font-size: 1.4em;
} }
h6 { h4 {
font-size: 1.3em; font-size: 1.3em;
} }
h5 {
@media (max-width: $breakpoint-small) { font-size: 1.2em;
font-size: 0.8em; }
h6 {
font-size: 1em;
} }
// Paragraphs // Paragraphs

View file

@ -23,7 +23,8 @@
text-overflow: ellipsis; text-overflow: ellipsis;
font-weight: var(--font-weight-bold); font-weight: var(--font-weight-bold);
white-space: normal; white-space: normal;
font-size: var(--font-title); // font-size: var(--font-title);
font-size: 2em;
display: inline; display: inline;
} }

View file

@ -23,6 +23,10 @@ html {
body { body {
font-size: 1em; font-size: 1em;
@media (max-width: $breakpoint-small) {
font-size: 1.3em;
}
} }
h1, h1,

View file

@ -1019,10 +1019,10 @@
prop-types "^15.6.2" prop-types "^15.6.2"
scheduler "^0.15.0" scheduler "^0.15.0"
"@lbry/components@^3.0.4": "@lbry/components@^3.0.5":
version "3.0.4" version "3.0.5"
resolved "https://registry.yarnpkg.com/@lbry/components/-/components-3.0.4.tgz#521166732707ed06e354341383c5d443fdb4b798" resolved "https://registry.yarnpkg.com/@lbry/components/-/components-3.0.5.tgz#4ab6cf8f97113e4c2c90fb6a840801c9da11923f"
integrity sha512-kvkYFdPEYhjKMY/YqNBVwKvaIhTeGNCr+MqVQsE0wsb+tD+xlY+BRSt2G/H62BoL6P38qZ9lZJ5Y6OtiefL8Ag== integrity sha512-u0J5MY3JvGxPjusVQVtoWKUbTAokC6wy+zafq/qJdnCUtjJbEG57jx7sx6KSfdoCz7jqmr2bivAbzMx+oP2mzA==
"@mapbox/hast-util-table-cell-style@^0.1.3": "@mapbox/hast-util-table-cell-style@^0.1.3":
version "0.1.3" version "0.1.3"