From 21b3bc3d77f1f30a0070541bd6f0bbaa7145f20f Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Tue, 25 Jan 2022 17:11:59 +0700 Subject: [PATCH] fixed cell shade for tablets --- src/components/flow/FlowCell/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/flow/FlowCell/index.tsx b/src/components/flow/FlowCell/index.tsx index e64e0b50..1aec9a17 100644 --- a/src/components/flow/FlowCell/index.tsx +++ b/src/components/flow/FlowCell/index.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React, { FC, useMemo } from 'react'; import classNames from 'classnames'; @@ -9,6 +9,7 @@ import { FlowCellImage } from '~/components/flow/FlowCellImage'; import { FlowCellMenu } from '~/components/flow/FlowCellMenu'; import { FlowCellText } from '~/components/flow/FlowCellText'; import { useClickOutsideFocus } from '~/hooks/dom/useClickOutsideFocus'; +import { useWindowSize } from '~/hooks/dom/useWindowSize'; import { useFlowCellControls } from '~/hooks/flow/useFlowCellControls'; import { FlowDisplay, INode } from '~/types'; @@ -38,6 +39,8 @@ const FlowCell: FC = ({ canEdit = false, onChangeCellView, }) => { + const { innerWidth } = useWindowSize(); + const withText = ((!!flow.display && flow.display !== 'single') || !image) && flow.show_description && !!text; const { @@ -50,6 +53,13 @@ const FlowCell: FC = ({ } = useFlowCellControls(id, text, flow, onChangeCellView); const { isActive: isMenuActive, activate, ref, deactivate } = useClickOutsideFocus(); + const shadeSize = useMemo(() => { + const min = innerWidth < 768 ? 10 : 15; + const max = innerWidth < 768 ? 20 : 50; + + return withText ? min : max; + }, [withText, innerWidth]); + return (
{canEdit && !isMenuActive && ( @@ -90,7 +100,7 @@ const FlowCell: FC = ({ /> )} - + {!withText && (