From e4e182517342ac4bab3542649cb5bcd6998363aa Mon Sep 17 00:00:00 2001 From: "lixinghua.vendor" Date: Tue, 6 Sep 2022 19:47:55 +0800 Subject: [PATCH] feat: ScribbleTool add sidebar --- .../src/assets/attributeIcon/eraser.svg | 6 ++ .../src/assets/attributeIcon/eraser_a.svg | 6 ++ .../src/assets/attributeIcon/pen.svg | 5 ++ .../src/assets/attributeIcon/pen_a.svg | 5 ++ packages/lb-components/src/index.scss | 25 +++++++ .../sidebar/ScribbleSidebar/index.tsx | 74 +++++++++++++++++++ .../src/views/MainView/sidebar/index.tsx | 11 ++- 7 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 packages/lb-components/src/assets/attributeIcon/eraser.svg create mode 100644 packages/lb-components/src/assets/attributeIcon/eraser_a.svg create mode 100644 packages/lb-components/src/assets/attributeIcon/pen.svg create mode 100644 packages/lb-components/src/assets/attributeIcon/pen_a.svg create mode 100644 packages/lb-components/src/views/MainView/sidebar/ScribbleSidebar/index.tsx diff --git a/packages/lb-components/src/assets/attributeIcon/eraser.svg b/packages/lb-components/src/assets/attributeIcon/eraser.svg new file mode 100644 index 000000000..e770d230e --- /dev/null +++ b/packages/lb-components/src/assets/attributeIcon/eraser.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/lb-components/src/assets/attributeIcon/eraser_a.svg b/packages/lb-components/src/assets/attributeIcon/eraser_a.svg new file mode 100644 index 000000000..8db10f5c4 --- /dev/null +++ b/packages/lb-components/src/assets/attributeIcon/eraser_a.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/lb-components/src/assets/attributeIcon/pen.svg b/packages/lb-components/src/assets/attributeIcon/pen.svg new file mode 100644 index 000000000..5a483a016 --- /dev/null +++ b/packages/lb-components/src/assets/attributeIcon/pen.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/packages/lb-components/src/assets/attributeIcon/pen_a.svg b/packages/lb-components/src/assets/attributeIcon/pen_a.svg new file mode 100644 index 000000000..c84ddce6f --- /dev/null +++ b/packages/lb-components/src/assets/attributeIcon/pen_a.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/packages/lb-components/src/index.scss b/packages/lb-components/src/index.scss index 7c5f3cd80..127a44e2f 100644 --- a/packages/lb-components/src/index.scss +++ b/packages/lb-components/src/index.scss @@ -521,6 +521,31 @@ $prefix: bee; ); } } + .#{$prefix}-scribble { + padding: 20px; + width: 100%; + &__select { + display: flex; + justify-content: center; + cursor: pointer; + img { + width: 12px; + margin: 0px 10px; + } + } + &__silder { + display: flex; + align-items: center; + justify-content: center; + } + &__circle { + display: block; + width: 5px; + height: 5px; + background: #d9d9d9; + border-radius: 50%; + } + } } .#{$prefix}-tips { diff --git a/packages/lb-components/src/views/MainView/sidebar/ScribbleSidebar/index.tsx b/packages/lb-components/src/views/MainView/sidebar/ScribbleSidebar/index.tsx new file mode 100644 index 000000000..cad69b84a --- /dev/null +++ b/packages/lb-components/src/views/MainView/sidebar/ScribbleSidebar/index.tsx @@ -0,0 +1,74 @@ +import React, { useState } from 'react'; + +import { Slider } from 'antd'; +import penActivate from '@/assets/attributeIcon/pen_a.svg'; +import pen from '@/assets/attributeIcon/pen.svg'; +import eraserActivate from '@/assets/attributeIcon/eraser_a.svg'; +import eraser from '@/assets/attributeIcon/eraser.svg'; +import { getClassName } from '@/utils/dom'; + +interface IProps { + // toolInstance?: GraphToolInstance; + // stepInfo?: IStepInfo; + onChange: (tool: number, values: number) => void; +} + +enum ESwitchTool { + Pen = 1, // 笔 + Ereser = 2, // 橡皮刷 +} + +const ScribbleSidebar: React.FC = (props) => { + const { onChange } = props; + // 查看时候默认值 + // const initValue = toolInstance?.weight || 20; + // const initTool = toolInstance?.brushTool || ESwitchTool.Pen; + const [silderValue, setSilderValue] = useState(20); + const [selectTool, setSelectTool] = useState(ESwitchTool.Pen); + + const changeValue = () => { + onChange(selectTool, silderValue); + }; + + return ( +
+
+ { + setSilderValue(20); + setSelectTool(ESwitchTool.Pen); + changeValue(); + }} + /> + { + setSilderValue(20); + setSelectTool(ESwitchTool.Ereser); + changeValue(); + }} + /> +
+
+ + { + setSilderValue(v); + changeValue(); + }} + min={1} + max={50} + style={{ width: '60%' }} + value={silderValue} + /> + +
+
+ ); +}; + +export default ScribbleSidebar; diff --git a/packages/lb-components/src/views/MainView/sidebar/index.tsx b/packages/lb-components/src/views/MainView/sidebar/index.tsx index dd10c7ab2..a68dce076 100644 --- a/packages/lb-components/src/views/MainView/sidebar/index.tsx +++ b/packages/lb-components/src/views/MainView/sidebar/index.tsx @@ -20,6 +20,7 @@ import TagSidebar, { expandIconFuc } from './TagSidebar'; import TextToolSidebar from './TextToolSidebar'; import ToolStyle from './ToolStyle'; import { cTool } from '@labelbee/lb-annotation'; +import ScribbleSidebar from './ScribbleSidebar'; const { EVideoToolName } = cTool; @@ -140,8 +141,15 @@ const Sidebar: React.FC = ({ sider }) => { const textToolSideBar = ; - const horizontal =
; + const scribbleSidebar = ( + { + // 接收 + }} + /> + ); + const horizontal =
; if (sider) { if (typeof sider === 'function') { return ( @@ -178,6 +186,7 @@ const Sidebar: React.FC = ({ sider }) => { return (
{toolIcon} + {scribbleSidebar} {horizontal} {attributeList} {annotationText}