Skip to content

Commit

Permalink
feat(lb-components): Add tips showing in annotationTips
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin-L committed Sep 30, 2022
1 parent 2eb3ae8 commit 5255983
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/lb-components/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface AppProps {
setToolInstance?: (tool: ToolInstance) => void;
mode?: 'light' | 'dark'; // 临时需求应用于 toolFooter 的操作
showTips?: boolean; // 是否展示 tips
tips?: string; // Tips 具体内容
defaultLang: 'en' | 'cn'; // 国际化设置
leftSider?: () => React.ReactNode | React.ReactNode;

Expand Down
8 changes: 7 additions & 1 deletion packages/lb-components/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ $prefix: bee;

.#{$prefix}-tips {
display: flex;
justify-content: flex-end;
justify-content: space-between;
background-color: #333;
color: rgba(255, 255, 255, 0.4);
line-height: 40px;
Expand All @@ -568,6 +568,12 @@ $prefix: bee;
width: 100%;
overflow: hidden;
white-space: nowrap;
.#{$prefix}-tips__leftContent {
max-width: 60%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}

.#{$prefix}-tips__path {
max-width: 40%;
Expand Down
14 changes: 10 additions & 4 deletions packages/lb-components/src/views/MainView/annotationTips/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ import { Tooltip } from 'antd';
import { prefix } from '@/constant';

interface IProps {
tips: string;
tips?: string;
path?: string;
}

const AnnotationTips = ({ tips }: IProps) => {
if (!tips) {
const AnnotationTips = ({ path, tips }: IProps) => {
if (!path && !tips) {
return null;
}

return (
<div className={`${prefix}-tips`}>
<Tooltip placement='bottomRight' title={tips}>
<span className={`${prefix}-tips__path`}>{tips}</span>
<span className={`${prefix}-tips__leftContent`} title={tips}>
{tips}
</span>
</Tooltip>
<Tooltip placement='bottomRight' title={path}>
<span className={`${prefix}-tips__path`}>{path}</span>
</Tooltip>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/lb-components/src/views/MainView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const layoutCls = `${prefix}-layout`;
const ImageAnnotate: React.FC<AppProps & IProps> = (props) => {
return (
<>
{props.showTips === true && <AnnotationTips tips={props.path} />}
{props.showTips === true && <AnnotationTips path={props.path} tips={props.tips} />}
<AnnotationOperation {...props} />
<ToolFooter style={props.style?.footer} mode={props.mode} footer={props?.footer} />
</>
Expand Down

0 comments on commit 5255983

Please sign in to comment.