1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

added flow menus

This commit is contained in:
Fedor Katurov 2021-10-12 18:04:35 +07:00
parent 65d13afab9
commit c8204a41a2
13 changed files with 358 additions and 53 deletions

View file

@ -0,0 +1,46 @@
import { useCallback } from 'react';
import { FlowDisplay, INode } from '~/redux/types';
export const useFlowCellControls = (
id: INode['id'],
description: string | undefined,
flow: FlowDisplay,
onChangeCellView: (id: INode['id'], flow: FlowDisplay) => void
) => {
const onChange = useCallback(
(value: Partial<FlowDisplay>) => onChangeCellView(id, { ...flow, ...value }),
[]
);
const hasDescription = !!description && description.length > 32;
const toggleViewDescription = useCallback(() => {
const show_description = !(flow && flow.show_description);
onChange({ show_description });
}, [id, flow, onChange]);
const setViewSingle = useCallback(() => {
onChange({ display: 'single' });
}, [id, flow, onChange]);
const setViewHorizontal = useCallback(() => {
onChange({ display: 'horizontal' });
}, [id, flow, onChange]);
const setViewVertical = useCallback(() => {
onChange({ display: 'vertical' });
}, [id, flow]);
const setViewQuadro = useCallback(() => {
onChange({ display: 'quadro' });
}, [id, flow, onChange]);
return {
hasDescription,
setViewHorizontal,
setViewVertical,
setViewQuadro,
setViewSingle,
toggleViewDescription,
};
};