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

106 lines
3.1 KiB
React
Raw Normal View History

2019-05-07 04:35:04 +02:00
// @flow
import React, { Fragment } from 'react';
import MarkdownPreview from 'component/common/markdown-preview';
2020-02-14 17:52:54 +01:00
import ClaimTags from 'component/claimTags';
import CreditAmount from 'component/common/credit-amount';
import Button from 'component/button';
import * as PAGES from 'constants/pages';
import DateTime from 'component/dateTime';
2019-05-07 04:35:04 +02:00
type Props = {
claim: ChannelClaim,
2020-02-14 17:52:54 +01:00
uri: string,
2019-05-07 04:35:04 +02:00
description: ?string,
email: ?string,
website: ?string,
};
const formatEmail = (email: string) => {
if (email) {
const protocolRegex = new RegExp('^mailto:', 'i');
const protocol = protocolRegex.exec(email);
return protocol ? email : `mailto:${email}`;
}
return null;
};
function ChannelAbout(props: Props) {
const { claim, uri, description, email, website } = props;
2019-05-07 04:35:04 +02:00
return (
<div className="card">
<section className="section card--section">
2019-05-07 04:35:04 +02:00
<Fragment>
{description && (
2020-06-29 21:54:07 +02:00
<>
<label>{__('Description')}</label>
<div className="media__info-text media__info-text--constrained">
<MarkdownPreview content={description} />
</div>
</>
)}
2019-05-07 04:35:04 +02:00
{email && (
<Fragment>
2019-11-22 22:13:00 +01:00
<label>{__('Contact')}</label>
<div className="media__info-text">
2019-12-03 17:41:44 +01:00
<MarkdownPreview content={formatEmail(email)} />
</div>
2019-05-07 04:35:04 +02:00
</Fragment>
)}
{website && (
<Fragment>
2019-11-22 22:13:00 +01:00
<label>{__('Site')}</label>
<div className="media__info-text">
2019-12-03 17:41:44 +01:00
<MarkdownPreview content={website} />
</div>
2019-05-07 04:35:04 +02:00
</Fragment>
)}
2020-02-14 17:52:54 +01:00
<label>{__('Tags')}</label>
<div className="media__info-text">
<ClaimTags uri={uri} type="large" />
</div>
2020-07-23 19:11:53 +02:00
<label>{__('Total Uploads')}</label>
<div className="media__info-text">{claim.meta.claims_in_channel}</div>
<label>{__('Last Updated')}</label>
<div className="media__info-text">
<DateTime timeAgo uri={uri} />
</div>
<label>{__('URL')}</label>
<div className="media__info-text">
<div className="media__info-text media__info-text--constrained">{claim.canonical_url}</div>
</div>
<label>{__('Claim ID')}</label>
<div className="media__info-text">
<div className="media__info-text media__info-text--constrained">{claim.claim_id}</div>
</div>
<label>{__('Staked LBC')}</label>
<div className="media__info-text">
<CreditAmount
badge={false}
amount={parseFloat(claim.amount) + parseFloat(claim.meta.support_amount)}
precision={8}
/>{' '}
(
<Button
button="link"
label={__('view other claims at lbry://%name%', {
name: claim.name,
})}
navigate={`/$/${PAGES.TOP}?name=${claim.name}`}
/>
)
</div>
2019-05-07 04:35:04 +02:00
</Fragment>
</section>
</div>
2019-05-07 04:35:04 +02:00
);
}
export default ChannelAbout;