Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 12 additions & 11 deletions packages/components/loading/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useState, useEffect, useMemo, CSSProperties } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import classnames from 'classnames';
import { canUseDocument } from '../_util/dom';
import useConfig from '../hooks/useConfig';
import { StyledProps } from '../common';
import { TdLoadingProps } from './type';
import { addClass, removeClass } from '../_util/style';
import Portal from '../common/Portal';
import Gradient from './gradient';
import { loadingDefaultProps } from './defaultProps';
import useConfig from '../hooks/useConfig';
import useDefaultProps from '../hooks/useDefaultProps';
import { addClass, removeClass } from '../_util/style';
import { loadingDefaultProps } from './defaultProps';
import Gradient from './gradient';

import type { StyledProps } from '../common';
import type { TdLoadingProps } from './type';

export interface LoadingProps extends TdLoadingProps, StyledProps {}

Expand Down Expand Up @@ -61,7 +62,7 @@ const Loading: React.FC<LoadingProps> = (props) => {
}, [delay, loading]);

const calcStyles = useMemo<React.CSSProperties>(() => {
const styles: CSSProperties = {};
const styles: React.CSSProperties = {};

if (zIndex !== undefined) {
styles.zIndex = zIndex;
Expand Down Expand Up @@ -113,7 +114,7 @@ const Loading: React.FC<LoadingProps> = (props) => {
};

if (fullscreen) {
return loading ? (
return showLoading ? (
<div className={classnames(name, fullscreenClass, centerClass, overlayClass)} style={{ ...calcStyles, ...style }}>
<div className={baseClasses}>{commonContent()}</div>
</div>
Expand All @@ -140,7 +141,7 @@ const Loading: React.FC<LoadingProps> = (props) => {
if (attach) {
return (
<Portal attach={attach}>
{loading ? (
{showLoading ? (
<div
className={classnames(name, baseClasses, fullClass, { [overlayClass]: showOverlay })}
style={{ ...calcStyles, ...style }}
Expand All @@ -152,7 +153,7 @@ const Loading: React.FC<LoadingProps> = (props) => {
);
}

return loading ? (
return showLoading ? (
<div className={classnames(name, baseClasses)} style={{ ...calcStyles, ...style }}>
{commonContent()}
</div>
Expand Down
26 changes: 1 addition & 25 deletions test/snap/__snapshots__/csr.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69043,31 +69043,7 @@ exports[`csr snapshot test > csr test packages/components/loading/_example/delay
<div
class="t-space-item"
>
<div>
<div
class="t-loading t-loading--center t-size-s"
>
<svg
class="t-loading__gradient t-icon-loading"
height="1em"
version="1.1"
viewBox="0 0 12 12"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<foreignobject
height="12"
width="12"
x="0"
y="0"
>
<div
class="t-loading__gradient-conic"
/>
</foreignobject>
</svg>
</div>
</div>
<div />
</div>
<div
class="t-space-item"
Expand Down
Loading