mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-02 22:30:25 +00:00
Stop inlining constant React components
This commit is contained in:
parent
f6cdd27972
commit
6aeb50bcd3
2 changed files with 10 additions and 5 deletions
|
|
@ -5,6 +5,8 @@ import Icon from '../../Icon/Icon';
|
|||
|
||||
import TooltipEntity from '../decorators/TooltipEntity';
|
||||
|
||||
const documentIcon = <Icon name="doc-full" />;
|
||||
|
||||
const Document = props => {
|
||||
const { entityKey, contentState } = props;
|
||||
const { url } = contentState.getEntity(entityKey).getData();
|
||||
|
|
@ -13,7 +15,7 @@ const Document = props => {
|
|||
return (
|
||||
<TooltipEntity
|
||||
{...props}
|
||||
icon={<Icon name="doc-full" />}
|
||||
icon={documentIcon}
|
||||
label={filename}
|
||||
url={url}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import TooltipEntity from '../decorators/TooltipEntity';
|
|||
const getEmailAddress = mailto => mailto.replace('mailto:', '').split('?')[0];
|
||||
const getDomainName = url => url.replace(/(^\w+:|^)\/\//, '').split('/')[0];
|
||||
|
||||
const linkIcon = <Icon name="link" />;
|
||||
const mailIcon = <Icon name="mail" />;
|
||||
|
||||
const Link = props => {
|
||||
const { entityKey, contentState } = props;
|
||||
const data = contentState.getEntity(entityKey).getData();
|
||||
|
|
@ -15,20 +18,20 @@ const Link = props => {
|
|||
let label;
|
||||
|
||||
if (data.id) {
|
||||
icon = 'link';
|
||||
icon = linkIcon;
|
||||
label = data.url;
|
||||
} else if (data.url.startsWith('mailto:')) {
|
||||
icon = 'mail';
|
||||
icon = mailIcon;
|
||||
label = getEmailAddress(data.url);
|
||||
} else {
|
||||
icon = 'link';
|
||||
icon = linkIcon;
|
||||
label = getDomainName(data.url);
|
||||
}
|
||||
|
||||
return (
|
||||
<TooltipEntity
|
||||
{...props}
|
||||
icon={<Icon name={icon} />}
|
||||
icon={icon}
|
||||
label={label}
|
||||
url={data.url}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue