en:outskirts:mages-peaks:toasts
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:outskirts:mages-peaks:toasts [2023/11/12 21:30] – removed - external edit (Unknown date) 127.0.0.1 | en:outskirts:mages-peaks:toasts [2024/10/28 08:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Notifications Management (Toasts & Modal) ====== | ||
| + | |||
| + | ===== What are Toasts ? ===== | ||
| + | |||
| + | Bootstrap Toasts are managed, and can be invoked programmatically. | ||
| + | |||
| + | They will display above the Map Area. **Several Toasts can be displayed simultaneously, | ||
| + | |||
| + | See [[https:// | ||
| + | |||
| + | A full Toast is composed of either or both: | ||
| + | * a Title text | ||
| + | * a Text body | ||
| + | * Plus an (optional) colored tag ('' | ||
| + | |||
| + | It can have an [X] button to make it '' | ||
| + | |||
| + | It can close itself after a specified delay ('' | ||
| + | |||
| + | {{en: | ||
| + | |||
| + | A specific type is also supported: "'' | ||
| + | |||
| + | {{en: | ||
| + | |||
| + | For this type of Toast, an " | ||
| + | |||
| + | {{en: | ||
| + | |||
| + | ==== Sample Uses ==== | ||
| + | Toasts can be used to: | ||
| + | * Notify that an operation failed | ||
| + | * Notify the success of an asynchronous operation | ||
| + | * Notify an event | ||
| + | * Materialize a pending user action (cancellable) | ||
| + | * Let the user interact with the Map and trigger a pending action | ||
| + | |||
| + | ==== API ==== | ||
| + | A Toast is created using '' | ||
| + | |||
| + | The Toast Definition is as follows: | ||
| + | < | ||
| + | export interface ToastDef { | ||
| + | /** The Toast Header will be shown with this title. | ||
| + | title?: string; | ||
| + | /** The tag color class besides Title or Body. Tag Absent if not specified. */ | ||
| + | tagColor?: ' | ||
| + | /** Text in the body, if any. */ | ||
| + | bodyText?: string; | ||
| + | /** | ||
| + | * Close mode: | ||
| + | * - closeable: Only the [X] close button. | ||
| + | * - autohide: Only after hideDelay millis | ||
| + | * - closeable+autohide: | ||
| + | * - cancellable: | ||
| + | * - no-close: only the code can dismiss this Toast. | ||
| + | */ | ||
| + | closeMode: CloseMode; | ||
| + | /** If auto-hide, gives the delay (millis). Default 5000. */ | ||
| + | hideDelay?: number; | ||
| + | /** If cancellable, | ||
| + | onEnded?: (how: " | ||
| + | /** If cancellable, | ||
| + | actionLabel?: | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Modals ===== | ||
| + | The `Modal.svelte` component is provided for simple Modals. | ||
| + | |||
| + | {{en: | ||
| + | |||
| + | It can accept any number of buttons, with a specified label, className (btn-primary, | ||
| + | |||
| + | ==== Adding a Modal ==== | ||
| + | Just insert a < | ||
| + | |||
| + | < | ||
| + | <Modal | ||
| + | title=" | ||
| + | bodyText=" | ||
| + | buttons={[ | ||
| + | { label: " | ||
| + | ]} | ||
| + | open={isOpen} | ||
| + | onClose={processModal} | ||
| + | /> | ||
| + | </ | ||
| + | |||
