-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Add CodeSandbox/Stackblitz to the rest of the templates (#43708)
- Loading branch information
1 parent
a7b7d9c
commit 91d0d91
Showing
177 changed files
with
1,070 additions
and
17,878 deletions.
There are no files selected for viewing
69 changes: 15 additions & 54 deletions
69
docs/data/material/getting-started/templates/blog/Blog.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 |
---|---|---|
@@ -1,65 +1,26 @@ | ||
import * as React from 'react'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import Container from '@mui/material/Container'; | ||
import { createTheme, ThemeProvider } from '@mui/material/styles'; | ||
import AppAppBar from './components/AppAppBar'; | ||
import MainContent from './components/MainContent'; | ||
import Latest from './components/Latest'; | ||
import Footer from './components/Footer'; | ||
import TemplateFrame from './TemplateFrame'; | ||
|
||
import getBlogTheme from './theme/getBlogTheme'; | ||
|
||
export default function Blog() { | ||
const [mode, setMode] = React.useState('light'); | ||
const [showCustomTheme, setShowCustomTheme] = React.useState(true); | ||
const blogTheme = createTheme(getBlogTheme(mode)); | ||
const defaultTheme = createTheme({ palette: { mode } }); | ||
// This code only runs on the client side, to determine the system color preference | ||
React.useEffect(() => { | ||
// Check if there is a preferred mode in localStorage | ||
const savedMode = localStorage.getItem('themeMode'); | ||
if (savedMode) { | ||
setMode(savedMode); | ||
} else { | ||
// If no preference is found, it uses system preference | ||
const systemPrefersDark = window.matchMedia( | ||
'(prefers-color-scheme: dark)', | ||
).matches; | ||
setMode(systemPrefersDark ? 'dark' : 'light'); | ||
} | ||
}, []); | ||
|
||
const toggleColorMode = () => { | ||
const newMode = mode === 'dark' ? 'light' : 'dark'; | ||
setMode(newMode); | ||
localStorage.setItem('themeMode', newMode); // Save the selected mode to localStorage | ||
}; | ||
|
||
const toggleCustomTheme = () => { | ||
setShowCustomTheme((prev) => !prev); | ||
}; | ||
import AppTheme from '../shared-theme/AppTheme'; | ||
|
||
export default function Blog(props) { | ||
return ( | ||
<TemplateFrame | ||
toggleCustomTheme={toggleCustomTheme} | ||
showCustomTheme={showCustomTheme} | ||
mode={mode} | ||
toggleColorMode={toggleColorMode} | ||
> | ||
<ThemeProvider theme={showCustomTheme ? blogTheme : defaultTheme}> | ||
<CssBaseline enableColorScheme /> | ||
<AppAppBar /> | ||
<Container | ||
maxWidth="lg" | ||
component="main" | ||
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }} | ||
> | ||
<MainContent /> | ||
<Latest /> | ||
</Container> | ||
<Footer /> | ||
</ThemeProvider> | ||
</TemplateFrame> | ||
<AppTheme {...props}> | ||
<CssBaseline enableColorScheme /> | ||
<AppAppBar /> | ||
<Container | ||
maxWidth="lg" | ||
component="main" | ||
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }} | ||
> | ||
<MainContent /> | ||
<Latest /> | ||
</Container> | ||
<Footer /> | ||
</AppTheme> | ||
); | ||
} |
69 changes: 15 additions & 54 deletions
69
docs/data/material/getting-started/templates/blog/Blog.tsx
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 |
---|---|---|
@@ -1,66 +1,27 @@ | ||
import * as React from 'react'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import Container from '@mui/material/Container'; | ||
import { createTheme, ThemeProvider, PaletteMode } from '@mui/material/styles'; | ||
import AppAppBar from './components/AppAppBar'; | ||
import MainContent from './components/MainContent'; | ||
import Latest from './components/Latest'; | ||
import Footer from './components/Footer'; | ||
import TemplateFrame from './TemplateFrame'; | ||
|
||
import getBlogTheme from './theme/getBlogTheme'; | ||
|
||
export default function Blog() { | ||
const [mode, setMode] = React.useState<PaletteMode>('light'); | ||
const [showCustomTheme, setShowCustomTheme] = React.useState(true); | ||
const blogTheme = createTheme(getBlogTheme(mode)); | ||
const defaultTheme = createTheme({ palette: { mode } }); | ||
// This code only runs on the client side, to determine the system color preference | ||
React.useEffect(() => { | ||
// Check if there is a preferred mode in localStorage | ||
const savedMode = localStorage.getItem('themeMode') as PaletteMode | null; | ||
if (savedMode) { | ||
setMode(savedMode); | ||
} else { | ||
// If no preference is found, it uses system preference | ||
const systemPrefersDark = window.matchMedia( | ||
'(prefers-color-scheme: dark)', | ||
).matches; | ||
setMode(systemPrefersDark ? 'dark' : 'light'); | ||
} | ||
}, []); | ||
|
||
const toggleColorMode = () => { | ||
const newMode = mode === 'dark' ? 'light' : 'dark'; | ||
setMode(newMode); | ||
localStorage.setItem('themeMode', newMode); // Save the selected mode to localStorage | ||
}; | ||
|
||
const toggleCustomTheme = () => { | ||
setShowCustomTheme((prev) => !prev); | ||
}; | ||
import AppTheme from '../shared-theme/AppTheme'; | ||
|
||
export default function Blog(props: { disableCustomTheme?: boolean }) { | ||
return ( | ||
<TemplateFrame | ||
toggleCustomTheme={toggleCustomTheme} | ||
showCustomTheme={showCustomTheme} | ||
mode={mode} | ||
toggleColorMode={toggleColorMode} | ||
> | ||
<ThemeProvider theme={showCustomTheme ? blogTheme : defaultTheme}> | ||
<CssBaseline enableColorScheme /> | ||
<AppTheme {...props}> | ||
<CssBaseline enableColorScheme /> | ||
|
||
<AppAppBar /> | ||
<Container | ||
maxWidth="lg" | ||
component="main" | ||
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }} | ||
> | ||
<MainContent /> | ||
<Latest /> | ||
</Container> | ||
<Footer /> | ||
</ThemeProvider> | ||
</TemplateFrame> | ||
<AppAppBar /> | ||
<Container | ||
maxWidth="lg" | ||
component="main" | ||
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }} | ||
> | ||
<MainContent /> | ||
<Latest /> | ||
</Container> | ||
<Footer /> | ||
</AppTheme> | ||
); | ||
} |
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
113 changes: 0 additions & 113 deletions
113
docs/data/material/getting-started/templates/blog/TemplateFrame.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.