Better dialog setting logic
This commit is contained in:
parent
7a6440988b
commit
e49e6ee802
4 changed files with 87 additions and 43 deletions
|
@ -1,13 +1,18 @@
|
|||
import React from 'react';
|
||||
import { IconPosition } from './DialogIcon';
|
||||
|
||||
type Callback<T> = ((value: T) => void) | React.Dispatch<React.SetStateAction<T>>;
|
||||
|
||||
interface DialogContextType {
|
||||
icon: React.RefObject<HTMLDivElement | undefined>;
|
||||
buttons: React.RefObject<HTMLDivElement | undefined>;
|
||||
setIcon: Callback<React.ReactNode>;
|
||||
setFooter: Callback<React.ReactNode>;
|
||||
setIconPosition: Callback<IconPosition>;
|
||||
}
|
||||
|
||||
const DialogContext = React.createContext<DialogContextType>({
|
||||
icon: React.createRef(),
|
||||
buttons: React.createRef(),
|
||||
setIcon: () => null,
|
||||
setFooter: () => null,
|
||||
setIconPosition: () => null,
|
||||
});
|
||||
|
||||
export default DialogContext;
|
||||
|
|
Reference in a new issue