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] Live demos v2 #34870
[docs] Live demos v2 #34870
Conversation
|
e596c7d
to
7dc58a2
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
eddedb2
to
a5be41f
Compare
a5be41f
to
f6c9327
Compare
This reverts commit 19df4df.
f6c9327
to
061d16f
Compare
27aa204
to
847e582
Compare
847e582
to
6e049cd
Compare
I did another iteration, I can't spot any opportunities for further improvement. Open for reviews/open to be improved on |
throw new Error( | ||
[ | ||
'A demo tries to access process.x in ReactRunner. This is not supported.', | ||
'If you do not need to show the source, you can set "hideToolbar": true to solve the issue.', |
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.
disableLiveEdit
?
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 think that hiding the toolbar is more relevant in this context. The developers should probably not be able to open it on codesandbox too if process
is accessed. disableLiveEdit
would work but would miss more improvement opportunities.
const sandboxProps = iframe ? { name, ...other } : {}; | ||
|
||
const t = useTranslate(); | ||
|
||
// `childrenProp` needs to be a child of `Sandbox` since the iframe implementation rely on `cloneElement`. | ||
const children = <Sandbox {...sandboxProps}>{childrenProp}</Sandbox>; | ||
|
||
return ( | ||
<DemoErrorBoundary name={name} onResetDemoClick={onResetDemoClick} t={t}> |
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.
Actually there is ErrorBoundary in react-runner
, I left it as it is for minimal change
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.
LGTM!
|
A few more opportunities for improvements that we saw:
It seems that we are pretty much done :). I will take care of 7. 8 is more of the realm of react-simple-code-editor. |
This is a continuation of #34454 (comment). The first commit is from the initial PR, the second commit is what I could make as a step forwards. I have tried to fix all the bugs but I'm stuck on point 6. I might not have the time to carry it further.
Performance-wise, it seems that these changes reduce the regression: https://www.webpagetest.org/video/compare.php?tests=221106_BiDcE6_7GV,221106_AiDcGG_7EA,221106_BiDcTA_7GW
Problem solved
@nihgwu For 6. we need to pass a prop/argument to the code that is executed. This demo https://mui.com/material-ui/react-drawer/#swipeable-edge runs inside an iframe, we normally pass it the
window
of the iframe as an argument for the demo:material-ui/docs/data/material/components/drawers/SwipeableEdgeDrawer.tsx
Lines 42 to 43 in 639224a
I have tried this:
material-ui/docs/src/modules/components/ReactRunner.tsx
Lines 42 to 54 in 36ce47e
but there is an intermediary element in react runner that prevents cloneElement to forward the
window
. What would you advise? The only alternative I can think of is to create a new demo option to disable live edits for some of the demos (it's already done by default whenhideToolbar
is used).