Skip to content

Commit 500a6cd

Browse files
committed
Add _Patterns_ page
1 parent d0abd77 commit 500a6cd

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/Layout.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { themeLight } from './styles/themes/theme.light';
1212
import { themeDark } from './styles/themes/theme.dark';
1313
import Game from './pages/Game';
1414
import About from './pages/About';
15+
import Patterns from './pages/Patterns';
1516
import { getMode } from './selectors';
1617

1718
const Layout = props => {
@@ -32,6 +33,7 @@ const Layout = props => {
3233
<Header />
3334

3435
<Route exact path="/" render={() => <Game style={style} />} />
36+
<Route path="/patterns/:pattern" component={Patterns} />
3537
<Route path="/about" component={About} />
3638
</React.Fragment>
3739
</ThemeProvider>

src/components/Header.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const Header = () => (
4646
<StyledHeader>
4747
<StyledLinkContainer>
4848
<StyledRouterLink to="/">Game</StyledRouterLink>
49+
<StyledRouterLink to="/patterns/memento">Patterns</StyledRouterLink>
4950
<StyledRouterLink to="/about">About</StyledRouterLink>
5051
<StyledLink href="//github.com/zoltantothcom/javascript-patterns" target="_blank">
5152
GitHub

src/pages/Patterns.jsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import styled from 'styled-components';
4+
5+
const StyledPatterns = styled.div``;
6+
7+
const Header = styled.h3`
8+
color: ${props => props.theme.buttonColorHover};
9+
margin-top: 2rem;
10+
`;
11+
12+
// const Patterns = ({ match }) => {
13+
// const { pattern } = match.params;
14+
15+
const Patterns = props => {
16+
console.log(props);
17+
18+
props.history.listen(location => {
19+
console.log(location);
20+
});
21+
22+
const { pattern } = props.match.params;
23+
24+
return (
25+
<StyledPatterns>
26+
<Header>{pattern}</Header>
27+
</StyledPatterns>
28+
);
29+
};
30+
31+
Patterns.propTypes = {
32+
history: PropTypes.object.isRequired,
33+
match: PropTypes.object.isRequired
34+
};
35+
36+
export default Patterns;

0 commit comments

Comments
 (0)