shivansh-bhatnagar18 / multiplayer-uno

https://multiplayer-uno.vercel.app
21 stars 43 forks source link

Improve the structure of the modal #116

Closed kuv2707 closed 2 weeks ago

kuv2707 commented 3 weeks ago

Description

The modal component in library directory was supposed to be as reusable as possible, but ended up catering to a particular use case. In other places where modals were needed, we made duplicate modals tailored to that use case only. All these modals have some common features which can be extracted into one actually reusable and configurable modal component.

Lets start with these for now. We should have a ModalContainer library component which accepts the following as props:

We should have a context for the modal in the same way we have for toasts.

We should be able to use it like this:

function HomePage(){
const modal = useModal(<div>Hi there</div>,[<Button/>]);
return <div onClick={()=>modal.show()}></div>
}

Any action (click etc) on the buttons passed to the modal will close the modal.

Notes

issue-assigner[bot] commented 3 weeks ago

Comment '@csoc-bot claim' to get this issue assigned or '@csoc-bot abandon' to get this issue unassigned.

ritwik-69 commented 3 weeks ago

@csoc-bot claim

issue-assigner[bot] commented 3 weeks ago

@ritwik-69 This issue has been successfully assigned to you! 🚀

realnilesh commented 3 weeks ago

@csoc-bot claim

issue-assigner[bot] commented 3 weeks ago

@realnilesh Sorry, maximum limit for assignees in this issue has reached. Please check other issues or contact a maintainer.