-
Notifications
You must be signed in to change notification settings - Fork 60
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
luozefeng
authored and
laoluo
committed
Sep 26, 2021
1 parent
b323998
commit 4100181
Showing
8 changed files
with
266 additions
and
34 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
packages/lb-components/src/components/annotationStepPopover/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,51 @@ | ||
// 标注步骤中的 popover 的内容 | ||
|
||
import { componentCls } from '@/constant'; | ||
import { classnames } from '@/utils'; | ||
import React from 'react'; | ||
import { IStepInfo } from '@/types/step'; | ||
import { cTool } from '@sensetime/annotation'; | ||
|
||
const { TOOL_NAME } = cTool; | ||
|
||
interface IProps { | ||
stepList: IStepInfo[]; | ||
currentStep: number; | ||
updateStep: (step: number) => void; | ||
} | ||
|
||
const AnnotationStepPopover = (props: IProps) => { | ||
const { stepList, updateStep, currentStep } = props; | ||
|
||
return ( | ||
<div className={`${componentCls}__annotationStepPopover`}> | ||
{stepList.map((info) => { | ||
const isSelected = info.step === currentStep; | ||
const isClick = true; | ||
|
||
return ( | ||
<div | ||
key={`stepList${info.step}`} | ||
className={classnames({ | ||
step: true, | ||
})} | ||
onClick={() => { | ||
isClick && updateStep(info.step); | ||
}} | ||
> | ||
<div | ||
className={classnames({ | ||
name: true, | ||
highlight: isSelected, | ||
})} | ||
> | ||
{`${info.step} - ${info.name || TOOL_NAME[info.tool]}`} | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AnnotationStepPopover; |
30 changes: 30 additions & 0 deletions
30
packages/lb-components/src/components/customAntd/IconWithText/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,30 @@ | ||
import { componentCls } from '@/constant'; | ||
import React from 'react'; | ||
|
||
interface IProps { | ||
text: string; // icon 文本 | ||
Icon: any; | ||
iconChildren: React.ReactNode; | ||
marginLeft: number; | ||
} | ||
|
||
const IconWithText = (props: IProps) => { | ||
const { Icon, text, iconChildren, ...otherProps } = props; | ||
|
||
const marginLeft = props.marginLeft === undefined ? 30 : props.marginLeft; | ||
|
||
return ( | ||
<div {...otherProps} className={componentCls} > | ||
<div className={`${componentCls}__iconWithText`} style={{ marginLeft }}> | ||
<div className='iconGroup'> | ||
<Icon className='icon' /> | ||
{iconChildren} | ||
</div> | ||
|
||
<span className='name'>{text}</span> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default IconWithText; |
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
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
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
55 changes: 55 additions & 0 deletions
55
packages/lb-components/src/views/MainView/toolHeader/StepSwitch/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,55 @@ | ||
/** | ||
* 用于多步骤中的切换 | ||
*/ | ||
|
||
import { Dropdown } from 'antd'; | ||
import { CaretDownOutlined, OrderedListOutlined } from '@ant-design/icons'; | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { AppState } from '@/store'; | ||
import IconWithText from '@/components/customAntd/IconWithText'; | ||
import { prefix } from '@/constant'; | ||
import AnnotationStepPopover from '@/components/annotationStepPopover'; | ||
import { IStepInfo } from '@/types/step'; | ||
import { store } from '@/index'; | ||
import { UpdateProcessingStep } from '@/store/annotation/actionCreators'; | ||
|
||
interface IProps { | ||
stepProgress: number; | ||
stepList: IStepInfo[]; | ||
step: number; | ||
} | ||
|
||
const StepSwitch: React.FC<IProps> = ({ stepProgress, step, stepList }) => { | ||
const updateStep = (toStep: number) => { | ||
store.dispatch(UpdateProcessingStep(toStep)) | ||
} | ||
|
||
return ( | ||
<span className={`${prefix}`}> | ||
<Dropdown | ||
overlay={ | ||
<AnnotationStepPopover | ||
stepList={stepList} | ||
baseStep={step} | ||
updateStep={updateStep} | ||
currentStep={step} | ||
/> | ||
} | ||
> | ||
<IconWithText | ||
text='标注步骤' | ||
Icon={OrderedListOutlined} | ||
iconChildren={<CaretDownOutlined style={{ fontSize: 8 }} />} | ||
/> | ||
</Dropdown> | ||
</span> | ||
); | ||
}; | ||
|
||
const mapStateToProps = (state: AppState) => ({ | ||
stepList: state.annotation.stepList, | ||
step: state.annotation.step, | ||
}); | ||
|
||
export default connect(mapStateToProps)(StepSwitch); |
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
Oops, something went wrong.