Add DialogModal and use it for close confirmations and "coming soon" features (#322)

Closes #269
Closes #196

* Add DialogModal and use it for close confirmations and "coming soon" features

* Code cleanup; add Enter key to accept emphasized dialog button
This commit is contained in:
Keavon Chambers
2021-07-31 14:30:31 -07:00
parent e1698c2783
commit 170cda7357
20 changed files with 375 additions and 67 deletions
+37
View File
@@ -0,0 +1,37 @@
import { reactive, readonly } from "vue";
import { TextButtonWidget } from "@/components/widgets/widgets";
const state = reactive({
visible: false,
icon: "",
heading: "",
details: "",
buttons: [] as TextButtonWidget[],
});
export function createDialog(icon: string, heading: string, details: string, buttons: TextButtonWidget[]) {
state.visible = true;
state.icon = icon;
state.heading = heading;
state.details = details;
state.buttons = buttons;
}
export function dismissDialog() {
state.visible = false;
}
export function submitDialog() {
const firstEmphasizedButton = state.buttons.find((button) => button.props.emphasized && button.callback);
if (firstEmphasizedButton) {
// If statement satisfies TypeScript
if (firstEmphasizedButton.callback) firstEmphasizedButton.callback();
}
}
export function dialogIsVisible(): boolean {
return state.visible;
}
export default readonly(state);