dialogs sorta work now
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import React, {createContext, useState} from "react";
|
||||
import {DialogConfig, DialogType} from "../models/Dialog";
|
||||
import {unimplemented} from "../helpers/misc";
|
||||
|
||||
interface DialogContextValue {
|
||||
dialog: DialogConfig,
|
||||
setDialog: (dialog: DialogConfig) => void,
|
||||
}
|
||||
|
||||
const DialogContext = createContext<DialogContextValue>({
|
||||
dialog: {type: DialogType.None},
|
||||
setDialog: unimplemented,
|
||||
});
|
||||
|
||||
export const DialogContextProvider: React.FC = ({children}) => {
|
||||
const [dialog, setDialog] = useState<DialogConfig>({type: DialogType.None});
|
||||
|
||||
return (
|
||||
<DialogContext.Provider value={{dialog, setDialog}}>
|
||||
{children}
|
||||
</DialogContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export function makeDialog(dialog: DialogConfig) {
|
||||
switch (dialog.type) {
|
||||
case DialogType.None:
|
||||
return undefined;
|
||||
case DialogType.AddColor:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export default DialogContext;
|
||||
Reference in New Issue
Block a user