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

[Layout] Per page Layout? #1168

Open
aress31 opened this issue Feb 11, 2022 · 0 comments
Open

[Layout] Per page Layout? #1168

aress31 opened this issue Feb 11, 2022 · 0 comments
Labels
improvement Make this project better pkg: layout issue related to @mui-treasury/layout

Comments

@aress31
Copy link
Contributor

aress31 commented Feb 11, 2022

Quick question, I built my website using a specific config/layout defined as follows in config/mui-layout.js:

export default {
  header: {
    config: {
      xs: {
        clipped: false,
        height: 'auto',
        position: 'sticky',
      },
    },
  },
  leftEdgeSidebar: {
    config: {
      xs: {
        variant: 'temporary',
        width: 256,
      },
      // TODO: Track https://github.com/siriwatknp/mui-treasury/issues/1156
      // eslint-disable-next-line
      sm: {
        collapsible: false,
        persistentBehavior: 'fit',
        variant: 'persistent',
        width: 256,
      },
    },
    hidden: ['md', 'lg', 'xl'],
  },
};

I then configure my layout application-wide in App.js as follows:

--- SNIP ---
export default () => {
  const location = useLocation();
  const routeResult = useRoutes(routeConfig);

  return (
    <Root scheme={muiLayout}>
      <CssBaseline />
      <Header variant='outlined'>
        <NavBar />
      </Header>
      <EdgeSidebar anchor='left'>
        <SidebarContent>
          <DrawerContent />
        </SidebarContent>
      </EdgeSidebar>
      <Content>
        <SnackbarProvider
          // TODO: Responsiveness
          // Track https://github.com/iamhosseindhv/notistack/issues/427
          // Track https://github.com/iamhosseindhv/notistack/issues/428
          // {...(useMediaQuery(
          //   (theme) => theme.breakpoints.up('xs'),
          //   { noSsr: true }
          // ) && { dense: false })}
          maxSnack={3}
        >
          <React.Suspense fallback={<LoadingSpinner />}>
            {/* Excludes pages with a hero */}
            {['/'].includes(location.pathname) ? (
              <>{routeResult}</>
            ) : (
              <StyledContainer maxWidth='lg'>
                {routeResult}
              </StyledContainer>
            )}
          </React.Suspense>
        </SnackbarProvider>
      </Content>
      <StyledFooter>
        <Container maxWidth='md'>
          <FooterContent />
        </Container>
      </StyledFooter>
    </Root>
  );
};

However, I am facing an issue as the layout needs to be different for pages/Blog.js, indeed, need to implement a Blog-oriented layout, as detailed in https://next.mui-treasury.com/?path=/story/layout-tutorials-blog--page. Is there an easy way to make one-time off changes to the layout for specific routes/pages?

@siriwatknp siriwatknp added improvement Make this project better pkg: layout issue related to @mui-treasury/layout labels Feb 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Make this project better pkg: layout issue related to @mui-treasury/layout
Projects
None yet
Development

No branches or pull requests

2 participants