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

[Fab] Extract from Button as new component #13573

Merged
merged 11 commits into from
Nov 14, 2018
Merged

[Fab] Extract from Button as new component #13573

merged 11 commits into from
Nov 14, 2018

Conversation

mbrookes
Copy link
Member

@mbrookes mbrookes commented Nov 11, 2018

The floating action button doesn't share many styles with the default button component.
We are extracting the variant into its own component. This way, we better isolate the concerns.
It's making the Button implementation more lightweight, a win for people overriding our styles.

Upgrade path

-import Button from '@material-ui/core/Button';
+import Fab from '@material-ui/core/Fab';

-<Button variant="fab" color="primary">
+<Fab color="primary">
  <AddIcon />
-</Button>
+</Fab>

@mbrookes mbrookes added the component: Fab The React component. label Nov 11, 2018
// assert.strictEqual(wrapper.hasClass(classes.flat), false);
// assert.strictEqual(wrapper.hasClass(classes.textPrimary), false);
// assert.strictEqual(wrapper.hasClass(classes.textSecondary), false);
// });
Copy link
Member Author

@mbrookes mbrookes Nov 11, 2018

Choose a reason for hiding this comment

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

@eps1lon Is there a way to prevent the warning from causing these test to fail?

Copy link
Member

Choose a reason for hiding this comment

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

I know it's probably not the perfect fix but if you use consoleErrorMock you can intercept the warning which will prevent the warning and even write tests for them :)

Copy link
Member Author

@mbrookes mbrookes Nov 11, 2018

Choose a reason for hiding this comment

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

Ah, right, @eps1lon had done that for the other legacy variant test. Thanks!

@oliviertassinari oliviertassinari self-assigned this Nov 12, 2018
@mbrookes mbrookes changed the title [FAB] Extract from Button as new component [Fab] Extract from Button as new component Nov 13, 2018
@eps1lon
Copy link
Member

eps1lon commented Nov 13, 2018

@mbrookes Just in case you're wondering about codecov failure: Codecov will do that if HEAD points to a merge commit. An empty commit should do the trick.

@mbrookes
Copy link
Member Author

@eps1lon Thanks, good to know. I usually fix merge conflicts locally, but as it was a quick one, thought I'd use github. No time saved after all!

@oliviertassinari oliviertassinari added the new feature New feature or request label Nov 14, 2018
@oliviertassinari oliviertassinari merged commit 226a3cb into mui:master Nov 14, 2018
@oliviertassinari
Copy link
Member

@mbrookes I have done some minor changes, great work! This change makes me happy 💯. I can't wait v4 to remove all the deprecated code.

@oliviertassinari oliviertassinari added the deprecation New deprecation message label Nov 15, 2018
@wyqydsyq
Copy link

wyqydsyq commented Nov 27, 2018

I am currently using @material-ui/core @ 3.6.0, I get the following warning about the fab variant being deprecated:

Warning: Failed prop type: The `fab` variant will be removed in the next major release. The `<Fab>` component is equivalent and should be used instead.

But then trying to follow those instructions, TSC yells at me because there are no TS definitions for Fab:
image

It seems the index re-exporter has been updated to include Fab, but the TypeScript definitions need to be rebuilt and published to account for this change. Unsure if this is big enough to warrant it's own issue (I imagine it would be done automatically as part of a future release anyway) so I've just commented here.

@oliviertassinari
Copy link
Member

@wyqydsyq Sorry about that. We have forgotten the TypeScript defintions in this pull request! It's important, we will take care of it. If you have some time, feel free to give it a go.

@mbrookes
Copy link
Member Author

We have forgotten the TypeScript defintions in this pull request!

We haven't:

https://github.com/mui-org/material-ui/pull/13573/files#diff-6656a4772d50c2237902506187b79972

Fab just need to be added to packages/material-ui/src/index.d.ts (No idea why TS insists on its own index file, but there you go...)

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 27, 2018

@wyqydsyq Do you want to add the missing import in the index.d.ts and overrides.d.ts?

@mbrookes mbrookes deleted the fab-new-component branch November 27, 2018 16:34
@wyqydsyq
Copy link

I would have submitted a PR but I have no idea about how TS is being used in this project, are these definitions being maintained by hand or generated by tsc?

@oliviertassinari
Copy link
Member

It's done by hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Fab The React component. deprecation New deprecation message new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants