mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added lazy loading to flow images
This commit is contained in:
parent
e2d870f187
commit
50f561de96
4 changed files with 18 additions and 13 deletions
|
@ -22,5 +22,14 @@ module.exports = withBundleAnalyzer(
|
||||||
|
|
||||||
/** don't try to optimize fonts */
|
/** don't try to optimize fonts */
|
||||||
optimizeFonts: false,
|
optimizeFonts: false,
|
||||||
|
images: {
|
||||||
|
remotePatterns: [
|
||||||
|
{
|
||||||
|
protocol: 'https',
|
||||||
|
hostname: '*.vault48.org',
|
||||||
|
pathname: '/**',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -119,7 +119,6 @@ const FlowCell: FC<Props> = ({
|
||||||
{image && (
|
{image && (
|
||||||
<FlowCellImage
|
<FlowCellImage
|
||||||
src={image}
|
src={image}
|
||||||
height={400}
|
|
||||||
className={styles.thumb}
|
className={styles.thumb}
|
||||||
style={{ backgroundColor: color }}
|
style={{ backgroundColor: color }}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import Image from 'next/image';
|
||||||
|
|
||||||
import { IMGProps } from '~/utils/types';
|
import { IMGProps } from '~/utils/types';
|
||||||
|
|
||||||
|
@ -10,9 +11,15 @@ interface Props extends IMGProps {
|
||||||
height?: number;
|
height?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FlowCellImage: FC<Props> = ({ className, children, ...rest }) => (
|
const FlowCellImage: FC<Props> = ({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
src,
|
||||||
|
alt,
|
||||||
|
...rest
|
||||||
|
}) => (
|
||||||
<div className={classNames(styles.wrapper, className)}>
|
<div className={classNames(styles.wrapper, className)}>
|
||||||
<img {...rest} src={rest.src} alt="" />
|
<Image {...rest} src={src!} alt={alt} placeholder="empty" layout="fill" />
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,14 +2,4 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
img {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue