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] Use defaultCodeOpen where appropriate #25418

Merged
merged 3 commits into from
Mar 22, 2021

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Mar 19, 2021

We don't need to duplicate code since we have defaultCodeOpen which solves the same problem. Inline the demo source manually is only required for demos that span multiple files.

Preview: https://deploy-preview-25418--material-ui.netlify.app/guides/interoperability/#the-css-prop

Based off of from #25416

@mui-pr-bot
Copy link

mui-pr-bot commented Mar 19, 2021

No bundle size changes

Generated by 🚫 dangerJS against d5495f5

Comment on lines -592 to -618
{{"demo": "pages/guides/interoperability/EmotionCSS.js", "hideToolbar": true}}

[![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/emotion-interoperability-idymy)

```jsx
/** @jsx jsx */
import { jsx, css } from '@emotion/react';
import Slider from '@material-ui/core/Slider';

export default function EmotionCSS() {
return (
<div>
<Slider defaultValue={30} />
<Slider
defaultValue={30}
css={css`
color: #20b2aa;

:hover {
color: #2e8b57;
}
`}
/>
</div>
);
}
```
Copy link
Member

@oliviertassinari oliviertassinari Mar 19, 2021

Choose a reason for hiding this comment

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

I'm commenting as it seems to be the intended objective of the draft PR.

Mainly interested why we had a separate codesandbox for this demo.

I would ask the same question. Why remove the codesandbox and the inlined JSX? These demos are meant to show that it works in isolation. I don't think that it matters that it works in our dev environment. I would even argue that it defeats the objective. We have used codesandbox and "hideToolbar": true as much as possible. "as much as possible", meaning up to a point where the maintenance pain of the sync of the codesandbox is acceptable.

@material-ui/styled-engine is meant to hide most of the underlying engine. It helps to switch to a different engine in the future if needed, and to provide extra features. We document emotion because developers might want to use it raw.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have used codesandbox and "hideToolbar": true as much as possible.

Why would we use it as much as possible?

Why remove the codesandbox and the inlined JSX?

Because we have existing code that does it for us.

Copy link
Member

@oliviertassinari oliviertassinari Mar 20, 2021

Choose a reason for hiding this comment

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

Why would we use it as much as possible?

The problem is:

  1. have these demos isolated (probably what's more important, to avoid depending on specifics of the documentation)
  2. not complexify the webpack config of the documentation for one-off use cases (e.g. CSS modules)

The solution was to:

Move them outside of the documentation. However, it comes with a maintenance cost. I believe we have both use a live demo (with different customization, only demonstrating the final output, with hidden sources), as well as showing the source for the most advanced portal to mitigate the cost.

Is it possible to improve the previous solution? Yeah, likely

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I definitely agree with the multi-file demos. But for single file demos that work just fine in our demo setup I don't see why we wouldn't use it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, agree, especially if the edit to codesandbox button in the toolbar works as-is.

@eps1lon eps1lon changed the title [docs] Use jsxImportSource instead of jsx directive [docs] Use defaultCodeOpen where appropriate Mar 20, 2021
@eps1lon eps1lon added the docs Improvements or additions to the documentation label Mar 20, 2021
@eps1lon eps1lon marked this pull request as ready for review March 20, 2021 13:22
@eps1lon eps1lon merged commit d9f219a into mui:next Mar 22, 2021
@eps1lon eps1lon deleted the docs/jsxImportSource branch March 22, 2021 09:01
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.

3 participants