mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
## Ticket 5457 Create file thumbnail fallback image for odysee ## Approach Since `background-image` does not invoke an `onerror` event, use the stacking attribute of `background-image` to display the fallback.
31 lines
680 B
JavaScript
31 lines
680 B
JavaScript
// @flow
|
|
import React from 'react';
|
|
import classnames from 'classnames';
|
|
import type { Node } from 'react';
|
|
import useLazyLoading from 'effects/use-lazy-loading';
|
|
|
|
type Props = {
|
|
thumb: string,
|
|
fallback: ?string,
|
|
children?: Node,
|
|
className?: string,
|
|
};
|
|
|
|
const Thumb = (props: Props) => {
|
|
const { thumb, fallback, children, className } = props;
|
|
const thumbnailRef = React.useRef(null);
|
|
useLazyLoading(thumbnailRef);
|
|
|
|
return (
|
|
<div
|
|
ref={thumbnailRef}
|
|
data-background-image={thumb}
|
|
data-background-image-fallback={fallback}
|
|
className={classnames('media__thumb', className)}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Thumb;
|