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] Add CodeSandbox/Stackblitz to the rest of the templates #43708

Merged
merged 41 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6a69cf5
update checkout template
siriwatknp Sep 11, 2024
273cb02
update marketing page
siriwatknp Sep 11, 2024
9a709c2
update sign-in-side template
siriwatknp Sep 11, 2024
43b36e7
update sign-up
siriwatknp Sep 11, 2024
4c28a7f
update blog
siriwatknp Sep 11, 2024
29907fa
use CSS theme variables
siriwatknp Sep 11, 2024
0b1cf8f
fix all issues
siriwatknp Sep 12, 2024
e33ef1d
update screenshots
siriwatknp Sep 12, 2024
e710571
Merge branch 'master' of https://github.com/mui/material-ui into temp…
siriwatknp Sep 12, 2024
790fcc2
fallback to theme
siriwatknp Sep 12, 2024
5935047
fix grid xs
siriwatknp Sep 13, 2024
22b0be0
Merge branch 'master' of https://github.com/mui/material-ui into temp…
siriwatknp Sep 13, 2024
53dc463
Merge branch 'master' of https://github.com/mui/material-ui into temp…
siriwatknp Sep 16, 2024
71951a1
update readme
siriwatknp Sep 16, 2024
c7956f4
remove updateTemplatesTheme script
siriwatknp Sep 16, 2024
a7753c3
Merge branch 'master' of https://github.com/mui/material-ui into temp…
siriwatknp Sep 20, 2024
b228a99
run pnpm dedupe
siriwatknp Sep 20, 2024
bc9e2c2
run pnpm dedupe
siriwatknp Sep 20, 2024
5b6e056
Merge branch 'master' of https://github.com/mui/material-ui into temp…
siriwatknp Sep 26, 2024
d86c497
update theme selector
siriwatknp Sep 26, 2024
61813d9
move size to formcontrol
siriwatknp Sep 27, 2024
4721573
Standardize close button in Drawer
zanivan Oct 8, 2024
77b5d1a
Fix Checkout template Drawer background
zanivan Oct 8, 2024
6e41285
Fix Checkout template padding
zanivan Oct 8, 2024
a23c3c2
Fix Dialog background
zanivan Oct 8, 2024
1083b23
Fix Dashboard Drawer
zanivan Oct 8, 2024
ad5a8b7
Run docs:typescript:formatted
zanivan Oct 8, 2024
4ad31e4
Standardize close button in Blog's Drawer
zanivan Oct 8, 2024
0e3df7f
Merge branch 'master' of https://github.com/mui/material-ui into temp…
siriwatknp Oct 10, 2024
184e750
add ColorModeIconDropdown to mobile viewport
siriwatknp Oct 10, 2024
285e66c
run docs:ts
siriwatknp Oct 10, 2024
c1865d6
improve sign in-* templates
siriwatknp Oct 10, 2024
c2f5e54
run dedupe
siriwatknp Oct 10, 2024
88a6a6e
Merge remote-tracking branch 'upstream/master' into pr/43708
zanivan Oct 10, 2024
170a9c9
Merge branch 'template/new-structure' of https://github.com/siriwatkn…
zanivan Oct 10, 2024
04a0b60
Merge branch 'master' of https://github.com/mui/material-ui into temp…
siriwatknp Oct 14, 2024
883e35a
revert
siriwatknp Oct 14, 2024
5cc855c
hide select root
siriwatknp Oct 14, 2024
97d344c
add TEMPLATE_IMAGE_URL to images in the templates
siriwatknp Oct 14, 2024
55d7dc4
docs ts format
siriwatknp Oct 14, 2024
d75ead4
fallback to mui.com
siriwatknp Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 15 additions & 54 deletions docs/data/material/getting-started/templates/blog/Blog.js
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 docs/data/material/getting-started/templates/blog/Blog.tsx
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>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!-- #default-branch-switch -->

1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
1. Copy these folders (`blog` and `shared-theme`) into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
Copy link
Member

Choose a reason for hiding this comment

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

Off-topic

We could provide a CLI script that does this. Related to #39588

Copy link
Contributor

Choose a reason for hiding this comment

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

I really dig this! I created a shaping page kind of related to this https://www.notion.so/mui-org/material-ui-Installation-CLI-e32438c1880c466c8b7075d289e825c4 I think it'd be really nice to have the templates as starting point for new projects.

2. Make sure your project has the required dependencies: @mui/material, @mui/icons-material, @emotion/styled, @emotion/react, markdown-to-jsx.
3. Import and use the `Blog` component.

Expand Down
113 changes: 0 additions & 113 deletions docs/data/material/getting-started/templates/blog/TemplateFrame.js

This file was deleted.

Loading
Loading