From b6c895e90f9f845975848126a08de38c51f49792 Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Tue, 16 Aug 2022 21:12:38 +0800 Subject: [PATCH] add move coverage --- .../components/command-panel/CommandPanel.tsx | 8 ++ .../components/command-panel/MoveCoverage.tsx | 109 ++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 libs/components/board-draw/src/components/command-panel/MoveCoverage.tsx diff --git a/libs/components/board-draw/src/components/command-panel/CommandPanel.tsx b/libs/components/board-draw/src/components/command-panel/CommandPanel.tsx index 395b6ddf47..2d3217d997 100644 --- a/libs/components/board-draw/src/components/command-panel/CommandPanel.tsx +++ b/libs/components/board-draw/src/components/command-panel/CommandPanel.tsx @@ -8,6 +8,7 @@ import { FontSizeConfig } from './FontSizeConfig'; import { FrameFillColorConfig } from './FrameFillColorConfig'; import { Group, UnGroup } from './GroupOperation'; import { Lock, Unlock } from './LockOperation'; +import { MoveCoverageConfig } from './MoveCoverage'; import { StrokeLineStyleConfig } from './stroke-line-style-config'; import { getAnchor, useConfig } from './utils'; @@ -91,6 +92,13 @@ export const CommandPanel = ({ app }: { app: TldrawApp }) => { shapes={config.deleteShapes.selectedShapes} /> ), + delete2: ( + + ), }; const nodes = Object.entries(configNodes).filter(([key, node]) => !!node); diff --git a/libs/components/board-draw/src/components/command-panel/MoveCoverage.tsx b/libs/components/board-draw/src/components/command-panel/MoveCoverage.tsx new file mode 100644 index 0000000000..d5faf978e7 --- /dev/null +++ b/libs/components/board-draw/src/components/command-panel/MoveCoverage.tsx @@ -0,0 +1,109 @@ +import type { TldrawApp } from '@toeverything/components/board-state'; +import type { TDShape } from '@toeverything/components/board-types'; +import { + HeadingOneIcon, + HeadingThreeIcon, + HeadingTwoIcon, + LockIcon, + TextFontIcon, +} from '@toeverything/components/icons'; +import { + IconButton, + Popover, + styled, + Tooltip, +} from '@toeverything/components/ui'; + +interface FontSizeConfigProps { + app: TldrawApp; + shapes: TDShape[]; +} + +const _fontSizes = [ + { + name: 'To Front', + value: 'tofront', + icon: , + }, + { + name: 'Forward', + value: 'forward', + icon: , + }, + { + name: 'Backward', + value: 'backward', + icon: , + }, + { + name: 'To Back', + value: 'toback', + icon: , + }, +]; + +export const MoveCoverageConfig = ({ app, shapes }: FontSizeConfigProps) => { + const moveCoverage = (type: string) => { + switch (type) { + case 'toback': + app.moveToBack(); + break; + case 'backward': + app.moveBackward(); + break; + case 'forward': + app.moveForward(); + break; + case 'tofront': + app.moveToFront(); + break; + } + }; + + return ( + + {_fontSizes.map(fontSize => { + return ( + moveCoverage(fontSize.value)} + > + {/* {fontSize.icon} */} + {fontSize.name} + + ); + })} + + } + > + + + + + + + ); +}; + +const ListItemContainer = styled('div')(({ theme }) => ({ + display: 'flex', + alignItems: 'center', + cursor: 'pointer', + height: '32px', + padding: '4px 12px', + color: theme.affine.palette.icons, + + // eslint-disable-next-line @typescript-eslint/naming-convention + '&:hover': { + backgroundColor: theme.affine.palette.hover, + }, +})); + +const ListItemTitle = styled('span')(({ theme }) => ({ + marginLeft: '12px', + color: theme.affine.palette.primaryText, +}));