summaryrefslogtreecommitdiff
path: root/client/src/components/BlurryLoadDiv.tsx
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-11-01 14:10:11 -0700
committerMichael Hunteman <michael@huntm.net>2024-11-01 14:10:11 -0700
commitfab698d676d43a46b0fd5df592915ca12111dbcb (patch)
tree0106ff4ac6583f0761b43474939fd2db0fbf0f76 /client/src/components/BlurryLoadDiv.tsx
parent59d6e1c7470b8f544dc128825ea5ff55ac34b992 (diff)
Blurry load
Diffstat (limited to 'client/src/components/BlurryLoadDiv.tsx')
-rw-r--r--client/src/components/BlurryLoadDiv.tsx21
1 files changed, 21 insertions, 0 deletions
diff --git a/client/src/components/BlurryLoadDiv.tsx b/client/src/components/BlurryLoadDiv.tsx
new file mode 100644
index 0000000..1dfe07e
--- /dev/null
+++ b/client/src/components/BlurryLoadDiv.tsx
@@ -0,0 +1,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>
+ );
+};