Minor fixes for channel-about page #2520
4 changed files with 29 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
// @flow
|
||||
import React, { Fragment } from 'react';
|
||||
import MarkdownPreview from 'component/common/markdown-preview';
|
||||
|
||||
type Props = {
|
||||
description: ?string,
|
||||
|
@ -7,6 +8,15 @@ type Props = {
|
|||
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 ChannelContent(props: Props) {
|
||||
const { description, email, website } = props;
|
||||
const showAbout = description || email || website;
|
||||
|
@ -16,17 +26,25 @@ function ChannelContent(props: Props) {
|
|||
{!showAbout && <h2 className="empty">{__('Nothing here yet')}</h2>}
|
||||
{showAbout && (
|
||||
<Fragment>
|
||||
{description && <div className="media__info-text">{description}</div>}
|
||||
{description && (
|
||||
<div className="media__info-text media__info-text--small">
|
||||
<MarkdownPreview content={description} promptLinks />
|
||||
</div>
|
||||
)}
|
||||
{email && (
|
||||
<Fragment>
|
||||
<div className="media__info-title">{__('Contact')}</div>
|
||||
<div className="media__info-text">{email}</div>
|
||||
<div className="media__info-text">
|
||||
<MarkdownPreview content={formatEmail(email)} promptLinks />
|
||||
</div>
|
||||
</Fragment>
|
||||
)}
|
||||
{website && (
|
||||
<Fragment>
|
||||
<div className="media__info-title">{__('Site')}</div>
|
||||
<div className="media__info-text">{website}</div>
|
||||
<div className="media__info-text">
|
||||
<MarkdownPreview content={website} promptLinks />
|
||||
</div>
|
||||
</Fragment>
|
||||
)}
|
||||
</Fragment>
|
||||
|
|
|
@ -30,7 +30,7 @@ const SimpleLink = (props: SimpleLinkProps) => {
|
|||
const schema = { ...defaultSchema };
|
||||
|
||||
// Extend sanitation schema to support lbry protocol
|
||||
schema.protocols.href[3] = 'lbry';
|
||||
schema.protocols.href.push('lbry');
|
||||
|
||||
const MarkdownPreview = (props: MarkdownProps) => {
|
||||
const { content, promptLinks } = props;
|
||||
|
|
|
@ -22,14 +22,14 @@ class ExternalLink extends React.PureComponent<Props> {
|
|||
const { href, title, children, openModal } = this.props;
|
||||
|
||||
// Regex for url protocol
|
||||
const protocolRegex = new RegExp('^(https?|lbry)+:', 'i');
|
||||
const protocolRegex = new RegExp('^(https?|lbry|mailto)+:', 'i');
|
||||
const protocol = href ? protocolRegex.exec(href) : null;
|
||||
|
||||
// Return plain text if no valid url
|
||||
let element = <span>{children}</span>;
|
||||
|
||||
// Return external link if protocol is http or https
|
||||
if (protocol && (protocol[0] === 'http:' || protocol[0] === 'https:')) {
|
||||
if (protocol && (protocol[0] === 'http:' || protocol[0] === 'https:' || protocol[0] === 'mailto:')) {
|
||||
element = (
|
||||
<Button
|
||||
button="link"
|
||||
|
|
|
@ -260,12 +260,16 @@
|
|||
|
||||
.media__info-text {
|
||||
font-size: 1.15rem;
|
||||
word-break: break-all;
|
||||
word-break: break-word;
|
||||
Oh, I see, then I think Oh, I see, then I think `word-break: break-word` should work for both cases :+1:
@seanyesmunt How long should be the @seanyesmunt How long should be the `max-width` ?
I added I added `70%` as a random value, looks good in my screen :stuck_out_tongue:
|
||||
|
||||
&:not(:last-of-type) {
|
||||
margin-bottom: var(--spacing-vertical-large);
|
||||
}
|
||||
|
||||
&.media__info-text--small {
|
||||
max-width: 50rem;
|
||||
}
|
||||
|
||||
&.media__info-text--center {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue
This was used as a quick fix to prevent super long links from not wrapping. Checkout some of cryptocandors content to see it.
Can we add a Max width on this for this? Mostly for the channel page.
Try editing the description to be really long to see the current issue.