Files
trailway-front/src/components/ui/Spins.tsx
2024-01-11 00:49:37 +08:00

96 lines
3.7 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.
/**
* Created by hao.cheng on 2017/4/23.
*/
import React from 'react';
import { Row, Col, Card, Spin, Alert, Switch, Button } from 'antd';
import BreadcrumbCustom from '../widget/BreadcrumbCustom';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
class Spins extends React.Component {
state = { loading: false };
toggle = (value: boolean) => {
this.setState({ loading: value });
};
nprogressStart = () => {
NProgress.start();
};
nprogressDone = () => {
NProgress.done();
};
render() {
const container = (
<Alert
message="Alert message title"
description="Further details about the context of this alert."
type="info"
/>
);
return (
<div className="gutter-example button-demo">
<BreadcrumbCustom breads={['UI', '加载中']} />
<Row gutter={16}>
<Col className="gutter-row" md={12}>
<div className="gutter-box">
<Card bordered={false}>
<Spin />
</Card>
</div>
</Col>
<Col className="gutter-row" md={12}>
<div className="gutter-box">
<Card>
<Spin size="small" />
<Spin />
<Spin size="large" />
</Card>
</div>
</Col>
</Row>
<Row gutter={16}>
<Col className="gutter-row" md={12}>
<div className="gutter-box">
<Card bordered={false}>
<Spin tip="Loading...">
<Alert
message="Alert message title"
description="Further details about the context of this alert."
type="info"
/>
</Spin>
</Card>
</div>
</Col>
<Col className="gutter-row" md={12}>
<div className="gutter-box">
<Card bordered={false}>
<Spin spinning={this.state.loading}>{container}</Spin>
Loading state
<Switch checked={this.state.loading} onChange={this.toggle} />
</Card>
</div>
</Col>
<Col className="gutter-row" md={12}>
<div className="gutter-box">
<Card bordered={false}>
<h4></h4>
<p>
<Button icon="caret-right" onClick={this.nprogressStart} />
<span> NProgress.start() </span>
</p>
<p style={{ marginTop: 20 }}>
<Button icon="caret-right" onClick={this.nprogressDone} />
<span> NProgress.done() </span>
</p>
</Card>
</div>
</Col>
</Row>
</div>
);
}
}
export default Spins;