Skip to content

Commit

Permalink
feat: create layout container for the pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Santiago committed Oct 14, 2021
1 parent 830970c commit edf4fc6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/@types/Components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ declare namespace Header {
isNavigationCollapsed: boolean
}
}

declare namespace PageLayoutContainer {
type Props = {
isNavigationCollapsed: boolean
children: React.ReactNode
}
}
1 change: 1 addition & 0 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { avatar } from 'assets/icons';

const useStyles = makeStyles((theme: Theme) => ({
headerContainer: {
zIndex: 1,
position: 'fixed',
width: 'calc(100% - 280px)',
right: 0,
Expand Down
41 changes: 41 additions & 0 deletions src/components/PageLayoutContainer/PageLayoutContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
Grid, Theme, useMediaQuery, useTheme,
} from '@material-ui/core';
import { makeStyles } from '@material-ui/styles';
import clsx from 'clsx';

const useStyles = makeStyles((theme: Theme) => ({
rootContainer: {
position: 'fixed',
width: 'calc(100% - 280px)',
right: 0,
top: 104,
padding: theme.spacing(3),
transition: 'width 0.2s ease',
},
rootContainerExtended: {
width: `calc(100% - ${theme.spacing(9)}px)`,
[theme.breakpoints.down('sm')]: {
width: '100%',
},
},
}));

export const PageLayoutContainer = ({
isNavigationCollapsed,
children,
}: PageLayoutContainer.Props): JSX.Element => {
const classes = useStyles();
const theme = useTheme();
const matchesSmallSize = useMediaQuery(theme.breakpoints.down('sm'));

return (
<Grid
container
className={clsx(classes.rootContainer,
(matchesSmallSize || isNavigationCollapsed) && classes.rootContainerExtended)}
>
{children}
</Grid>
);
};
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { MenuItem } from './MenuItem/MenuItem';
export { Navigation } from './Navigation/Navigation';
export { Header } from './Header/Header';
export { PageLayoutContainer } from './PageLayoutContainer/PageLayoutContainer';

0 comments on commit edf4fc6

Please sign in to comment.