Files
animal-island-ui/demo/components/Loading/LoadingDemo.tsx
T

75 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React, { useState } from 'react';
import { Loading as LoadingComponent, Button } from '../../../src';
import { CodeBlock, ApiTable, ApiRow, sectionStyle, sectionTitleStyle, tagStyle, demoBodyStyle, labelStyle } from '../../tools';
const LoadingDemo: React.FC = () => {
const [active, setActive] = useState(true);
return (
<div style={sectionStyle}>
<div style={sectionTitleStyle}>
Loading <span style={tagStyle}></span>
</div>
<div style={labelStyle}>
Loading
</div>
<div style={{ marginBottom: 16 }}>
<Button type={active ? 'default' : 'primary'} onClick={() => setActive(!active)}>
{active ? '关闭 Loading' : '开启 Loading'}
</Button>
</div>
<div style={{ ...demoBodyStyle, position: 'relative', height: 800, padding: 0, overflow: 'hidden' }}>
<div
style={{
position: 'absolute',
inset: 0,
background: 'linear-gradient(135deg, #ffd6a5 0%, #fdffb6 25%, #caffbf 50%, #9bf6ff 75%, #a0c4ff 100%)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: 28,
fontWeight: 600,
color: '#333',
}}
>
· Underlying Content
</div>
<LoadingComponent
active={active}
style={{ height: '100%', position: 'absolute', inset: 0 }}
/>
</div>
<CodeBlock
code={`import React, { useState } from 'react';
import { Loading } from 'animal-island-ui';
const App = () => {
const [active, setActive] = useState(true);
return (
<div style={{ position: 'relative', height: 800 }}>
{/* 底层内容 */}
<div style={{ position: 'absolute', inset: 0 }}>Underlying Content</div>
{/* Loading 覆盖层,关闭时透明圆形扩散露出底层 */}
<Loading
active={active}
style={{ position: 'absolute', inset: 0, height: '100%' }}
/>
<button onClick={() => setActive(!active)}>
{active ? '关闭 Loading' : '开启 Loading'}
</button>
</div>
);
};`}
/>
<ApiTable rows={LOADING_API} />
</div>
);
};
const LOADING_API: ApiRow[] = [
{ prop: 'active', desc: '是否显示加载动画', type: 'boolean', defaultVal: 'true' },
{ prop: 'className', desc: '自定义类名', type: 'string', defaultVal: '-' },
{ prop: 'style', desc: '自定义样式', type: 'CSSProperties', defaultVal: '-' },
];
export default LoadingDemo;