mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-14 08:09:13 +08:00
fb5ed95853
* chore(deps): bump typescript to v5 * fix * fix * type fix * Update components/statistic/demo/countdown.tsx Co-authored-by: MadCcc <1075746765@qq.com> * Update components/statistic/demo/countdown.tsx Co-authored-by: MadCcc <1075746765@qq.com> * fix * fix type * update demo --------- Co-authored-by: MadCcc <1075746765@qq.com>
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import type { CountdownProps } from 'antd';
|
|
import { Col, Row, Statistic } from 'antd';
|
|
import React from 'react';
|
|
|
|
const { Countdown } = Statistic;
|
|
|
|
const deadline = Date.now() + 1000 * 60 * 60 * 24 * 2 + 1000 * 30; // Dayjs is also OK
|
|
|
|
const onFinish: CountdownProps['onFinish'] = () => {
|
|
console.log('finished!');
|
|
};
|
|
|
|
const onChange: CountdownProps['onChange'] = (val) => {
|
|
if (typeof val === 'number' && 4.95 * 1000 < val && val < 5 * 1000) {
|
|
console.log('changed!');
|
|
}
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<Row gutter={16}>
|
|
<Col span={12}>
|
|
<Countdown title="Countdown" value={deadline} onFinish={onFinish} />
|
|
</Col>
|
|
<Col span={12}>
|
|
<Countdown title="Million Seconds" value={deadline} format="HH:mm:ss:SSS" />
|
|
</Col>
|
|
<Col span={24} style={{ marginTop: 32 }}>
|
|
<Countdown title="Day Level" value={deadline} format="D 天 H 时 m 分 s 秒" />
|
|
</Col>
|
|
<Col span={12}>
|
|
<Countdown title="Countdown" value={Date.now() + 10 * 1000} onChange={onChange} />
|
|
</Col>
|
|
</Row>
|
|
);
|
|
|
|
export default App;
|