fix(style): tooltip overflow
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
||||||
|
import { Tooltip, TooltipProps } from 'antd';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
@@ -7,7 +8,7 @@ const Wrapper = styled.div<{ $maxHeight?: number }>`
|
|||||||
typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight};
|
typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight};
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-inline: 10px;
|
padding-inline: 8px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const OverlayScroller: React.FC<any> = ({
|
const OverlayScroller: React.FC<any> = ({
|
||||||
@@ -33,7 +34,7 @@ const OverlayScroller: React.FC<any> = ({
|
|||||||
<Wrapper
|
<Wrapper
|
||||||
ref={scroller}
|
ref={scroller}
|
||||||
className="overlay-scroller-wrapper"
|
className="overlay-scroller-wrapper"
|
||||||
$maxHeight={maxHeight || '100%'}
|
$maxHeight={maxHeight || 200}
|
||||||
hidden={false}
|
hidden={false}
|
||||||
as="div"
|
as="div"
|
||||||
style={{
|
style={{
|
||||||
@@ -45,4 +46,32 @@ const OverlayScroller: React.FC<any> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const TooltipOverlayScroller: React.FC<
|
||||||
|
TooltipProps & { maxHeight?: number }
|
||||||
|
> = ({ children, maxHeight, title, ...rest }) => {
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
destroyTooltipOnHide
|
||||||
|
overlayInnerStyle={{
|
||||||
|
width: 'max-content',
|
||||||
|
maxWidth: 300,
|
||||||
|
paddingInlineEnd: 0
|
||||||
|
}}
|
||||||
|
title={
|
||||||
|
title && (
|
||||||
|
<OverlayScroller
|
||||||
|
style={{ paddingInlineStart: 0 }}
|
||||||
|
maxHeight={maxHeight}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</OverlayScroller>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{...rest}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default OverlayScroller;
|
export default OverlayScroller;
|
||||||
|
|||||||
@@ -1,31 +1,36 @@
|
|||||||
import { convertFileSize } from '@/utils';
|
import { convertFileSize } from '@/utils';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import SimpleBar from 'simplebar-react';
|
|
||||||
import 'simplebar-react/dist/simplebar.min.css';
|
import 'simplebar-react/dist/simplebar.min.css';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
.file-part-item {
|
||||||
|
width: 180px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const FileParts: React.FC<{
|
const FileParts: React.FC<{
|
||||||
showSize?: boolean;
|
showSize?: boolean;
|
||||||
fileList: any[];
|
fileList: any[];
|
||||||
}> = ({ fileList, showSize = true }) => {
|
}> = ({ fileList, showSize = true }) => {
|
||||||
return (
|
return (
|
||||||
<SimpleBar
|
<Wrapper>
|
||||||
style={{ maxHeight: 200 }}
|
{fileList.map((file, index) => {
|
||||||
classNames={{ scrollbar: 'scrollbar-handle-light simplebar-scrollbar' }}
|
return (
|
||||||
>
|
<div key={index} className="file-part-item">
|
||||||
<div style={{ padding: 10 }}>
|
<span>
|
||||||
{fileList.map((file, index) => {
|
Part {file.part} of {file.total}
|
||||||
return (
|
</span>
|
||||||
<div key={index} className="flex-between m-b-5">
|
{<span>{convertFileSize(file.size)}</span>}
|
||||||
<span>
|
</div>
|
||||||
{' '}
|
);
|
||||||
Part {file.part} of {file.total}
|
})}
|
||||||
</span>
|
</Wrapper>
|
||||||
{showSize && <span>{convertFileSize(file.size)}</span>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</SimpleBar>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import { TooltipOverlayScroller } from '@/components/overlay-scroller';
|
||||||
import { convertFileSize } from '@/utils';
|
import { convertFileSize } from '@/utils';
|
||||||
import { InfoCircleOutlined } from '@ant-design/icons';
|
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||||
import { Tag, Tooltip } from 'antd';
|
import { Tag } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@@ -24,13 +25,7 @@ const FilePartsTag = (props: { parts: any[] }) => {
|
|||||||
}
|
}
|
||||||
const { parts } = props;
|
const { parts } = props;
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<TooltipOverlayScroller title={<FileParts fileList={parts}></FileParts>}>
|
||||||
overlayInnerStyle={{
|
|
||||||
width: 180,
|
|
||||||
padding: 0
|
|
||||||
}}
|
|
||||||
title={<FileParts fileList={parts}></FileParts>}
|
|
||||||
>
|
|
||||||
<Tag
|
<Tag
|
||||||
className="tag-item"
|
className="tag-item"
|
||||||
color="purple"
|
color="purple"
|
||||||
@@ -43,7 +38,7 @@ const FilePartsTag = (props: { parts: any[] }) => {
|
|||||||
{parts.length} parts
|
{parts.length} parts
|
||||||
</span>
|
</span>
|
||||||
</Tag>
|
</Tag>
|
||||||
</Tooltip>
|
</TooltipOverlayScroller>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ const options = [
|
|||||||
{
|
{
|
||||||
label: '--truncation',
|
label: '--truncation',
|
||||||
value: '--truncation'
|
value: '--truncation'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--max-link-num',
|
||||||
|
value: '--max-link-num'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { modelsExpandKeysAtom } from '@/atoms/models';
|
|||||||
import AutoTooltip from '@/components/auto-tooltip';
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
import DeleteModal from '@/components/delete-modal';
|
import DeleteModal from '@/components/delete-modal';
|
||||||
import DropdownButtons from '@/components/drop-down-buttons';
|
import DropdownButtons from '@/components/drop-down-buttons';
|
||||||
import OverlayScroller from '@/components/overlay-scroller';
|
import { TooltipOverlayScroller } from '@/components/overlay-scroller';
|
||||||
import { FilterBar } from '@/components/page-tools';
|
import { FilterBar } from '@/components/page-tools';
|
||||||
import StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
import { PageAction } from '@/config';
|
import { PageAction } from '@/config';
|
||||||
@@ -27,15 +27,7 @@ import {
|
|||||||
InfoCircleOutlined
|
InfoCircleOutlined
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { useIntl, useNavigate } from '@umijs/max';
|
import { useIntl, useNavigate } from '@umijs/max';
|
||||||
import {
|
import { ConfigProvider, Empty, Table, Tag, Typography, message } from 'antd';
|
||||||
ConfigProvider,
|
|
||||||
Empty,
|
|
||||||
Table,
|
|
||||||
Tag,
|
|
||||||
Tooltip,
|
|
||||||
Typography,
|
|
||||||
message
|
|
||||||
} from 'antd';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@@ -97,18 +89,14 @@ const PathWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const OverlayScrollerWrapper = styled.div`
|
|
||||||
.overlay-scroller-wrapper {
|
|
||||||
padding-block: 0;
|
|
||||||
padding-inline: 6px 0;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ItemWrapper = styled.ul`
|
const ItemWrapper = styled.ul`
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding-inline: 8px 0;
|
padding-inline: 15px 0;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
|
li {
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const FilesTag = styled(Tag)`
|
const FilesTag = styled(Tag)`
|
||||||
@@ -337,21 +325,14 @@ const ModelFiles = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<TooltipOverlayScroller title={renderItem()}>
|
||||||
title={
|
|
||||||
<OverlayScrollerWrapper>
|
|
||||||
<OverlayScroller>{renderItem()}</OverlayScroller>
|
|
||||||
</OverlayScrollerWrapper>
|
|
||||||
}
|
|
||||||
overlayInnerStyle={{ width: 'max-content', maxWidth: 300 }}
|
|
||||||
>
|
|
||||||
<FilesTag color="purple" icon={<InfoCircleOutlined />}>
|
<FilesTag color="purple" icon={<InfoCircleOutlined />}>
|
||||||
<span style={{ opacity: 1 }}>
|
<span style={{ opacity: 1 }}>
|
||||||
{record.resolved_paths?.length}{' '}
|
{record.resolved_paths?.length}{' '}
|
||||||
{intl.formatMessage({ id: 'models.form.files' })}
|
{intl.formatMessage({ id: 'models.form.files' })}
|
||||||
</span>
|
</span>
|
||||||
</FilesTag>
|
</FilesTag>
|
||||||
</Tooltip>
|
</TooltipOverlayScroller>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user