File size: 1,759 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import { Fab } from '@mui/material';
import type { CSSProperties } from 'react';
import React from 'react';
import IconUp from '@mui/icons-material/ArrowDropUp';
import IconDown from '@mui/icons-material/ArrowDropDown';
import IconRight from '@mui/icons-material/ArrowRight';
import IconLeft from '@mui/icons-material/ArrowLeft';
import {
useMoveNodeDown,
useMoveNodeUp,
useMoveNodeLeft,
useMoveNodeRight,
} from '../../core/components/hooks';
const Base: React.FC<{
onClick: null | (() => void);
icon: NonNullable<React.ReactNode>;
style?: CSSProperties;
}> = ({ onClick, icon, style }) => {
// don't show at all
return (
<Fab
disabled={!onClick}
style={{ margin: 10, pointerEvents: 'all', ...style }}
size="small"
onClick={onClick ?? undefined}
color="default"
>
{icon}
</Fab>
);
};
export const MoveUp: React.FC<{ nodeId: string; style?: CSSProperties }> = ({
nodeId,
style,
}) => {
const moveUp = useMoveNodeUp(nodeId);
return <Base onClick={moveUp} icon={<IconUp />} style={style} />;
};
export const MoveDown: React.FC<{ nodeId: string; style?: CSSProperties }> = ({
nodeId,
style,
}) => {
const moveDown = useMoveNodeDown(nodeId);
return <Base onClick={moveDown} icon={<IconDown />} style={style} />;
};
export const MoveLeft: React.FC<{ nodeId: string; style?: CSSProperties }> = ({
nodeId,
style,
}) => {
const moveLeft = useMoveNodeLeft(nodeId);
return <Base onClick={moveLeft} icon={<IconLeft />} style={style} />;
};
export const MoveRight: React.FC<{ nodeId: string; style?: CSSProperties }> = ({
nodeId,
style,
}) => {
const moveRight = useMoveNodeRight(nodeId);
return <Base onClick={moveRight} icon={<IconRight />} style={style} />;
};
|