Minor fixes for channel-about page #2520

Merged
btzr-io merged 4 commits from channel-desc into master 2019-05-30 23:07:53 +02:00
4 changed files with 29 additions and 7 deletions

View file

@ -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>

View file

@ -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;

View file

@ -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"

View file

@ -260,12 +260,16 @@
.media__info-text {
font-size: 1.15rem;
word-break: break-all;
word-break: break-word;
neb-b commented 2019-05-30 01:04:05 +02:00 (Migrated from github.com)
Review

This was used as a quick fix to prevent super long links from not wrapping. Checkout some of cryptocandors content to see it.

This was used as a quick fix to prevent super long links from not wrapping. Checkout some of cryptocandors content to see it.
neb-b commented 2019-05-30 01:05:11 +02:00 (Migrated from github.com)
Review

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.

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.
btzr-io commented 2019-05-30 03:03:28 +02:00 (Migrated from github.com)
Review

Oh, I see, then I think word-break: break-word should work for both cases 👍

Oh, I see, then I think `word-break: break-word` should work for both cases :+1:
btzr-io commented 2019-05-30 03:14:13 +02:00 (Migrated from github.com)
Review

@seanyesmunt How long should be the max-width ?

@seanyesmunt How long should be the `max-width` ?
btzr-io commented 2019-05-30 03:28:30 +02:00 (Migrated from github.com)
Review

I added 70% as a random value, looks good in my screen 😛

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;
}