Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create useToast Provider/Hook #3

Open
nsantos16 opened this issue Aug 11, 2020 · 1 comment
Open

Create useToast Provider/Hook #3

nsantos16 opened this issue Aug 11, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request hacktoberfest V0.1 release Will be included in V0.1 release

Comments

@nsantos16
Copy link
Contributor

Description

We need to implement the basic hook to render a component passed as a param on an absolute position.
According to primary research about how to render on the virtual DOM root, we need to provide an app wrapper (Provided) to distinct the absolute position of the screen.


The basic API of the hook is the next one:

const {onOpen, onClose} = useToast (<CustomToastComponent />);

In which:

  • useToast is a hook invokes in whatever component inside the app
  • onOpen is a handler function that when is invoked, shows<CustomToastComponent />in a fixed position (for now)
  • onClose is a handler function that when is invoked remove<CustomToastComponent />from the app if it was shown, in another case, it doesn't anything

The basic API of the provider is the next one:

<ToastProvider>
  <App />
<ToastProvider />

In which:

  • App is the application
  • ToastProvider is a provider that allows useToast hook to show the custom component from anywhere in the application.

** Additional context **
To implementing the Provider component, is recommended use Context API

@nsantos16 nsantos16 added enhancement New feature or request V0.1 release Will be included in V0.1 release labels Aug 11, 2020
@nsantos16 nsantos16 self-assigned this Aug 11, 2020
@nsantos16 nsantos16 added this to Backlog in Public backlog via automation Aug 11, 2020
@peter7z
Copy link

peter7z commented Aug 12, 2020

What about defining the components to be used as toasts on the provider? I really doubt you will want to use a different component every time you show a toast. At most I imagine you will want something like info, success, and error. Or if we want to make them dynamic it could be an object with keys as the toast type and the component as the value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest V0.1 release Will be included in V0.1 release
Projects
Public backlog
  
Backlog
Development

No branches or pull requests

2 participants