-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
[Avatar] Migrate to emotion #24114
[Avatar] Migrate to emotion #24114
Conversation
@material-ui/core: parsed: +0.20% , gzip: +0.20% |
Thanks for taking the time to try this @oliviertassinari. I agree with all points.
At some point I needed this in a different component, it may not be true at this moment.. I guess after applying this change we won't even need it anymore diff --git a/packages/material-ui/src/Avatar/avatarClasses.js b/packages/material-ui/src/Avatar/avatarClasses.js
index 5ede5b894e..2c8a4549da 100644
--- a/packages/material-ui/src/Avatar/avatarClasses.js
+++ b/packages/material-ui/src/Avatar/avatarClasses.js
@@ -1,15 +1,13 @@
-export function getAvatarUtilityClass(name) {
- return `MuiAvatar-${name}`;
-}
+import generateUtilityClass from '@material-ui/unstyled/generateUtilityClass';
-const avatarClasses = {
- root: getAvatarUtilityClass('root'),
- colorDefault: getAvatarUtilityClass('colorDefault'),
- circular: getAvatarUtilityClass('circular'),
- rounded: getAvatarUtilityClass('rounded'),
- square: getAvatarUtilityClass('square'),
- img: getAvatarUtilityClass('img'),
- fallback: getAvatarUtilityClass('fallback'),
-};
+const avatarClasses = generateUtilityClass('MuiAvatar', [
+ 'root',
+ 'colorDefault',
+ 'circular',
+ 'rounded',
+ 'square',
+ 'img',
+ 'fallback',
+]);
export default avatarClasses; |
At least it means that after we have an agreed upon template the migration should go fast and would be pretty mechanical :) |
Actually, I have seen it used in Badge.js, but if we have a
Ok, In this case, I think that we could handle them in a follow-up effort.
Yeah, I could probably have moved faster if I had done more and had a better template. But the review phase will probably consume it. I didn't look into the unstyled part yet, but it seems to be important, at the very least, so developers can leverage the |
Agree, I think we can push first with the migration to emotion, and proceed with the |
It took me about 1 hour without knowing exactly what I was doing, I tried to copy the changes in #24107 😆 . We have about 150 components to migrate. So in theory, the migration effort could take about 1 month.
Proposals improvements, to solve pains I have faced during the effort:
This would have saved me some time to rename the props. I also think that it's easier to ready and more aligned with what we document.
I got confused about what was what.
.tsx
directly. So I think that we should:overridesResolver
? What about:Same question for no intermediate variable in
useAvatarClasses
.useAvatarClasses
a specific name? What about a generic one to make it easier to copy & paste?getAvatarUtilityClass
public?avatarClasses.js
to be less verbose. I believe that it's always the same. How about we have an array?This should also open the door to global customization of the class name generator.