mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 14:23:44 +02:00
Make modals programatically controllable via a HOC
This allows entire components to be unmounted when the modal is hidden without affecting the fade in/out of the modal itself. This also makes it easier to programatically dismiss a modal without having to copy the visibility all over the place, and makes working with props much simpler in those modal components
This commit is contained in:
15
resources/scripts/context/ModalContext.ts
Normal file
15
resources/scripts/context/ModalContext.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
|
||||
export interface ModalContextValues {
|
||||
dismiss: () => void;
|
||||
toggleSpinner: (visible?: boolean) => void;
|
||||
}
|
||||
|
||||
const ModalContext = React.createContext<ModalContextValues>({
|
||||
dismiss: () => null,
|
||||
toggleSpinner: () => null,
|
||||
});
|
||||
|
||||
ModalContext.displayName = 'ModalContext';
|
||||
|
||||
export default ModalContext;
|
||||
Reference in New Issue
Block a user