2019-05-07 04:35:04 +02:00
|
|
|
// @flow
|
|
|
|
import React, { Fragment } from 'react';
|
2019-05-29 23:54:47 +02:00
|
|
|
import MarkdownPreview from 'component/common/markdown-preview';
|
2019-05-07 04:35:04 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
description: ?string,
|
|
|
|
email: ?string,
|
|
|
|
website: ?string,
|
|
|
|
};
|
|
|
|
|
2019-05-30 01:21:20 +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;
|
|
|
|
};
|
|
|
|
|
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>
|
2019-05-29 23:54:47 +02:00
|
|
|
{description && (
|
2019-05-30 03:32:06 +02:00
|
|
|
<div className="media__info-text media__info-text--small">
|
2019-05-29 23:54:47 +02:00
|
|
|
<MarkdownPreview content={description} promptLinks />
|
|
|
|
</div>
|
|
|
|
)}
|
2019-05-07 04:35:04 +02:00
|
|
|
{email && (
|
|
|
|
<Fragment>
|
|
|
|
<div className="media__info-title">{__('Contact')}</div>
|
2019-05-30 01:21:20 +02:00
|
|
|
<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>
|
2019-05-29 23:54:47 +02:00
|
|
|
<div className="media__info-text">
|
|
|
|
<MarkdownPreview content={website} promptLinks />
|
|
|
|
</div>
|
2019-05-07 04:35:04 +02:00
|
|
|
</Fragment>
|
|
|
|
)}
|
|
|
|
</Fragment>
|
|
|
|
)}
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ChannelContent;
|