@cubetiq/antd-modal
v0.0.1-alpha.3
Published
Modal from Ant Design, draggable, resizable.
Downloads
927
Readme
Modal from Ant Design, draggable, resizable.
🌎 Example
Required
- Ant Design 5.x
- React 18.x
✨ Features
- [x] Drag with title bar.
- [x] Resize with handle.
- [x] Keep in bounds.
- [x] During drag.
- [x] During resize.
- [x] During resize window.
- [x] Multiple modals with managed
zIndex
. - [x] Open from center.
- [ ] Better API for using as a controlled component.
- [ ] Open from quadrants.
- [ ] Better escape key management.
- [ ] Resize with option key.
✨ Enhancements
- [x] Ant Design 5.x
- [ ] Modal
visible
toopen
📦 Install
yarn add @cubetiq/antd-modal
NOTE: You must use react@18
and react-dom@18
or higher and antd@5
or higher.
🔨 Usage
import { useState, useCallback } from 'react'
import { Button } from 'antd'
import { DraggableModal, DraggableModalProvider } from '@cubetiq/antd-modal'
import '@cubetiq/antd-modal/dist/index.css'
const ModalWithButton = () => {
const [visible, setVisible] = useState(false)
const onOk = useCallback(() => setVisible(true), [])
const onCancel = useCallback(() => setVisible(false), [])
return (
<>
<Button onClick={onOk}>Open</Button>
<DraggableModal open={visible} onOk={onOk} onCancel={onCancel}>
Body text.
</DraggableModal>
</>
)
}
// DraggableModalProvider manages the zIndex
// of DraggableModals rendered beneath it.
const App = () => (
<DraggableModalProvider>
<ModalWithButton />
<ModalWithButton />
<ModalWithButton />
</DraggableModalProvider>
)
⚠️ User Experience Warning
You should probably try to design your app not to need to use this, apps should usually not be window managers.
License
MIT © DylanVann