2021-03-10 13:34:21 -05:00
|
|
|
// @flow
|
2021-12-16 15:59:13 -06:00
|
|
|
|
2021-03-10 13:34:21 -05:00
|
|
|
import React from 'react';
|
|
|
|
import Card from 'component/common/card';
|
|
|
|
import ClaimPreview from 'component/claimPreview';
|
2021-04-23 15:59:48 -04:00
|
|
|
import { useHistory } from 'react-router';
|
|
|
|
import { formatLbryUrlForWeb } from 'util/url';
|
2021-03-10 13:34:21 -05:00
|
|
|
|
|
|
|
type Props = {
|
2021-12-22 10:12:44 -06:00
|
|
|
title?: string,
|
2021-12-16 15:59:13 -06:00
|
|
|
claimUri: string,
|
2021-03-10 13:34:21 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function LivestreamLink(props: Props) {
|
2021-12-22 10:12:44 -06:00
|
|
|
const { claimUri, title = null } = props;
|
2021-04-23 15:59:48 -04:00
|
|
|
const { push } = useHistory();
|
2021-03-10 13:34:21 -05:00
|
|
|
|
2021-03-29 19:05:18 -04:00
|
|
|
const element = (props: { children: any }) => (
|
2021-04-23 15:59:48 -04:00
|
|
|
<Card
|
2021-11-05 14:14:00 -05:00
|
|
|
className="livestream__channel-link claim-preview__live"
|
2021-12-22 10:12:44 -06:00
|
|
|
title={title || __('Live stream in progress')}
|
2021-04-23 15:59:48 -04:00
|
|
|
onClick={() => {
|
2021-12-16 15:59:13 -06:00
|
|
|
push(formatLbryUrlForWeb(claimUri));
|
2021-04-23 15:59:48 -04:00
|
|
|
}}
|
|
|
|
>
|
2021-03-29 19:05:18 -04:00
|
|
|
{props.children}
|
|
|
|
</Card>
|
2021-03-10 13:34:21 -05:00
|
|
|
);
|
2021-03-29 19:05:18 -04:00
|
|
|
|
2021-12-23 15:52:23 +08:00
|
|
|
return claimUri ? <ClaimPreview uri={claimUri} wrapperElement={element} type="inline" /> : null;
|
2021-03-10 13:34:21 -05:00
|
|
|
}
|