feat(lock): button enabling and disabling interactivity on Controls plugin
This commit is contained in:
@@ -2,9 +2,13 @@ import React, { CSSProperties } from 'react';
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
import { fitView, zoomIn, zoomOut } from '../../utils/graph';
|
import { fitView, zoomIn, zoomOut } from '../../utils/graph';
|
||||||
|
import { useStoreState, useStoreActions } from '../../store/hooks';
|
||||||
|
|
||||||
import PlusIcon from '../../../assets/icons/plus.svg';
|
import PlusIcon from '../../../assets/icons/plus.svg';
|
||||||
import MinusIcon from '../../../assets/icons/minus.svg';
|
import MinusIcon from '../../../assets/icons/minus.svg';
|
||||||
import FitviewIcon from '../../../assets/icons/fitview.svg';
|
import FitviewIcon from '../../../assets/icons/fitview.svg';
|
||||||
|
import LockIcon from '../../../assets/icons/lock.svg';
|
||||||
|
import UnlockIcon from '../../../assets/icons/unlock.svg';
|
||||||
|
|
||||||
const baseStyle: CSSProperties = {
|
const baseStyle: CSSProperties = {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -18,6 +22,9 @@ interface ControlProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|||||||
export default ({ style, className }: ControlProps) => {
|
export default ({ style, className }: ControlProps) => {
|
||||||
const mapClasses: string = classnames('react-flow__controls', className);
|
const mapClasses: string = classnames('react-flow__controls', className);
|
||||||
|
|
||||||
|
const setInteractive = useStoreActions(actions => actions.setInteractive);
|
||||||
|
const { isInteractive } = useStoreState(({ isInteractive }) => ({ isInteractive }));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={mapClasses}
|
className={mapClasses}
|
||||||
@@ -26,6 +33,12 @@ export default ({ style, className }: ControlProps) => {
|
|||||||
...style,
|
...style,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div
|
||||||
|
className="react-flow__controls-button react-flow__controls-lock"
|
||||||
|
onClick={() => setInteractive(!isInteractive)}
|
||||||
|
>
|
||||||
|
{ isInteractive ? <UnlockIcon /> : <LockIcon /> }
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
className="react-flow__controls-button react-flow__controls-zoomin"
|
className="react-flow__controls-button react-flow__controls-zoomin"
|
||||||
onClick={zoomIn}
|
onClick={zoomIn}
|
||||||
|
|||||||
Reference in New Issue
Block a user