mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed cell shade for tablets
This commit is contained in:
parent
fdd404cd4d
commit
21b3bc3d77
1 changed files with 12 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC, useMemo } from 'react';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import { FlowCellImage } from '~/components/flow/FlowCellImage';
|
||||||
import { FlowCellMenu } from '~/components/flow/FlowCellMenu';
|
import { FlowCellMenu } from '~/components/flow/FlowCellMenu';
|
||||||
import { FlowCellText } from '~/components/flow/FlowCellText';
|
import { FlowCellText } from '~/components/flow/FlowCellText';
|
||||||
import { useClickOutsideFocus } from '~/hooks/dom/useClickOutsideFocus';
|
import { useClickOutsideFocus } from '~/hooks/dom/useClickOutsideFocus';
|
||||||
|
import { useWindowSize } from '~/hooks/dom/useWindowSize';
|
||||||
import { useFlowCellControls } from '~/hooks/flow/useFlowCellControls';
|
import { useFlowCellControls } from '~/hooks/flow/useFlowCellControls';
|
||||||
import { FlowDisplay, INode } from '~/types';
|
import { FlowDisplay, INode } from '~/types';
|
||||||
|
|
||||||
|
@ -38,6 +39,8 @@ const FlowCell: FC<Props> = ({
|
||||||
canEdit = false,
|
canEdit = false,
|
||||||
onChangeCellView,
|
onChangeCellView,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { innerWidth } = useWindowSize();
|
||||||
|
|
||||||
const withText =
|
const withText =
|
||||||
((!!flow.display && flow.display !== 'single') || !image) && flow.show_description && !!text;
|
((!!flow.display && flow.display !== 'single') || !image) && flow.show_description && !!text;
|
||||||
const {
|
const {
|
||||||
|
@ -50,6 +53,13 @@ const FlowCell: FC<Props> = ({
|
||||||
} = useFlowCellControls(id, text, flow, onChangeCellView);
|
} = useFlowCellControls(id, text, flow, onChangeCellView);
|
||||||
const { isActive: isMenuActive, activate, ref, deactivate } = useClickOutsideFocus();
|
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 (
|
return (
|
||||||
<div className={classNames(styles.cell, styles[flow.display || 'single'])} ref={ref as any}>
|
<div className={classNames(styles.cell, styles[flow.display || 'single'])} ref={ref as any}>
|
||||||
{canEdit && !isMenuActive && (
|
{canEdit && !isMenuActive && (
|
||||||
|
@ -90,7 +100,7 @@ const FlowCell: FC<Props> = ({
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<CellShade color={color} className={styles.shade} size={withText ? 15 : 50} />
|
<CellShade color={color} className={styles.shade} size={shadeSize} />
|
||||||
|
|
||||||
{!withText && (
|
{!withText && (
|
||||||
<div className={styles.title_wrapper}>
|
<div className={styles.title_wrapper}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue