2020-04-29 22:50:06 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import Button from 'component/button';
|
2020-05-22 22:47:10 +02:00
|
|
|
import FilePrice from 'component/filePrice';
|
2020-04-29 22:50:06 +02:00
|
|
|
import { formatLbryUrlForWeb } from 'util/url';
|
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
import { URL } from 'config';
|
2021-07-26 00:03:48 +02:00
|
|
|
import Logo from 'component/logo';
|
2020-04-29 22:50:06 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
|
|
|
title: ?string,
|
|
|
|
isInApp: boolean,
|
2021-09-18 16:23:30 +02:00
|
|
|
preferEmbed: boolean,
|
2020-04-29 22:50:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function FileViewerEmbeddedTitle(props: Props) {
|
2021-09-18 16:23:30 +02:00
|
|
|
const { uri, title, isInApp, preferEmbed } = props;
|
2020-04-29 22:50:06 +02:00
|
|
|
|
|
|
|
let contentLink = `${formatLbryUrlForWeb(uri)}`;
|
|
|
|
|
|
|
|
if (!isInApp) {
|
|
|
|
contentLink = `${contentLink}?src=embed`;
|
|
|
|
}
|
|
|
|
|
2020-05-18 19:07:42 +02:00
|
|
|
const contentLinkProps = isInApp ? { navigate: contentLink } : { href: contentLink };
|
2020-04-29 22:50:06 +02:00
|
|
|
const lbryLinkProps = isInApp ? { navigate: '/' } : { href: URL };
|
|
|
|
|
|
|
|
return (
|
2020-05-22 22:47:10 +02:00
|
|
|
<div className="file-viewer__embedded-header">
|
2020-10-20 19:10:02 +02:00
|
|
|
<div className="file-viewer__embedded-gradient" />
|
2021-09-18 16:23:30 +02:00
|
|
|
{preferEmbed ? (
|
|
|
|
<div className="file-viewer__embedded-title ">
|
|
|
|
<span dir="auto">{title}</span>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<Button
|
|
|
|
label={title}
|
|
|
|
aria-label={title}
|
|
|
|
button="link"
|
|
|
|
className="file-viewer__embedded-title"
|
|
|
|
{...contentLinkProps}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2020-05-22 22:47:10 +02:00
|
|
|
<div className="file-viewer__embedded-info">
|
2021-09-18 16:23:30 +02:00
|
|
|
<Button className="file-viewer__overlay-logo" disabled={preferEmbed} aria-label={__('Home')} {...lbryLinkProps}>
|
2021-07-26 00:03:48 +02:00
|
|
|
<Logo type={'embed'} />
|
|
|
|
</Button>
|
2020-05-26 20:42:44 +02:00
|
|
|
{isInApp && <FilePrice uri={uri} />}
|
2020-05-22 22:47:10 +02:00
|
|
|
</div>
|
2020-04-29 22:50:06 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default withRouter(FileViewerEmbeddedTitle);
|