Added: Placeholder when uploading images

This commit is contained in:
Tom Moor
2017-08-26 22:37:20 -07:00
parent 3c51cc3197
commit 667d1caf11
5 changed files with 80 additions and 40 deletions

View File

@@ -1,13 +1,16 @@
// @flow
import React from 'react';
import type { Props } from '../types';
import styled from 'styled-components';
const LoadingImage = styled.img`
opacity: .5;
`;
export default function Image({ attributes, node }: Props) {
return (
<img
{...attributes}
src={node.data.get('src')}
alt={node.data.get('alt')}
/>
);
const loading = node.data.get('loading');
const Component = loading ? LoadingImage : 'img';
const src = node.data.get('inlineSrc') || node.data.get('src');
return <Component {...attributes} src={src} alt={node.data.get('alt')} />;
}