Skip to content

Commit 633ea80

Browse files
committed
feat: create Layout component and transfer necessary code
meta: issue-6_layout-component
1 parent 0a3d4b3 commit 633ea80

File tree

10 files changed

+33
-8
lines changed

10 files changed

+33
-8
lines changed

public/logo.png

-8.97 KB
Binary file not shown.

public/logo192.png

5.22 KB
Loading

public/logo512.png

9.44 KB
Loading

src/App.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import React from 'react';
2-
import { ApolloProvider } from '@apollo/client';
2+
import { Route, Routes } from 'react-router-dom';
33
import client from './client';
4+
import { ApolloProvider } from '@apollo/client';
5+
46
import { ArticleListContainer, ArticlePageContainer } from './containers';
5-
import { Route, Routes, Link } from 'react-router-dom';
6-
import { AppStyled, MainLogoStyled } from './styled';
7+
import { AppLayout } from './components';
78

89
function App() {
910
return (
1011
<ApolloProvider client={client}>
11-
<AppStyled>
12-
<Link to="/">
13-
<MainLogoStyled src='https://point.md/static/svg/new-point-logo.svg' alt='Point logo' />
14-
</Link>
12+
<AppLayout>
1513
<Routes>
1614
<Route path="/" element={<ArticleListContainer />} />
1715
<Route path="/article/:slag" element={<ArticlePageContainer />} />
1816
</Routes>
19-
</AppStyled>
17+
</AppLayout>
2018
</ApolloProvider>
2119
);
2220
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { Outlet, Link } from 'react-router-dom';
3+
4+
import { AppStyled, MainLogoStyled } from './styled';
5+
6+
7+
export const AppLayout: React.FC<{
8+
children: React.ReactElement | null;
9+
}> = ({ children }): JSX.Element => {
10+
return (
11+
<>
12+
<AppStyled>
13+
<Link to="/">
14+
<MainLogoStyled src='https://point.md/static/svg/new-point-logo.svg' alt='Point logo' />
15+
</Link>
16+
<Outlet />
17+
{children}
18+
</AppStyled>
19+
</>
20+
);
21+
};

src/components/AppLayout/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { AppLayout } from './AppLayout';

src/styled.tsx src/components/AppLayout/styled.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const AppStyled = styled.div`
1010
padding: 20px;
1111
margin: 0 auto;
1212
background: #F5F5F5;
13+
background-color: rgb(255, 255, 255);
1314
`;
1415

1516
export const MainLogoStyled = styled.img`

src/components/ArticleItem/styled.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const ArticleItemStyled = styled.li`
1212

1313
const ArticleImgBoxStyled = styled.div`
1414
width: 240px;
15+
min-width: 240px
1516
`;
1617

1718
const ArticleImgStyled = styled.img`

src/components/ArticlePage/styled.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const ArticlePageStyled = styled.div`
55
max-width: 984px;
66
padding: 24px;
77
border-radius: 8px;
8+
display: flex;
9+
flex-direction: column;
810
`;
911

1012
const ArticleTitleStyled = styled.h2`

src/components/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { ArticleList } from './ArticleList';
2+
export { AppLayout } from './AppLayout';

0 commit comments

Comments
 (0)