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

[docs] Fix CodeSandbox & StackBlitz generation #32726

Merged
merged 15 commits into from
May 23, 2022

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented May 11, 2022

Preview: https://deploy-preview-32726--material-ui.netlify.app/material-ui/react-button/#basic-button

Issues

  • [BUG] StackBlitz does not work on the production. Also, the demo.tsx does not show on the editor. Proof: https://mui.com/material-ui/react-button/ This bug is gone in v5.8.0 because we have moved the private classnames to mui-utils
    Screen Shot 2565-05-11 at 12 59 51
  • The templates generated is not compatible with Joy UI
     // index.js
     import * as React from 'react';
     import ReactDOM from 'react-dom/client';
     import { StyledEngineProvider } from '@mui/material/styles';
     import Demo from './demo';
     
     ReactDOM.createRoot(document.querySelector("#root")).render(
       <StyledEngineProvider injectFirst> // Joy needs CssVarsProvider instead
         <Demo />
       </StyledEngineProvider>
     );
  • The code is not extensible. (We need to be able to configure the template based on the product)

Refactoring

Here is how it worked before:

image

There is only 1 function, the getDemoConfig() which call other functions and so on. If we want to adjust the dependencies, we have to pass the props from the top down to the bottom. This is quite hard to adapt and write tests.

Here is the refactored version:

image

  • The sandbox modules split into CodeSandbox and StackBlitz to provide flexibility and composition of other APIs. Both of them contain the method createReactApp that use the CreateReactApp module to generate templates between products.

    In the future, if we want to generate NextJS template, this will be very easy.

  • The dependencies module handles the extraction from the file and assign version based on the config.

Fix

  • StackBlitz bug is fixed.
  • Joy UI is working on both CodeSandbox & StackBlitz.
  • MUI Base is working on both CodeSandbox & StackBlitz

@siriwatknp siriwatknp added the docs Improvements or additions to the documentation label May 11, 2022
@mui-bot
Copy link

mui-bot commented May 11, 2022

Details of bundle changes

Generated by 🚫 dangerJS against cb3d6ce

docs/src/modules/sandbox/CreateReactApp.ts Outdated Show resolved Hide resolved
docs/src/modules/sandbox/StackBlitz.ts Outdated Show resolved Hide resolved
docs/src/modules/sandbox/Dependencies.ts Outdated Show resolved Hide resolved
docs/src/modules/sandbox/Dependencies.ts Outdated Show resolved Hide resolved
docs/src/modules/components/Demo.js Outdated Show resolved Hide resolved
docs/src/modules/components/Demo.js Outdated Show resolved Hide resolved
docs/src/modules/components/DemoToolbar.js Outdated Show resolved Hide resolved
docs/src/modules/sandbox/CodeSandbox.test.js Outdated Show resolved Hide resolved
docs/src/modules/sandbox/CodeSandbox.test.js Outdated Show resolved Hide resolved
docs/src/modules/sandbox/StackBlitz.ts Show resolved Hide resolved
docs/src/modules/sandbox/StackBlitz.ts Outdated Show resolved Hide resolved
@oliviertassinari oliviertassinari mentioned this pull request May 15, 2022
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 17, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 20, 2022
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Overall looks good, I've left few comments. Let's also address Olivier's feedback.

@siriwatknp
Copy link
Member Author

Overall looks good, I've left few comments. Let's also address Olivier's feedback.

All fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants