-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32ede31
commit e4e1825
Showing
7 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/lb-components/src/views/MainView/sidebar/ScribbleSidebar/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IProps> = (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 ( | ||
<div className={getClassName('scribble')}> | ||
<div className={getClassName('scribble', 'select')}> | ||
<img | ||
src={selectTool === ESwitchTool.Pen ? penActivate : pen} | ||
onClick={() => { | ||
setSilderValue(20); | ||
setSelectTool(ESwitchTool.Pen); | ||
changeValue(); | ||
}} | ||
/> | ||
<img | ||
src={selectTool === ESwitchTool.Ereser ? eraserActivate : eraser} | ||
onClick={() => { | ||
setSilderValue(20); | ||
setSelectTool(ESwitchTool.Ereser); | ||
changeValue(); | ||
}} | ||
/> | ||
</div> | ||
<div className={getClassName('scribble', 'silder')}> | ||
<span className={getClassName('scribble', 'circle')} /> | ||
<Slider | ||
onChange={(v) => { | ||
setSilderValue(v); | ||
changeValue(); | ||
}} | ||
min={1} | ||
max={50} | ||
style={{ width: '60%' }} | ||
value={silderValue} | ||
/> | ||
<span | ||
className={getClassName('scribble', 'circle')} | ||
style={{ width: '10px', height: '10px' }} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ScribbleSidebar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters