-
-
Notifications
You must be signed in to change notification settings - Fork 805
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
[legacy-framework] Add material-ui
recipe
#840
Conversation
Thank you @drenther! I haven't tested this, but initially it looks good. Do you have more work to do on it? If not, you can mark is as "Ready for review" |
Hey @flybayer, I initially started the implementation naively assuming it will work as it is used in a client side only app. On testing it didn't. So now making changes according to this example that works for next.js - https://github.com/mui-org/material-ui/tree/17b9a90bf8488d1a96fbb2f6528eb0c30308ce2e/examples/nextjs I have committed the changes for customizing |
Hey @drenther! I tried to manually add Material-UI to a blitz app following the nextjs example like you did in this recipe. The problem is that Material-UI does not yet support strict mode. I ran into issues when I tried to use components that use dynamic styling like If there is a workaround (I didn't find any for now), maybe it should be included in this recipe. If not, we could add it to the documentation to warn the users. |
@gabrielcolson Thanks. I followed the trail of the material-ui examples PR when writing this PR. I am trying to add a workaround for it and reasoning for it in the comments. Also, let the user know during installing of recipe that this path is currently React.Strict incompatible. |
Since it's not strict mode compatible, that means you need to add this to module.exports = {
experimental: {
reactMode: "legacy"
}
} Also, each time you use const [stuff, {isLoading, isSuccess, error}] = useQuery(getStuff, {id: 1}, {suspense:false}) |
The suspense bit will need to be mentioned in the docs and when installing the recipe? |
I think just in the recipe installation. Perhaps we could create a github discussion thread on material UI and link to it as a place for workarounds and help. |
Forcing the removal of React Suspense by default in the recipe seems overkill as it only affects the Maybe it would be sufficient to only warn the users about it and point them to this issue. |
@gabrielcolson That's a good point. By dynamic styling do you mean customizing the theme passed to the |
From what I understand it is only when passing parameters to the hook generated by |
Looks like it would be better if we skipped the legacy mode bit and added a warning note in the recipe installer notifying the user about strict mode incompatibility when using Box and/or dynamic styling features as you mentioned. @flybayer what's the call here? |
Pushed all the changes required to get the recipe running. Tested it out and seems to work fine with Box component and all as well (since the legacy mode switch is currently on). Let me know if need to roll that back. Opening for review now. |
Oh, good to know that you only need legacy mode for those certain cases. I was under the impression it was needed for everything. In this case, let's remove legacy mode from the recipe and instead add a warning about those cases. Thanks everyone! |
|
||
let isReactImported = false | ||
|
||
visit(ast, { |
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'm gonna update the addImport
function we currently expose to take just a module name and a ImportSpecifier | ImportDefaultSpecifier
so we can hide all of this logic away. It's fine to merge this as-is if we want, but otherwise we can remove a lot of this boilerplate
b.tsTypeReference(b.identifier("DocumentContext")), | ||
) | ||
|
||
const getInitialPropsBody = b.blockStatement([ |
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.
this is another thing that my refactor branch helps with - we'll be able to pass in a template string with valid TS in it, and the output will be the right AST nodes. might be worth waiting for that change to land
@aem The refactor branch sounds good. Will reduce a lot of boilerplate and make this recipe code easier to reason with. @flybayer @gabrielcolson I have removed the legacy mode transform in the blitz.config.js file and added an extensive (may be too big, may need some help trimming it down and making it more digestable.) Let me know if anything needs to done on this. |
Awesome, thank you @drenther!! @all-contributors add @drenther for code |
I've put up a pull request to add @drenther! 🎉 |
material-ui
recipematerial-ui
recipe
Closes: None
What are the changes and their implications?
Adds a recipe for the Material-UI. Most of the code is similar to the chakra-ui recipe with the only exception being an empty initial theme object variable declaration similar to what is in the material-ui docs ThemeProvider example. That can be used to extend the theme as the user sees fit in the future.
Note:
The TODOs and improvements suggested in the chakra ui recipe like this haven't made it into the installer so that bit is still copy-pasted (can by cleaned up in a future PR post the changes?) -
Checklist