mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-06-26 13:01:07 +02:00
40 lines
956 B
TypeScript
40 lines
956 B
TypeScript
import {XCircleIcon} from '@heroicons/react/solid';
|
|
import * as React from 'react';
|
|
|
|
export interface IImageFallbackProps {
|
|
src: string;
|
|
}
|
|
|
|
export const ImageFallback: React.FunctionComponent<IImageFallbackProps> = ({ src }: React.PropsWithChildren<IImageFallbackProps>) => {
|
|
|
|
if (!src) {
|
|
return (
|
|
<div style={{
|
|
width: '100%',
|
|
height: '120px',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
backgroundColor: 'var(--button-secondary-hover-background)'
|
|
}}>
|
|
<XCircleIcon style={{
|
|
height: '8rem',
|
|
width: '8rem',
|
|
color: 'var(--vscode-errorForeground)',
|
|
}} />
|
|
|
|
<p style={{
|
|
marginBottom: '1rem',
|
|
color: 'var(--button-secondary-foreground)',
|
|
}}>
|
|
The image couldn't be loaded
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<img src={src} />
|
|
);
|
|
}; |