UNPKG

wcz-layout

Version:

44 lines (35 loc) 1.32 kB
--- name: notifications description: "Use when: displaying feedback with snackbars." --- ## Rules - Use `useNotification()` for lightweight non-blocking user feedback. - Always use translation; add new keys for feature-specific messages. - Notifications are automatically queued by the provider and shown one at a time. - `autoHideDuration` defaults to 5000 ms and is not capped by the library; keep overrides reasonable (~10000 ms) for messages that need more reading time. - Use `severity: "success" | "info" | "warning" | "error"` consistently with the outcome. Severity is optional omitting it renders a plain snackbar (no colored `Alert`). - Use notifications for lightweight feedback; dialogs when the user must decide or acknowledge. ## File Placement ```txt wcz-layout/hooks useNotification hook, useTranslation src/lib/locales/ translation keys ``` ## Examples ```ts // basic usage const { notify } = useNotification(); const { t } = useTranslation(); notify(t("Feature.Created"), { severity: "success", autoHideDuration: 6000, }); // error handling try { await deleteFeature({ data: id }); } catch (error) { notify(error instanceof Error ? error.message : t("DeleteFailed"), { severity: "error", autoHideDuration: 10000, }); } ```