react-haiku icon indicating copy to clipboard operation
react-haiku copied to clipboard

[FEAT] Add useNotification hook

Open m10rten opened this issue 1 year ago • 1 comments

Description To add a hook that allows usage of the built in notification system: mozilla

Acceptance Criteria

  • [ ] Allows for title input
  • [ ] Allows for description input
  • [ ] Allows for image input
  • [ ] Needs to check permissions with Notification.permission
  • [ ] All other notification properties, specified on mozilla docs.
  • [ ] Returns the events from the notification (close, click, error, show, etc.)

Example usage

import { useNotification } from "react-haiku";

//... component
const { show, close } = useNotification({
  title: "Test Notification",
  //... more properties here
});

//... in button for example:
onClick={() => {
  show();
}}
//... close component

the hook will either show the notification or not at all if the permission is denied.

We could also return the permission status: 'denied' | 'granted' | 'loading' | 'default'

m10rten avatar Jul 12 '23 08:07 m10rten