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

feat(Dialog): use MDC Foundation with Dialogs #177

Closed
wants to merge 2 commits into from

Conversation

aeon0
Copy link

@aeon0 aeon0 commented Mar 30, 2018

To get used to new "foundation way" I tried to convert the Dialog component. I am not sure if a missed some (or a lot).
If I missed too much it's not a problem if we close the PR and you do the conversion which might be faster in that case! At worst it was a good exercise for me ; )

@aeon0 aeon0 requested a review from jamesmfriedman March 30, 2018 20:23
@jamesmfriedman
Copy link
Collaborator

Thanks for this! I’ll take a look tonight.

Copy link
Collaborator

@jamesmfriedman jamesmfriedman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead I using componentWillRecieveProps, checkout how I’ve been using syncWithProps on the Slider and IconToggle.

Just looking on my phone at the moment so I can’t validate but this is the general gist of it.

This creates a react component Class that is quite literally merged with the vanilla js class from mdc so any and all functionality that exists on it is inherited. The trick is to see what the vanilla js class is already doing and work with it or around it.

@aeon0
Copy link
Author

aeon0 commented Mar 31, 2018

Changed it to syncWithProps.

Some other issues I am having:

  1. How do I add custom events? With the current code changes, the onClose is not working anymore since close it is not a native MDC event such as accept and cancel. But I think it is important we add the event for backwards compatibility and convince.

  2. On componentDidMount() I have to copy the code that is being used in the initialize() method of the vanilla js class. Doesn't seem nice to me, as you mentioned we only want to work around the vanilla implementation if we need to. But I couldn't figure out how to access the initialize method...

@jamesmfriedman
Copy link
Collaborator

@j-o-d-o Check out MDC 34 branch and #179. I just implemented the Select component with foundation. A few relevant things that I came across:

  • I wasn't calling the "initialize" method from Foundation before. I've added that back, so you shouldn't have to replicate the initialize method.
  • syncWithProps is really just a React sensible replacement for initialSyncWithDom. Basically, we need to do the same kind of things initialSyncWithDom does, but base it off of our props. It's not exactly the same as their method, but looking at theirs is a good place to start. Theirs never actually gets called in RMWC.
  • Basically, you have to look through the vanilla JS implementation, and do the minimal number of modifications to the adapter or built in methods to get the result you want.

@aeon0
Copy link
Author

aeon0 commented Apr 5, 2018

Alright, sounds and looks good. I will merge this branch into the mdc34.

I am still not 100% sure how to add custom RMWC events that are not included in the MDC adapter, but I will fiddle around some tonight.

@jamesmfriedman
Copy link
Collaborator

@j-o-d-o sorry, not trying to steal your thunder but I thought being able to show you how close you were would help. See this commit 3a072b2.

Granted, things are still a bit in flux, I added a tad bit of functionality to the MDCFoundation class for this, but you get the gist. Controlling updating props (in this case the open prop), and patching the foundation adapters that need to be changed. Here I just grabbed the two event methods, duplicated them and added the onClose handler in there.

@jamesmfriedman
Copy link
Collaborator

Also, thank you so much for answering peoples questions on issues! It's a massive help.

@aeon0
Copy link
Author

aeon0 commented Apr 5, 2018

Ah okay, no worries ;) Implementation looks good and makes sense.

Always glad to help!

@aeon0 aeon0 closed this Apr 5, 2018
@aeon0 aeon0 deleted the feat/dialog-foundation branch April 5, 2018 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants