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
3.0.0 Button.js #632
3.0.0 Button.js #632
Conversation
@@ -35,28 +32,40 @@ const ButtonsPage = () => ( | |||
</ReactPlayground> | |||
</Col> | |||
<h4 className='col s12'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about an example of a Flat button, corresponding to the one in materializecss
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
docs/src/pages/Samples.js
Outdated
@@ -50,6 +50,7 @@ export default { | |||
sideNav: require('!raw-loader!../../../examples/SideNavBasic.js'), | |||
sliders: require('!raw-loader!../../../examples/Sliders.js'), | |||
submitButton: require('!raw-loader!../../../examples/SubmitButton.js'), | |||
smallButtom: require('!raw-loader!../../../examples/SmallButtom.js'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo in file name 😅
src/Button.js
Outdated
if ( | ||
typeof $ !== 'undefined' && | ||
(typeof tooltip !== 'undefined' || typeof tooltipOptions !== 'undefined') | ||
) { | ||
$(this._btnEl).tooltip(tooltipOptions); | ||
} | ||
if (fab && this._floatingActionBtn) { | ||
$(this._floatingActionBtn).floatingActionButton(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot use jQuery, you should do something like: M.FloatingActionButton.init(elems, options);
. Same goes for the use of jQuery right above on line 21.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also remember to destroy on componentDidUnmount
, on both destroy and re-initialize on componentDidUpdate
to make sure new props are used as options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alextrastero, what you think of it? componentDidUnmount actualy doesn't exist in react life cicle (at least a coudn't find it in the docs), but there is componentWillUnmount.
In that case, we would have something like:
- componentDidMount -> M.FloatingActionButton.init
- componentWillUnmount - > M.FloatingActionButton.destroy
In that situation, we will only have do save the instance returned in M.FloatingActionButton.init and then destroy it on componentWillUnmount.
Does it makes sense for you guys? Any tought about best ways to implement it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right, componentWillUnmount
is what I meant. The way you describe is exactly whas is done elsewhere.
Also remember componentDidUpdate
. In my PR I destroy, and re-initialize, don't think there is any other way to give the instance new options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start, you still need to remove any dependency on jQuery. Also you will need to test the new way of initializing and destroying the instance, see https://github.com/react-materialize/react-materialize/blob/3.0.0-beta.0/test/Collapsible.spec.js#L8-L44 for an example.
Thanks @petergarnaes for the review :) and thanks @onluiz for this massive change well done |
@alextrastero @petergarnaes , thanks for the feedbacks. I'll fix it all as soon as possible. I fixed the easy ones for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't commit the package-lock.js
file :)
examples/FixedActionButton.js
Outdated
@@ -2,7 +2,7 @@ import React from 'react'; | |||
import Button from '../src/Button'; | |||
|
|||
export default | |||
<Button floating fab='vertical' faicon='fa fa-plus' className='red' large style={{bottom: '45px', right: '24px'}}> | |||
<Button floating fab='vertical' faicon='fa fa-plus' className='red' large style={{bottom: '45px', right: '24px'}}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this faicon='fa fa-plus'
prop do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove it :)
@alextrastero, later I will fix Button.spec and add new tests. |
Nice work! However, you still need the Maybe we should split the Button and FloatingActionButton into two separate components? This mirrors the new Hope it makes sense 😅 |
@petergarnaes nice insights. I will try it out and shows you the results. EDIT: I will mimic the Floating Action Button from materializecss: https://materializecss.com/floating-action-button.html |
I will be closing this PR for now. When I have all the review requests done I will open it again. Thanks guys! |
Why close? |
src/Button.js
Outdated
if (!M) return; | ||
|
||
const { tooltip, tooltipOptions, fab } = this.props; | ||
if (tooltip || tooltipOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tooltipOptions
is defined but there is no actual tooltip
text should it still appear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed :)
Awesome! Is it possible to test the tooltip initialization also? |
@petergarnaes , yes! :) In Button.spec there is tests for tooltip (init and destroy) and for fab (init and destroy). =) |
Somehow missed it 😵 Great job! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @onluiz, nearly there, just a few comments:
Please merge the docs of buttons and FloatingActionButtonsPage
, I would rather keep the pages on the docs unified.
Did you delete package-lock? Seems like -10,106 changes is quite a lot :)
if (fab && this._floatingActionBtn) { | ||
this.instance = M.FloatingActionButton.init(this._floatingActionBtn); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to check for this._floatingActionBtn
on L23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -10,106 changes are actually from my commit that removes the package.lock. BUT, I may have done something wrong trying to remove the file. @alextrastero, could you help me on this? What is the proper way to remove the file? Sorry about the trouble.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem! You can checkout any file from any branch like so:
git checkout master package-lock.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omg it worked 😄
Now I will work on the others tasks:
- Remove check this._floatingActionBtn on L23
- Merge the docs of buttons and FloatingActionButtonsPage
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
@alextrastero
@onluiz ping |
@alextrastero , sorry. I have been dealing with health problems and couldn't finish my PRhe. Can I finish it in the next days? 😸 |
Of course buddy! no worries, get well! |
Nice! one last thing are we are done! checkout the modal snapshot from the beta branch since we are not changing that file on this PR :) |
@alextrastero all right! I'll sync my fork so a can let it all working. |
@alextrastero , really sorry for the delay =( I tried to revert the snapshot but the tests began to fail. I'll bring more details here about the problem. And again, sorry for the delay. |
what if you run |
@alextrastero think it worked =) |
This reverts commit 696f65e.
Great job @onluiz, thanks for the contribution. As as a next step would you like to to create a storybook story for the buttons? Have a look in here: https://github.com/react-materialize/react-materialize/tree/3.0.0-beta.0/stories |
@alextrastero I would love to! I am having such a great learning time here 😄 |
Description
It closes #583 (I hope 😄 )
This PR updates
Button
component to work with materializecss 1.0.0-rc.2. It includes:.btn-small
.btn-large
or.btn-small
you no longer need the.btn
classButton
component docs (used materializecss new Button docs page as example)string-helper
. It is used to captalize and add spaces to titles (for the navbar and header of the page). It was necessary since the Floating Action Component docs page had its title rendered as "FloatingActionPage" (in the header of the page and in the navbar)fab
prop is passed.btn-small
There is some items I would like the opinion from the others contributors:
@petergarnaes, sorry but could you review this PR again? I have created a new clean branch. And thanks for helping me.
Type of change
How Has This Been Tested?
Checklist: