Add LayoutImage

This commit is contained in:
Bill 2022-01-03 00:56:14 -05:00
parent d3908b1221
commit 2f67bb66e7

View File

@ -0,0 +1,23 @@
import { FC, useMemo } from 'react';
import { Base, BaseProps } from '../Base';
export interface LayoutImageProps extends BaseProps<HTMLDivElement>
{
imageUrl: string;
}
export const LayoutImage: FC<LayoutImageProps> = props =>
{
const { imageUrl = null, style = null, ...rest } = props;
const getStyle = useMemo(() =>
{
const newStyle = { ...style };
if(imageUrl) newStyle.background = `url(${ imageUrl }) center no-repeat`;
return newStyle;
}, [ style, imageUrl ]);
return <Base fit style={ getStyle } { ...rest } />;
}