Start typing to search...

UI.present

Presents dialog boxes and system alerts to users on the frontend of your Koji app.

Methods

.alert(options)

Presents an alert dialog box to the user. Use this method for messages that require only an acknowledgement from the user. For messages that require a decision, use [[confirmation]]. For simple alerts that are dismissed automatically after a delay, without user interaction or a message, use [[systemAlert]].

Parameters

Example

Koji.ui.present.alert({
 title: 'Image Posted',
 message: 'Your new image is available on your fan wall!'
});

Source: frontend/ui/present/index.ts#L87

.confirmation(options)

Presents a confirmation dialog box to a user. Use this method for messages that require a decision from the user, such as to ask whether to proceed with an action. For messages that do not require a decision, use [[alert]] or [[systemAlert]].

Parameters

Returns

Promise<Boolean>, Whether the user confirmed (`true`) or cancelled (`false`) the action.

Example

const confirmed = await Koji.ui.present.confirmation({
 title: 'Delete File',
 message: 'Are you sure you want to delete this file?',
 confirmButtonLabel: 'Delete',
 cancelButtonLabel: 'Cancel'
});

Source: frontend/ui/present/index.ts#L54

.systemAlert(type)

Presents a system alert (icon and label). System alerts are displayed for 1200ms and then dismissed automatically, allowing for an easy way to communicate state changes to a user. For dialog boxes that show messages and require user interaction, use [[alert]] or [[confirmation]].

Parameters

Example

Koji.ui.present.systemAlert('success');

Source: frontend/ui/present/index.ts#L112

Interfaces

PresentAlertOptions

Defines an alert dialog box to show a user.

Properties

  • message - String, Information to display to the user.

  • title - String, Title for the dialog box.

PresentConfirmationOptions

Defines a confirmation dialog box to show a user.

Properties

  • cancelButtonLabel - String (Optional), Label for the cancel action (`Cancel` by default).

  • confirmButtonLabel - String (Optional), Label for the confirm action (`Confirm` by default).

  • message - String (Optional), Question to ask the user (empty by default).

  • title - String (Optional), Title for the dialog box (`Confirm` by default).

Type aliases

SystemAlertType

Type of a system alert – `success` (check mark), `sent` (message sent icon), `rejected` (alert icon), and `reported` (alert icon).

Possible values

  • 'success'
  • 'sent'
  • 'reported'
  • 'rejected'