You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
733 B
34 lines
733 B
2 years ago
|
import React, { useCallback, useState } from 'react';
|
||
2 years ago
|
import { Blurhash } from './blurhash';
|
||
2 years ago
|
import classNames from 'classnames';
|
||
|
|
||
|
type Props = {
|
||
|
src: string;
|
||
|
srcSet?: string;
|
||
|
blurhash?: string;
|
||
|
className?: string;
|
||
2 years ago
|
};
|
||
2 years ago
|
|
||
2 years ago
|
export const ServerHeroImage: React.FC<Props> = ({
|
||
2 years ago
|
src,
|
||
|
srcSet,
|
||
|
blurhash,
|
||
|
className,
|
||
|
}) => {
|
||
2 years ago
|
const [loaded, setLoaded] = useState(false);
|
||
|
|
||
|
const handleLoad = useCallback(() => {
|
||
|
setLoaded(true);
|
||
|
}, [setLoaded]);
|
||
|
|
||
|
return (
|
||
2 years ago
|
<div
|
||
|
className={classNames('image', { loaded }, className)}
|
||
|
role='presentation'
|
||
|
>
|
||
2 years ago
|
{blurhash && <Blurhash hash={blurhash} className='image__preview' />}
|
||
|
<img src={src} srcSet={srcSet} alt='' onLoad={handleLoad} />
|
||
|
</div>
|
||
|
);
|
||
|
};
|