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 rtl issue on the demos #27865

Merged
merged 2 commits into from Aug 20, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/src/modules/components/DemoSandboxed.js
Expand Up @@ -12,6 +12,7 @@ import { useTheme, styled, createTheme, ThemeProvider } from '@material-ui/core/
import rtl from 'jss-rtl';
import DemoErrorBoundary from 'docs/src/modules/components/DemoErrorBoundary';
import { useTranslate } from 'docs/src/modules/utils/i18n';
import darkScrollbar from '@material-ui/core/darkScrollbar';
mnajdova marked this conversation as resolved.
Show resolved Hide resolved

function FramedDemo(props) {
const { children, document } = props;
Expand Down Expand Up @@ -121,6 +122,12 @@ DemoFrame.propTypes = {
const theme = createTheme();
const darkModeTheme = createTheme({ palette: { mode: 'dark' } });

const getTheme = (outerTheme) => {
const resultTheme = outerTheme?.palette?.mode === 'dark' ? darkModeTheme : theme;
resultTheme.direction = outerTheme?.direction;
return resultTheme;
};

/**
* Isolates the demo component as best as possible. Additional props are spread
* to an `iframe` if `iframe={true}`.
Expand All @@ -135,9 +142,7 @@ function DemoSandboxed(props) {
return (
<DemoErrorBoundary name={name} onResetDemoClick={onResetDemoClick} t={t}>
<Sandbox {...sandboxProps}>
<ThemeProvider
theme={(outerTheme) => (outerTheme?.palette?.mode === 'dark' ? darkModeTheme : theme)}
>
<ThemeProvider theme={(outerTheme) => getTheme(outerTheme)}>
<Component />
</ThemeProvider>
</Sandbox>
Expand Down