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

111 lines
3.4 KiB
React
Raw Permalink 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 DateTime from 'component/dateTime';
import YoutubeBadge from 'component/youtubeBadge';
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
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,
languages: Array<string>,
2019-05-07 04:35:04 +02:00
};
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, languages } = props;
const claimId = claim && claim.claim_id;
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} />
2020-06-29 21:54:07 +02:00
</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">
<MarkdownPreview content={formatEmail(email)} simpleLinks />
</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">
<MarkdownPreview content={website} simpleLinks />
</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>
<label>{__('Languages')}</label>
<div className="media__info-text">
{/* this could use some nice 'tags' styling */}
2020-10-29 18:36:45 +01:00
{languages && languages.length
? languages.reduce((acc, lang, i) => {
return acc + `${SUPPORTED_LANGUAGES[lang]}` + ' ';
2020-10-29 18:36:45 +01:00
}, '')
: null}
</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>
2020-09-02 22:08:37 +02:00
<label>{__('Staked LBRY Credits')}</label>
<div className="media__info-text">
<CreditAmount
badge={false}
amount={parseFloat(claim.amount) + parseFloat(claim.meta.support_amount)}
precision={8}
/>{' '}
</div>
<YoutubeBadge channelClaimId={claimId} />
2019-05-07 04:35:04 +02:00
</Fragment>
</section>
</div>
2019-05-07 04:35:04 +02:00
);
}
export default ChannelAbout;