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

[blog] Improve the width of the layout #33706

Merged
merged 3 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 0 additions & 10 deletions docs/src/modules/brandingTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,6 @@ export function getThemedComponents(theme: Theme): { components: Theme['componen
},
},
},
MuiContainer: {
Copy link
Member Author

@oliviertassinari oliviertassinari Jul 30, 2022

Choose a reason for hiding this comment

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

This contradicts the default values we have for the <Container> that we have in MUI System as best practices.

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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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;
Copy link
Member Author

@oliviertassinari oliviertassinari Jul 30, 2022

Choose a reason for hiding this comment

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

The BrandingProvider theme was not applied at this point yet. theme.spacing would be 8 vs. 10 pixels based on either the context is provided or not.

2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
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