This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/frontend/components/Editor/components/Image.js
2017-08-27 09:51:37 -07:00

28 lines
713 B
JavaScript

// @flow
import React from 'react';
import type { Props } from '../types';
import { color } from 'styles/constants';
import styled from 'styled-components';
const StyledImg = styled.img`
box-shadow: ${props => (props.active ? `0 0 0 3px ${color.slate}` : '0')};
opacity: ${props => (props.loading ? 0.5 : 1)};
`;
export default function Image({ attributes, state, node }: Props) {
const loading = node.data.get('loading');
const alt = node.data.get('alt');
const src = node.data.get('src');
const active = state.isFocused && state.selection.hasEdgeIn(node);
return (
<StyledImg
{...attributes}
src={src}
alt={alt}
active={active}
loading={loading}
/>
);
}