Skip to content

fix(empty): fix active search empty will flush #542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/empty/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,14 @@ import { Empty } from 'dt-react-component';
import { Space } from 'antd';

export default () => {
return <Empty description="搜索无数据" type="search" active={true} />;
return (
<>
<Empty description="搜索无数据" type="search" active={true} />
<Empty description="搜索无数据" type="search" />
<Empty description="搜索无数据" size="large" type="search" active={true} />
<Empty description="搜索无数据" size="large" type="search" />
</>
);
};
```

Expand Down
25 changes: 15 additions & 10 deletions src/empty/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const Empty = (props: EmptyProps) => {
active = false,
children,
image,
imageStyle,
extra,
className,
style,
Expand All @@ -39,10 +38,10 @@ const Empty = (props: EmptyProps) => {
const img = () => {
if (type === 'search' && active) {
return (
<div className="dtc-empty__container">
<>
<SearchIcon className="dtc-empty__search" />
<LoupeIcon className="dtc-empty__loupe" />
</div>
</>
);
} else if (IMG_MAP[type]) {
return <img src={require(`./emptyImg/${IMG_MAP[type]}`)} />;
Expand All @@ -54,14 +53,20 @@ const Empty = (props: EmptyProps) => {
let newImage: ReactNode = img() || null;
if (image) newImage = image as ReactNode;

const height = size === 'default' ? 80 : 100;

return showEmpty ? (
<div className={classNames('dtc-empty', className)} style={style}>
<AntdEmpty {...restProps} image={newImage} imageStyle={{ height, ...imageStyle }}>
{extra}
</AntdEmpty>
</div>
<AntdEmpty
className={classNames(
'dtc-empty',
size === 'large' && 'dtc-empty__large',
active && 'dtc-empty__active',
className
)}
style={style}
image={newImage}
{...restProps}
>
{extra}
</AntdEmpty>
) : (
<>{children}</>
);
Expand Down
117 changes: 89 additions & 28 deletions src/empty/style.scss
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
.dtc-empty {
.ant-empty {
$defaultSize: 80px;
$largeSize: 100px;

.ant-empty.dtc-empty {
.ant-empty-image {
display: flex;
justify-content: center;
width: $defaultSize;
height: $defaultSize;
font-size: $defaultSize;
margin: 0 auto 8px;
}
.ant-empty-description {
color: #8B8FA8;
line-height: 20px;
font-size: 14px;
font-family: PingFangSC-Regular, "PingFang SC";
font-weight: 400;
}
&__active {
.ant-empty-image {
display: flex;
justify-content: center;
margin-bottom: 8px;
}
.ant-empty-description {
color: #8B8FA8;
line-height: 20px;
font-size: 14px;
font-family: PingFangSC-Regular, "PingFang SC";
font-weight: 400;
position: relative;
}
}
}

.dtc-empty__container {
position: relative;
width: 80px;
height: 80px;
bottom: 8px;
.dtc-empty__search {
font-size: 80px;
position: absolute;
top: 0;
left: 0;
width: 80px;
height: 80px;
line-height: 0;
font-size: 100%;
}
.dtc-empty__loupe {
font-size: 38px;
line-height: 0;
position: absolute;
width: 38px;
height: 38px;
font-size: 38px;
right: 10px;
bottom: 2px;
animation:
animY 1s cubic-bezier(0.36, 0, 0.64, 1) 0.5s infinite alternate,
animX 1s cubic-bezier(0.36, 0, 0.64, 1) -0s infinite alternate;
}
&__large {
.ant-empty-image {
width: $largeSize;
height: $largeSize;
font-size: $largeSize;
}
.dtc-empty__loupe {
font-size: 48px;
}
}
}

@keyframes animX {
Expand All @@ -56,3 +65,55 @@
bottom: 17px;
}
}

// .dtc-empty {
// .ant-empty {
// .ant-empty-image {
// display: flex;
// justify-content: center;
// margin-bottom: 8px;
// }
// .ant-empty-description {
// color: #8b8fa8;
// line-height: 20px;
// font-size: 14px;
// font-family: PingFangSC-Regular, 'PingFang SC';
// font-weight: 400;
// }
// }
// }

// .dtc-empty-container {
// position: relative;
// width: 80px;
// height: 80px;
// .dtc-empty__search {
// font-size: 80px;
// line-height: 0;
// position: absolute;
// top: 0;
// left: 0;
// }
// .dtc-empty__loupe {
// font-size: 38px;
// position: absolute;
// bottom: 2px;
// right: 10px;
// line-height: 0;
// animation: animY 1s cubic-bezier(0.36, 0, 0.64, 1) 0.5s infinite alternate,
// animX 1s cubic-bezier(0.36, 0, 0.64, 1) -0s infinite alternate;
// }

// &__large {
// width: 100px;
// height: 100px;

// .dtc-empty__search {
// font-size: 100px;
// }

// .dtc-empty__loupe {
// font-size: 48px;
// }
// }
// }
Loading