-
Notifications
You must be signed in to change notification settings - Fork 0
PUIAlert
Elijah Cobb edited this page May 13, 2021
·
3 revisions
A PUIAlert is a modal that can be displayed to the user with actions associated with it. You present an alert using the usePUIAlert hook and pass it an object that follows the PUIAlertConfig interface. Once you call the function returned by userPUIAlert an alert will be displayed to the user and added to the global state.
Note: Only one alert can be presented at a time. Using the hook while another PUIAlert is displaying will result in the current alert being dismissed and the new one being presented.
import {PUIColor, usePUIAlert, usePUIAlertHide} from "./pstdl-ui";
import {ReactElement} from "react";
export function TestBed(): ReactElement {
const aFunctionToMakeAnAlert = usePUIAlert();
const hideAlert = usePUIAlertHide();
return <div className={"TestBed"}>
<button onClick={() => {
aFunctionToMakeAnAlert({
title: "Hello pstdl-ui!",
message: "A PUIAlert is a simple modal that takes some text and actions.",
actions: [
{
text: "Abort",
color: PUIColor.red,
onClick: () => {
console.log("AHH!")
}
},
{
text: "Ok",
onClick: hideAlert
}
]
})
}}>Click Me!</button>
</div>
}
Created by Elijah Cobb at the Planetary Surface Technology Development Lab located at Michigan Technological University
- PUIGage
- PUIImmutableBinaryStatus
- PUIImmutableNumericStatus
- PUILog
- PUIMutableBinaryStatus
- PUIMutableNumericStatus
- PUIPicker
- PUISegmentedPicker
- PUIAlert
- PUIToast
- PUICard
- PUITopBar
- PUIAppController
- PUIKeyboardController
- PUIGamepadController
- PUIHookAlert
- PUIHookLog
- PUIHookState
- PUIHookToast
- PUIApp
- PUIColor
- PUIContext