Skip to content

Commit c6f50d3

Browse files
Add hook router
1 parent 7c10ac2 commit c6f50d3

File tree

23 files changed

+162
-77
lines changed

23 files changed

+162
-77
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@testing-library/user-event": "^7.1.2",
99
"babel-plugin-transform-remove-console": "^6.9.4",
1010
"customize-cra": "^0.9.1",
11+
"hookrouter": "^1.2.3",
1112
"node-sass": "^4.13.0",
1213
"react": "^16.12.0",
1314
"react-app-rewired": "^2.1.5",

src/App.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
import React from 'react';
2-
import logo from './logo.svg';
2+
import { useRoutes } from 'hookrouter';
3+
import routes from './router';
4+
import NoPageFound from './pages/NoPageFound/NoPageFound';
35
import './App.scss';
46

5-
function App() {
7+
const App = () => {
68
console.log('This console will be remove in Production mode');
9+
const routeResult = useRoutes(routes);
710

811
return (
9-
<div className="App">
10-
<header className="header">
11-
<img src={logo} className="logo" alt="logo" />
12-
<p>
13-
Edit <code>src/App.js</code> and save to reload.
14-
</p>
15-
<a
16-
className="link"
17-
href="https://reactjs.org"
18-
target="_blank"
19-
rel="noopener noreferrer"
20-
>
21-
Learn React
22-
</a>
23-
</header>
12+
<div className="app-container">
13+
{routeResult || <NoPageFound />}
2414
</div>
2515
);
2616
}

src/App.scss

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,5 @@
1-
@import './scss/variables.scss';
2-
3-
.App {
4-
text-align: center;
5-
.header {
6-
background-color: #282c34;
7-
min-height: 100vh;
8-
display: flex;
9-
flex-direction: column;
10-
align-items: center;
11-
justify-content: center;
12-
font-size: calc(10px + 2vmin);
13-
color: white;
14-
.logo {
15-
height: 40vmin;
16-
pointer-events: none;
17-
}
18-
.link {
19-
color: $primaryColor;
20-
}
21-
}
22-
}
23-
@media (prefers-reduced-motion: no-preference) {
24-
.App {
25-
.header {
26-
.logo {
27-
animation: App-logo-spin infinite 20s linear;
28-
}
29-
}
30-
}
31-
}
32-
@keyframes App-logo-spin {
33-
from {
34-
transform: rotate(0deg);
35-
}
36-
to {
37-
transform: rotate(360deg);
38-
}
1+
.app-container {
2+
max-width: 80%;
3+
margin: 0 auto;
4+
color: #252525;
395
}

src/App.test.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import { A } from 'hookrouter';
3+
import './Navigation.scss';
4+
5+
const Navigation = () => {
6+
return (
7+
<div className="navigation-container">
8+
<ul>
9+
<li><A href="/">Home</A></li>
10+
<li><A href="/terms">Terms of Use</A></li>
11+
<li><A href="/privacy">Privacy Policy</A></li>
12+
<li><A href="/blog/1">Blog 1</A></li>
13+
<li><A href="/blog/2">Blog 2</A></li>
14+
</ul>
15+
</div>
16+
);
17+
};
18+
19+
export default Navigation;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@import "../../scss/variables.scss";
2+
3+
.navigation-container {
4+
ul {
5+
li {
6+
a {
7+
color: $primaryColor;
8+
text-decoration: none;
9+
&:hover {
10+
color: darken($color: $primaryColor, $amount: 10);
11+
}
12+
}
13+
}
14+
}
15+
}

src/components/Title/Title.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import './Title.scss';
3+
4+
const Title = props => {
5+
return <h1 className="title-container">{props.children}</h1>;
6+
};
7+
8+
export default Title;

src/components/Title/Title.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.title-container {
2+
text-transform: uppercase;
3+
}

src/logo.svg

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/pages/Blog/Blog.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import Navigation from '../../components/Navigation/Navigation';
3+
import Title from '../../components/Title/Title';
4+
import './Blog.scss';
5+
6+
const Blog = ({ blogId }) => {
7+
return (
8+
<div className="blog-container">
9+
<Navigation />
10+
<Title>{`Blog Page with id: ${blogId}`}</Title>
11+
</div>
12+
);
13+
};
14+
15+
export default Blog;

0 commit comments

Comments
 (0)