lbry-desktop/ui/component/livestreamLink/view.jsx

32 lines
807 B
React
Raw Normal View History

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