Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Drawer add loading prop to show spinner (#48563)
* feat: Drawer add loading prop to show spinner * fix: loading replace drawer content while true * fix: update snap * fix: update site snap * fix: increase test coverage * fix: upate check-site snap --------- Co-authored-by: ykryshtal <ykryshtal@magnite.com>
- Loading branch information
Showing
9 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## zh-CN | ||
|
||
设置抽屉加载状态。 | ||
|
||
## en-US | ||
|
||
Set the loading status of Drawer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import type { DrawerProps } from 'antd'; | ||
import { Button, Drawer } from 'antd'; | ||
|
||
const App: React.FC = () => { | ||
const [open, setOpen] = useState(false); | ||
const [loading, setLoading] = useState<DrawerProps['loading']>(true); | ||
let id: NodeJS.Timer; | ||
|
||
const showDrawer = () => { | ||
setOpen(true); | ||
}; | ||
|
||
const onClose = () => { | ||
setOpen(false); | ||
clearTimeout(Number(id)); | ||
}; | ||
|
||
useEffect(() => { | ||
setLoading(true); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (open) { | ||
id = setTimeout(() => { | ||
setLoading(false); | ||
}, 1000); | ||
} | ||
}, [open]); | ||
|
||
return ( | ||
<> | ||
<Button type="primary" onClick={showDrawer}> | ||
Open | ||
</Button> | ||
<Drawer | ||
title="Basic Drawer" | ||
placement="right" | ||
closable={false} | ||
onClose={onClose} | ||
open={open} | ||
loading={loading} | ||
afterOpenChange={(visible) => !visible && setLoading(true)} | ||
> | ||
<Button onClick={() => setLoading(true)}>set Loading true</Button> | ||
<p>Some contents...</p> | ||
<p>Some contents...</p> | ||
<p>Some contents...</p> | ||
</Drawer> | ||
</> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters