Skip to content

Commit

Permalink
Merge branch 'next' into fix-broken-links
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Aug 2, 2024
2 parents 60a9efa + 85a3b55 commit f7eef73
Show file tree
Hide file tree
Showing 118 changed files with 5,487 additions and 1,629 deletions.
2 changes: 0 additions & 2 deletions benchmark/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ HocButton x 166,229 ops/sec ±1.04% (191 runs sampled)
NakedButton x 228,473 ops/sec ±0.99% (187 runs sampled)
ButtonBase enable ripple x 56,019 ops/sec ±0.87% (189 runs sampled)
ButtonBase disable ripple x 61,748 ops/sec ±0.35% (190 runs sampled)
Markdown x 954 ops/sec ±1.35% (187 runs sampled)
```

## `@mui/docs`
Expand All @@ -22,7 +21,6 @@ _Synthetic benchmark_
```bash
pnpm server:docs

Markdown x 946 ops/sec ±4.04% (176 runs sampled)
MarkdownElement x 3,941 ops/sec ±5.53% (185 runs sampled)
```

Expand Down
4 changes: 0 additions & 4 deletions benchmark/server/scenarios/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Benchmark from 'benchmark';
import * as React from 'react';
import * as ReactDOMServer from 'react-dom/server';
import { MarkdownElement } from '@mui/docs/MarkdownElement';
import Markdown from 'docs/data/material/getting-started/templates/blog/Markdown';
import { createStore } from 'redux';
import { Provider } from 'react-redux';

Expand All @@ -28,9 +27,6 @@ const store = createStore((state) => state, {
});

suite
.add('Markdown', () => {
ReactDOMServer.renderToString(<Markdown>{markdown}</Markdown>);
})
.add('MarkdownElement', () => {
ReactDOMServer.renderToString(
<Provider store={store}>
Expand Down
175 changes: 75 additions & 100 deletions docs/data/material/getting-started/templates/blog/Blog.js
Original file line number Diff line number Diff line change
@@ -1,118 +1,93 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import CssBaseline from '@mui/material/CssBaseline';
import Grid from '@mui/material/Grid';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import GitHubIcon from '@mui/icons-material/GitHub';
import FacebookIcon from '@mui/icons-material/Facebook';
import XIcon from '@mui/icons-material/X';
import ToggleButton from '@mui/material/ToggleButton';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import Header from './Header';
import MainFeaturedPost from './MainFeaturedPost';
import FeaturedPost from './FeaturedPost';
import Main from './Main';
import Sidebar from './Sidebar';
import Footer from './Footer';
import post1 from './blog-post.1.md';
import post2 from './blog-post.2.md';
import post3 from './blog-post.3.md';

const sections = [
{ title: 'Technology', url: '#' },
{ title: 'Design', url: '#' },
{ title: 'Culture', url: '#' },
{ title: 'Business', url: '#' },
{ title: 'Politics', url: '#' },
{ title: 'Opinion', url: '#' },
{ title: 'Science', url: '#' },
{ title: 'Health', url: '#' },
{ title: 'Style', url: '#' },
{ title: 'Travel', url: '#' },
];
import AutoAwesomeRoundedIcon from '@mui/icons-material/AutoAwesomeRounded';

const mainFeaturedPost = {
title: 'Title of a longer featured blog post',
description:
"Multiple lines of text that form the lede, informing new readers quickly and efficiently about what's most interesting in this post's contents.",
image: 'https://picsum.photos/1100/350',
imageText: 'main image description',
linkText: 'Continue reading…',
};
import AppAppBar from './components/AppAppBar';
import MainContent from './components/MainContent';
import Latest from './components/Latest';
import Footer from './components/Footer';

const featuredPosts = [
{
title: 'Featured post',
date: 'Nov 12',
description:
'This is a wider card with supporting text below as a natural lead-in to additional content.',
image: 'https://picsum.photos/200/300',
imageLabel: 'Image Text',
},
{
title: 'Post title',
date: 'Nov 11',
description:
'This is a wider card with supporting text below as a natural lead-in to additional content.',
image: 'https://picsum.photos/200/300',
imageLabel: 'Image Text',
},
];
import getBlogTheme from './theme/getBlogTheme';

const posts = [post1, post2, post3];
function ToggleCustomTheme({ showCustomTheme, toggleCustomTheme }) {
return (
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
width: '100dvw',
position: 'fixed',
bottom: 24,
}}
>
<ToggleButtonGroup
color="primary"
exclusive
value={showCustomTheme}
onChange={toggleCustomTheme}
aria-label="Toggle design language"
sx={{
backgroundColor: 'background.default',
'& .Mui-selected': {
pointerEvents: 'none',
},
}}
>
<ToggleButton value>
<AutoAwesomeRoundedIcon sx={{ fontSize: '20px', mr: 1 }} />
Custom theme
</ToggleButton>
<ToggleButton value={false}>Material Design 2</ToggleButton>
</ToggleButtonGroup>
</Box>
);
}

const sidebar = {
title: 'About',
description:
'Etiam porta sem malesuada magna mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.',
archives: [
{ title: 'March 2020', url: '#' },
{ title: 'February 2020', url: '#' },
{ title: 'January 2020', url: '#' },
{ title: 'November 1999', url: '#' },
{ title: 'October 1999', url: '#' },
{ title: 'September 1999', url: '#' },
{ title: 'August 1999', url: '#' },
{ title: 'July 1999', url: '#' },
{ title: 'June 1999', url: '#' },
{ title: 'May 1999', url: '#' },
{ title: 'April 1999', url: '#' },
],
social: [
{ name: 'GitHub', icon: GitHubIcon },
{ name: 'X', icon: XIcon },
{ name: 'Facebook', icon: FacebookIcon },
],
ToggleCustomTheme.propTypes = {
showCustomTheme: PropTypes.shape({
valueOf: PropTypes.func.isRequired,
}).isRequired,
toggleCustomTheme: PropTypes.func.isRequired,
};

// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();

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 } });

const toggleColorMode = () => {
setMode((prev) => (prev === 'dark' ? 'light' : 'dark'));
};

const toggleCustomTheme = () => {
setShowCustomTheme((prev) => !prev);
};

return (
<ThemeProvider theme={defaultTheme}>
<ThemeProvider theme={showCustomTheme ? blogTheme : defaultTheme}>
<CssBaseline />
<Container maxWidth="lg">
<Header title="Blog" sections={sections} />
<main>
<MainFeaturedPost post={mainFeaturedPost} />
<Grid container spacing={4}>
{featuredPosts.map((post) => (
<FeaturedPost key={post.title} post={post} />
))}
</Grid>
<Grid container spacing={5} sx={{ mt: 3 }}>
<Main title="From the firehose" posts={posts} />
<Sidebar
title={sidebar.title}
description={sidebar.description}
archives={sidebar.archives}
social={sidebar.social}
/>
</Grid>
</main>
<AppAppBar mode={mode} toggleColorMode={toggleColorMode} />
<Container
maxWidth="lg"
component="main"
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }}
>
<MainContent />
<Latest />
</Container>
<Footer
title="Footer"
description="Something here to give the footer a purpose!"
<Footer />
<ToggleCustomTheme
toggleCustomTheme={toggleCustomTheme}
showCustomTheme={showCustomTheme}
/>
</ThemeProvider>
);
Expand Down
Loading

0 comments on commit f7eef73

Please sign in to comment.