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

57 lines
1.6 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';
2019-05-07 04:35:04 +02:00
type Props = {
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;
};
2019-05-07 04:35:04 +02:00
function ChannelContent(props: Props) {
const { description, email, website } = props;
const showAbout = description || email || website;
return (
2019-06-11 20:10:58 +02:00
<section className="card--section">
{!showAbout && <h2 className="main--empty empty">{__('Nothing here yet')}</h2>}
2019-05-07 04:35:04 +02:00
{showAbout && (
<Fragment>
{description && (
2019-05-30 03:32:06 +02:00
<div className="media__info-text media__info-text--small">
<MarkdownPreview content={description} promptLinks />
</div>
)}
2019-05-07 04:35:04 +02:00
{email && (
<Fragment>
<div className="media__info-title">{__('Contact')}</div>
<div className="media__info-text">
<MarkdownPreview content={formatEmail(email)} promptLinks />
</div>
2019-05-07 04:35:04 +02:00
</Fragment>
)}
{website && (
<Fragment>
<div className="media__info-title">{__('Site')}</div>
<div className="media__info-text">
<MarkdownPreview content={website} promptLinks />
</div>
2019-05-07 04:35:04 +02:00
</Fragment>
)}
</Fragment>
)}
</section>
);
}
export default ChannelContent;