Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Thomasroest/basic layout component #159

Closed
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
20 changes: 20 additions & 0 deletions client/components/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { StyledLayout, StyledMain } from './styles';
import MainHeader from '../MainHeader';
import MainFooter from '../MainFooter';

interface IProps {
children: React.ReactNode;
}

const Layout = ({ children }: IProps) => {
return (
<StyledLayout>
<MainHeader />
<StyledMain>{children}</StyledMain>
<MainFooter />
</StyledLayout>
);
};

export default Layout;
11 changes: 11 additions & 0 deletions client/components/Layout/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import styled from 'styled-components';

export const StyledLayout = styled.div`
display: flex;
flex-direction: column;
min-height: 100vh;
`;

export const StyledMain = styled.main`
flex: 1;
`;
7 changes: 7 additions & 0 deletions client/components/MainFooter/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

const MainFooter = () => {
return <footer>Footer</footer>;
};

export default MainFooter;
15 changes: 15 additions & 0 deletions client/components/MainHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { AppBar, Toolbar } from '@material-ui/core';
import { Logo } from './styles';

const MainHeader = () => {
return (
<AppBar position="relative" color="primary">
<Toolbar>
<Logo>Chapter</Logo>
</Toolbar>
</AppBar>
);
};

export default MainHeader;
5 changes: 5 additions & 0 deletions client/components/MainHeader/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styled from 'styled-components';

export const Logo = styled.span`
font-size: 1.5rem;
`;
2 changes: 1 addition & 1 deletion client/components/SomeComponent/__test__/Index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { ThemeProvider } from 'styled-components';
import { SomeComponent } from 'client/components';
import SomeComponent from 'client/components/SomeComponent';
import { themeObject } from 'styles/theme';

describe('SomeComponent', () => {
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions client/components/index.ts

This file was deleted.

7 changes: 4 additions & 3 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { SomeComponent } from 'client/components';
import Layout from 'client/components/Layout';
import SomeComponent from 'client/components/SomeComponent';

const Index = () => {
return (
<div>
<Layout>
<SomeComponent />
</div>
</Layout>
);
};

Expand Down