From 4f0a015593f7ae2e03a40715b3256e7bc38d8f00 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 16 Dec 2021 13:54:15 +0700 Subject: [PATCH] disabled lazy load on flow cell --- src/components/flow/FlowCell/index.tsx | 2 +- src/components/flow/FlowCellImage/index.tsx | 5 ++--- .../flow/FlowCellImageLazyLoad/index.tsx | 18 ++++++++++++++++++ .../FlowCellImageLazyLoad/styles.module.scss | 15 +++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/components/flow/FlowCellImageLazyLoad/index.tsx create mode 100644 src/components/flow/FlowCellImageLazyLoad/styles.module.scss diff --git a/src/components/flow/FlowCell/index.tsx b/src/components/flow/FlowCell/index.tsx index abfec94c..cd48a6f6 100644 --- a/src/components/flow/FlowCell/index.tsx +++ b/src/components/flow/FlowCell/index.tsx @@ -2,7 +2,6 @@ import React, { FC } from 'react'; import styles from './styles.module.scss'; import { NavLink } from 'react-router-dom'; import { CellShade } from '~/components/flow/CellShade'; -import { FlowCellImage } from '~/components/flow/FlowCellImage'; import { FlowDisplay, INode } from '~/redux/types'; import { FlowCellText } from '~/components/flow/FlowCellText'; import classNames from 'classnames'; @@ -10,6 +9,7 @@ import { FlowCellMenu } from '~/components/flow/FlowCellMenu'; import { useFlowCellControls } from '~/utils/hooks/flow/useFlowCellControls'; import { useClickOutsideFocus } from '~/utils/hooks/useClickOutsideFocus'; import { MenuDots } from '~/components/common/MenuDots'; +import { FlowCellImage } from '~/components/flow/FlowCellImage'; interface Props { id: INode['id']; diff --git a/src/components/flow/FlowCellImage/index.tsx b/src/components/flow/FlowCellImage/index.tsx index 048bc96d..3ac34dfc 100644 --- a/src/components/flow/FlowCellImage/index.tsx +++ b/src/components/flow/FlowCellImage/index.tsx @@ -1,5 +1,4 @@ import React, { FC } from 'react'; -import LazyLoad from 'react-lazyload'; import { IMGProps } from '~/utils/types'; import styles from './styles.module.scss'; import classNames from 'classnames'; @@ -9,10 +8,10 @@ interface Props extends IMGProps { } const FlowCellImage: FC = ({ className, children, ...rest }) => ( - +
{children} - +
); export { FlowCellImage }; diff --git a/src/components/flow/FlowCellImageLazyLoad/index.tsx b/src/components/flow/FlowCellImageLazyLoad/index.tsx new file mode 100644 index 00000000..bb43419b --- /dev/null +++ b/src/components/flow/FlowCellImageLazyLoad/index.tsx @@ -0,0 +1,18 @@ +import React, { FC } from 'react'; +import LazyLoad from 'react-lazyload'; +import { IMGProps } from '~/utils/types'; +import styles from './styles.module.scss'; +import classNames from 'classnames'; + +interface Props extends IMGProps { + height?: number; +} + +const FlowCellImageLazyLoad: FC = ({ className, children, ...rest }) => ( + + + {children} + +); + +export { FlowCellImageLazyLoad }; diff --git a/src/components/flow/FlowCellImageLazyLoad/styles.module.scss b/src/components/flow/FlowCellImageLazyLoad/styles.module.scss new file mode 100644 index 00000000..61ac2651 --- /dev/null +++ b/src/components/flow/FlowCellImageLazyLoad/styles.module.scss @@ -0,0 +1,15 @@ +.wrapper { + width: 100%; + height: 100%; + position: relative; + + img { + position: absolute; + top: 50%; + left: 50%; + min-width: 100%; + min-height: 100%; + transform: translate(-50%, -50%); + object-fit: cover; + } +}