NehemiahK / fun-react-lib

A fun React Library for practice
https://nehemiahk.github.io/fun-react-lib/
61 stars 24 forks source link

added Modal component, demo, and docs #47

Open rosensteinsamuel1 opened 4 years ago

rosensteinsamuel1 commented 4 years ago

I added the Modal component along with the corresponding demo and docs.

NehemiahK commented 4 years ago

Hey, this is neat. Any reason to use refs in this situation? I had initially thought users could just pass in their own open/close function but that would be outside the modal. what do you think?

rosensteinsamuel1 commented 4 years ago

Good idea, I'm going to try a different approach and I'll keep you updated.

rosensteinsamuel1 commented 4 years ago

After thinking about this for a bit I think the best thing is to have defined open/close functionality. If the user wants to run custom functions then we can have props for functions that will execute when the modal is opened/closed. Also, the ref is in order to allow for the modal to close when the background is clicked. If this isn't necessary, I can remove the ref and just have the close functionality via an 'x' button in the corner of the modal.

rosensteinsamuel1 commented 4 years ago

Here is the new version. There aren't any refs. In order to open, set isOpen=true and then the modal closes when the 'close' button is clicked inside of the modal.

rosensteinsamuel1 commented 4 years ago

@NehemiahK Where are we with this?