Skip to content

Commit

Permalink
feat: label-bee 添加步骤切换组件
Browse files Browse the repository at this point in the history
  • Loading branch information
luozefeng authored and laoluo committed Sep 26, 2021
1 parent b323998 commit 4100181
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 34 deletions.
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;
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;
1 change: 1 addition & 0 deletions packages/lb-components/src/constant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export enum ESubmitType {
}
// css 命名前缀
export const prefix = 'bee';
export const componentCls = `${prefix}-component`;
147 changes: 116 additions & 31 deletions packages/lb-components/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ $prefix: bee;
background: #f3f4ff;
}

>span:nth-child(2) {
> span:nth-child(2) {
flex: 1;
justify-content: space-between;
display: flex;
Expand Down Expand Up @@ -345,7 +345,7 @@ $prefix: bee;
.textareaContainer {
position: relative;

>textarea {
> textarea {
padding-bottom: 30px;
}

Expand Down Expand Up @@ -618,19 +618,22 @@ $hotkey-container-padding: 7px;
padding: 0 3px 0 8px;
}

.ant-collapse-borderless>.ant-collapse-item>.ant-collapse-content>.ant-collapse-content-box {
.ant-collapse-borderless
> .ant-collapse-item
> .ant-collapse-content
> .ant-collapse-content-box {
padding-top: 4px;
}

.ant-collapse-content>.ant-collapse-content-box {
.ant-collapse-content > .ant-collapse-content-box {
padding: 0;
}

.ant-collapse-icon-position-right>.ant-collapse-item>.ant-collapse-header {
.ant-collapse-icon-position-right > .ant-collapse-item > .ant-collapse-header {
padding-right: 40px;
}

.ant-collapse-borderless>.ant-collapse-item {
.ant-collapse-borderless > .ant-collapse-item {
border-bottom: 0px;
}
}
Expand All @@ -655,7 +658,7 @@ $hotkey-container-padding: 7px;
background: #f3f4ff;
}

>span:nth-child(2) {
> span:nth-child(2) {
flex: 1;
justify-content: space-between;
display: flex;
Expand Down Expand Up @@ -770,34 +773,38 @@ $hotkey-container-padding: 7px;

#style-color {
.ant-slider-rail {
background: linear-gradient(to right,
rgb(0, 0, 255) 0%,
rgb(0, 0, 255) 20%,
rgb(0, 255, 255) 20%,
rgb(0, 255, 255) 40%,
rgb(0, 255, 0) 40%,
rgb(0, 255, 0) 60%,
rgb(255, 255, 0) 60%,
rgb(255, 255, 0) 80%,
rgb(255, 0, 255) 80%,
rgb(255, 0, 255) 100%);
background: linear-gradient(
to right,
rgb(0, 0, 255) 0%,
rgb(0, 0, 255) 20%,
rgb(0, 255, 255) 20%,
rgb(0, 255, 255) 40%,
rgb(0, 255, 0) 40%,
rgb(0, 255, 0) 60%,
rgb(255, 255, 0) 60%,
rgb(255, 255, 0) 80%,
rgb(255, 0, 255) 80%,
rgb(255, 0, 255) 100%
);
}
}

#style-fillOpacity,
#style-borderOpacity {
.ant-slider-rail {
background: linear-gradient(to right,
rgba(0, 0, 0, 0.2) 0%,
rgba(0, 0, 0, 0.2) 20%,
rgba(0, 0, 0, 0.4) 20%,
rgba(0, 0, 0, 0.4) 40%,
rgba(0, 0, 0, 0.6) 40%,
rgba(0, 0, 0, 0.6) 60%,
rgba(0, 0, 0, 0.8) 60%,
rgba(0, 0, 0, 0.8) 80%,
rgba(0, 0, 0, 1) 80%,
rgba(0, 0, 0, 1) 100%);
background: linear-gradient(
to right,
rgba(0, 0, 0, 0.2) 0%,
rgba(0, 0, 0, 0.2) 20%,
rgba(0, 0, 0, 0.4) 20%,
rgba(0, 0, 0, 0.4) 40%,
rgba(0, 0, 0, 0.6) 40%,
rgba(0, 0, 0, 0.6) 60%,
rgba(0, 0, 0, 0.8) 60%,
rgba(0, 0, 0, 0.8) 80%,
rgba(0, 0, 0, 1) 80%,
rgba(0, 0, 0, 1) 100%
);
}
}

Expand Down Expand Up @@ -886,7 +893,7 @@ $hotkey-container-padding: 7px;
display: flex;
padding: 0 10px;

>span {
> span {
line-height: 16px;
}

Expand Down Expand Up @@ -996,4 +1003,82 @@ $hotkey-container-padding: 7px;
background-color: #f5f5f5;
cursor: not-allowed;
}
}
}

// 组件控件的问题

.#{$prefix}-component {
&__iconWithText {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
height: auto;

.iconGroup {
color: #666666;
cursor: pointer;
display: flex;
align-items: center;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;

margin: 0px 21px 4px;

.icon {
font-size: 18px;
}
}

.name {
font-size: 12px;

color: #999999;
}

&:hover &__iconGroup {
color: #666fff;
}

&:hover &__name {
color: #666fff;
}
}

&__annotationStepPopover {
padding: 12px 30px;
background: white;

.step {
margin-bottom: 24px;
&:last-child {
margin-bottom: 0px;
}

&:hover {
color: #666fff;
cursor: pointer;
}

.name {
margin-bottom: 6px;

font-size: 14px;
}
.progress {
font-size: 12px;
}
.highlight {
color: #666fff;
}
}
.isNotStart {
color: #cccccc;
&:hover {
color: #cccccc;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ export const ToNextStep = () => (dispatch: any, getState: any) => {
*/
export const UpdateProcessingStep = (toStep: number) => (dispatch: any) =>
[
ToSubmitFileData(ESubmitType.StepChanged),
dispatch({ type: ANNOTATION_ACTIONS.SUBMIT_RESULT }),
dispatch({
type: ANNOTATION_ACTIONS.SUBMIT_FILE_DATA,
payload: { submitType: ESubmitType.StepChanged },
}),
// ToSubmitFileData(ESubmitType.StepChanged),
dispatch({ type: ANNOTATION_ACTIONS.SET_STEP, payload: { toStep } }),
dispatch({ type: ANNOTATION_ACTIONS.CALC_STEP_PROGRESS }),
dispatch(loadFileData(0)),
Expand Down
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);
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import HeaderOption from './headerOption';
import { AnnotationEngine } from '@sensetime/annotation';
import { Button } from 'antd';
import { ToNextStep } from '@/store/annotation/actionCreators';
import StepSwitch from './StepSwitch';


interface INextStep {
stepProgress: number;
}


const NextStep: React.FC<INextStep> = ({ stepProgress }) => {
return (
<Button
Expand Down Expand Up @@ -71,6 +74,7 @@ const ToolHeader: React.FC<IToolHeaderProps> = ({
<div className={`${prefix}-header__title`}>
<LeftOutlined className={`${prefix}-header__icon`} onClick={closeAnnotation} />
{headerName ? <span className={`${prefix}-header__name`}>{headerName}</span> : ''}
<StepSwitch stepProgress={stepProgress} />

<NextStep stepProgress={stepProgress} />

Expand Down
Loading

0 comments on commit 4100181

Please sign in to comment.