-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Snackbar] Remove
RTL
direction specific logic (#32808)
- Loading branch information
1 parent
57d68d9
commit 96f5a72
Showing
3 changed files
with
73 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import Snackbar from '@mui/material/Snackbar'; | ||
|
||
export default function PositionedSnackbar() { | ||
return ( | ||
<Box dir="ltr" sx={{ width: window?.innerWidth, height: '100vh' }}> | ||
<Snackbar | ||
key="left" | ||
anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }} | ||
message="Snackbar should show left (LTR)" | ||
open | ||
/> | ||
<Snackbar | ||
key="right" | ||
anchorOrigin={{ horizontal: 'right', vertical: 'top' }} | ||
message="Snackbar should show right (LTR)" | ||
open | ||
/> | ||
</Box> | ||
); | ||
} |
43 changes: 43 additions & 0 deletions
43
test/regressions/fixtures/Snackbar/PositionedSnackbarRtl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import { prefixer } from 'stylis'; | ||
import rtlPlugin from 'stylis-plugin-rtl'; | ||
import rtlPluginSc from 'stylis-plugin-rtl-sc'; | ||
import { StyleSheetManager } from 'styled-components'; | ||
import { CacheProvider } from '@emotion/react'; | ||
import { createTheme, ThemeProvider } from '@mui/material/styles'; | ||
import createCache from '@emotion/cache'; | ||
import Snackbar from '@mui/material/Snackbar'; | ||
|
||
// Create rtl cache | ||
const cacheRtl = createCache({ | ||
key: 'muirtl', | ||
stylisPlugins: [prefixer, rtlPlugin], | ||
}); | ||
|
||
const theme = createTheme({ direction: 'rtl' }); | ||
|
||
export default function PositionedSnackbar() { | ||
return ( | ||
<StyleSheetManager stylisPlugins={[rtlPluginSc]}> | ||
<CacheProvider value={cacheRtl}> | ||
<ThemeProvider theme={theme}> | ||
<Box dir="rtl" sx={{ width: window?.innerWidth, height: '100vh' }}> | ||
<Snackbar | ||
key="left" | ||
anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }} | ||
message="Snackbar should show right (RTL)" | ||
open | ||
/> | ||
<Snackbar | ||
key="right" | ||
anchorOrigin={{ horizontal: 'right', vertical: 'top' }} | ||
message="Snackbar should show left (RTL)" | ||
open | ||
/> | ||
</Box> | ||
</ThemeProvider> | ||
</CacheProvider> | ||
</StyleSheetManager> | ||
); | ||
} |