summaryrefslogtreecommitdiff
path: root/client/src/components/BlurryLoadDiv.tsx
blob: 1dfe07e93183c0c5092222b61e2ebc63cdd0543e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import React from 'react';
import { ClassAttributes, ImgHTMLAttributes } from 'react';
import { JSX } from 'react/jsx-runtime';
import { useBlurryLoad } from '../useBlurryLoad.ts';
import { useMediaQuery } from '@mui/material';

export const BlurryLoadDiv = (
  props: JSX.IntrinsicAttributes &
    ClassAttributes<HTMLImageElement> &
    ImgHTMLAttributes<HTMLImageElement> & { 'data-large': string }
) => {
  const isMobile = useMediaQuery('(max-width: 768px)');
  let blurry = '';
  if (!isMobile) {
    useBlurryLoad();
    blurry = 'blurry-load';
  }
  return (
    <div alt="" {...props} className={`${blurry} ${props.className}`}></div>
  );
};