Skip to content

Commit c1257f9

Browse files
[blog] Improve the width of the layout (mui#33706)
1 parent 3846a8f commit c1257f9

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

Diff for: docs/src/modules/brandingTheme.ts

-10
Original file line numberDiff line numberDiff line change
@@ -456,16 +456,6 @@ export function getThemedComponents(theme: Theme): { components: Theme['componen
456456
},
457457
},
458458
},
459-
MuiContainer: {
460-
styleOverrides: {
461-
root: {
462-
[theme.breakpoints.up('md')]: {
463-
paddingLeft: theme.spacing(2),
464-
paddingRight: theme.spacing(2),
465-
},
466-
},
467-
},
468-
},
469459
MuiDivider: {
470460
styleOverrides: {
471461
root: {

Diff for: docs/src/modules/components/AppContainer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as React from 'react';
22
import { styled } from '@mui/material/styles';
33
import Container from '@mui/material/Container';
44

5-
const StyledContainer = styled(Container)(({ theme }) => {
5+
const StyledAppContainer = styled(Container)(({ theme }) => {
66
return {
7-
paddingTop: 80 + 20,
7+
paddingTop: 'calc(var(--MuiDocs-header-height) + 36px)',
88
// We're mostly hosting text content so max-width by px does not make sense considering font-size is system-adjustable.
99
// 105ch ≈ 930px
1010
fontFamily: 'Arial',
@@ -17,5 +17,5 @@ const StyledContainer = styled(Container)(({ theme }) => {
1717
});
1818

1919
export default function AppContainer(props) {
20-
return <StyledContainer id="main-content" maxWidth={false} tabIndex={-1} {...props} />;
20+
return <StyledAppContainer id="main-content" maxWidth={false} tabIndex={-1} {...props} />;
2121
}

Diff for: docs/src/modules/components/TopLayoutBlog.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ const classes = {
9696
container: 'TopLayoutBlog-container',
9797
};
9898

99+
// Replicate the value used by https://medium.com/, a trusted reference.
100+
const BLOG_MAX_WIDTH = 692;
101+
99102
const styles = ({ theme }) => ({
100103
flexGrow: 1,
101104
background:
@@ -112,8 +115,14 @@ const styles = ({ theme }) => ({
112115
},
113116
[`& .${classes.container}`]: {
114117
paddingTop: 60 + 20,
115-
marginBottom: theme.spacing(8),
116-
maxWidth: `calc(740px + ${theme.spacing(12)})`,
118+
marginBottom: theme.spacing(12),
119+
maxWidth: `calc(${BLOG_MAX_WIDTH}px + ${theme.spacing(2 * 2)})`,
120+
[theme.breakpoints.up('md')]: {
121+
maxWidth: `calc(${BLOG_MAX_WIDTH}px + ${theme.spacing(3 * 2)})`,
122+
},
123+
[theme.breakpoints.up('lg')]: {
124+
maxWidth: `calc(${BLOG_MAX_WIDTH}px + ${theme.spacing(8 * 2)})`,
125+
},
117126
'& h1': {
118127
marginBottom: theme.spacing(3),
119128
},
@@ -197,6 +206,8 @@ const AuthorsContainer = styled('div')(({ theme }) => ({
197206
},
198207
}));
199208

209+
const Root = styled('div')(styles);
210+
200211
function TopLayoutBlog(props) {
201212
const { className, docs } = props;
202213
const { description, rendered, title, headers } = docs.en;
@@ -217,7 +228,7 @@ function TopLayoutBlog(props) {
217228
: 'https://mui.com/static/logo.png'
218229
}
219230
/>
220-
<div className={className}>
231+
<Root className={className}>
221232
<AppContainer component="main" className={classes.container}>
222233
<Link
223234
href={ROUTES.blog}
@@ -281,7 +292,7 @@ function TopLayoutBlog(props) {
281292
<HeroEnd />
282293
<Divider />
283294
<AppFooter />
284-
</div>
295+
</Root>
285296
</BrandingProvider>
286297
);
287298
}
@@ -295,4 +306,4 @@ if (process.env.NODE_ENV !== 'production') {
295306
TopLayoutBlog.propTypes = exactProp(TopLayoutBlog.propTypes);
296307
}
297308

298-
export default styled(TopLayoutBlog)(styles);
309+
export default TopLayoutBlog;

Diff for: prettier.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
files: ['docs/pages/blog/**/*.md'],
1616
options: {
1717
// otherwise code blocks overflow on the blog website
18-
// The container is 676px
18+
// The container is 692px
1919
printWidth: 82,
2020
},
2121
},

0 commit comments

Comments
 (0)