Skip to content

Commit

Permalink
[blog] Improve the width of the layout (#33706)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Aug 5, 2022
1 parent 3846a8f commit c1257f9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
10 changes: 0 additions & 10 deletions docs/src/modules/brandingTheme.ts
Expand Up @@ -456,16 +456,6 @@ export function getThemedComponents(theme: Theme): { components: Theme['componen
},
},
},
MuiContainer: {
styleOverrides: {
root: {
[theme.breakpoints.up('md')]: {
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
},
},
},
},
MuiDivider: {
styleOverrides: {
root: {
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/components/AppContainer.js
Expand Up @@ -2,9 +2,9 @@ import * as React from 'react';
import { styled } from '@mui/material/styles';
import Container from '@mui/material/Container';

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

export default function AppContainer(props) {
return <StyledContainer id="main-content" maxWidth={false} tabIndex={-1} {...props} />;
return <StyledAppContainer id="main-content" maxWidth={false} tabIndex={-1} {...props} />;
}
21 changes: 16 additions & 5 deletions docs/src/modules/components/TopLayoutBlog.js
Expand Up @@ -96,6 +96,9 @@ const classes = {
container: 'TopLayoutBlog-container',
};

// Replicate the value used by https://medium.com/, a trusted reference.
const BLOG_MAX_WIDTH = 692;

const styles = ({ theme }) => ({
flexGrow: 1,
background:
Expand All @@ -112,8 +115,14 @@ const styles = ({ theme }) => ({
},
[`& .${classes.container}`]: {
paddingTop: 60 + 20,
marginBottom: theme.spacing(8),
maxWidth: `calc(740px + ${theme.spacing(12)})`,
marginBottom: theme.spacing(12),
maxWidth: `calc(${BLOG_MAX_WIDTH}px + ${theme.spacing(2 * 2)})`,
[theme.breakpoints.up('md')]: {
maxWidth: `calc(${BLOG_MAX_WIDTH}px + ${theme.spacing(3 * 2)})`,
},
[theme.breakpoints.up('lg')]: {
maxWidth: `calc(${BLOG_MAX_WIDTH}px + ${theme.spacing(8 * 2)})`,
},
'& h1': {
marginBottom: theme.spacing(3),
},
Expand Down Expand Up @@ -197,6 +206,8 @@ const AuthorsContainer = styled('div')(({ theme }) => ({
},
}));

const Root = styled('div')(styles);

function TopLayoutBlog(props) {
const { className, docs } = props;
const { description, rendered, title, headers } = docs.en;
Expand All @@ -217,7 +228,7 @@ function TopLayoutBlog(props) {
: 'https://mui.com/static/logo.png'
}
/>
<div className={className}>
<Root className={className}>
<AppContainer component="main" className={classes.container}>
<Link
href={ROUTES.blog}
Expand Down Expand Up @@ -281,7 +292,7 @@ function TopLayoutBlog(props) {
<HeroEnd />
<Divider />
<AppFooter />
</div>
</Root>
</BrandingProvider>
);
}
Expand All @@ -295,4 +306,4 @@ if (process.env.NODE_ENV !== 'production') {
TopLayoutBlog.propTypes = exactProp(TopLayoutBlog.propTypes);
}

export default styled(TopLayoutBlog)(styles);
export default TopLayoutBlog;
2 changes: 1 addition & 1 deletion prettier.config.js
Expand Up @@ -15,7 +15,7 @@ module.exports = {
files: ['docs/pages/blog/**/*.md'],
options: {
// otherwise code blocks overflow on the blog website
// The container is 676px
// The container is 692px
printWidth: 82,
},
},
Expand Down

0 comments on commit c1257f9

Please sign in to comment.