Skip to content

Commit 761a74e

Browse files
committed
add button component
1 parent c25f23c commit 761a74e

File tree

7 files changed

+29
-31
lines changed

7 files changed

+29
-31
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ The goal of this exercise is to understand what's state and how to reason about
8080
- [ ] 5. Break `<Books>` down into `<BookList>` and `<BookFilter>`
8181

8282
## 🏋️‍♀️ Bonus exercise
83-
- What do you think it would make sense to componentize next? Are there any parts on that view that you can reuse? Hint, replace the `<a>` with your `<Link>` component. Who are the children of the `Link` component? The `Link` component should receive a prop called `to` that becomes the href of the `<a href={to} ...`. Try to use the prop called `children` for the text displayed inside the anchor.
83+
- Abstract the `button` component that is inside the `Navbar` component and `Menu` component into a `Button` component. Do we know ahead of time who are the children of the `Button` component? Try to use the prop called `children` for the elements displayed inside the button.
8484
- Can we move the `isMenuOpen` state inside the menu? Does it conflict with the idea of "lifting the state up".
8585
- If you look at the [React Profiler](https://reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html) when you open and close the menu, is the whole app being rendered? If so, how can we avoid that and still lift the state up?
8686

public/css/main.css

-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ footer .footer-below {
297297
border: solid 2px white;
298298
background: transparent;
299299
transition: all 0.3s ease-in-out;
300-
margin-top: 15px;
301300
}
302301
.btn-outline:hover,
303302
.btn-outline:focus,

src/components/Button.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const Button = (props) => (
4+
<button onClick={props.onClick} className="btn btn-lg btn-outline">
5+
{props.children}
6+
</button>
7+
)
8+
9+
export default Button

src/components/Footer.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ function Footer() {
5050
</ul>
5151
</div>
5252
<div className="footer-col col-md-4">
53-
<h3>About ReactJS Academy</h3>
53+
<h3>About React GraphQL Academy</h3>
5454
<p>
55-
<a href="https://reactjs.academy/">ReactJS Academy</a>
55+
<a href="https://reactjs.academy/">React GraphQL Academy</a>
56+
{` `}
5657
<span>
57-
ReactJS Academy is Europes longest running dedicated React,
58-
Redux, and GraphQL training.
58+
is Europes longest running dedicated React, Redux, and GraphQL
59+
training.
5960
</span>
6061
</p>
6162
</div>
@@ -67,13 +68,7 @@ function Footer() {
6768
<div className="row">
6869
<div className="col-lg-12">
6970
<span>Copyright &copy;</span>{' '}
70-
<a
71-
href="https://leanjs.com/"
72-
target="_blank"
73-
rel="noopener noreferrer"
74-
>
75-
LeanJS
76-
</a>
71+
<a to="https://leanjs.com/">LeanJS</a>
7772
</div>
7873
</div>
7974
</div>

src/components/Header.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react'
22

3-
const Header = props => (
3+
const Header = (props) => (
44
<header>
55
<div className="container">
66
<div className="row">
77
<div className="col-lg-12">
88
<img
9-
alt="Logo ReactJS Academy"
9+
alt="Logo React GraphQL Academy"
1010
className="img-responsive logo-academy"
1111
src="/img/logo.png"
1212
/>

src/components/Navigations/Menu.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@ import React from 'react'
22

33
import SideMenu from './Menus/SideMenu'
44
import SideMenuItem from './Menus/SideMenuItem'
5+
import Button from '../Button'
56

6-
const Menu = props => (
7+
const Menu = (props) => (
78
<SideMenu isOpen={props.isOpen} toggleMenu={props.toggleMenu}>
8-
<h4>
9-
Next Courses
10-
<button
11-
className="btn-link"
12-
onClick={() => props.toggleMenu()}
13-
style={{ cursor: 'pointer' }}
14-
>
15-
<i className="fa fa-close pull-right" />
16-
</button>
17-
</h4>
9+
<div style={{ position: 'absolute', right: '10px' }}>
10+
<Button onClick={() => props.toggleMenu()}>
11+
<i className="fa fa-close" />
12+
</Button>
13+
</div>
14+
<h4>Next Courses</h4>
1815
<SideMenuItem link="https://reactjs.academy/react-redux-graphql-bootcamp/">
1916
Bootcamp
2017
</SideMenuItem>

src/components/Navigations/Navbar.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react'
2+
import Button from '../Button'
23

34
function Navbar(props) {
45
return (
@@ -14,12 +15,9 @@ function Navbar(props) {
1415
<a href="#about">About us</a>
1516
</li>
1617
<li>
17-
<button
18-
onClick={props.toggleMenu}
19-
className="btn btn-lg btn-outline"
20-
>
18+
<Button onClick={props.toggleMenu}>
2119
<i className="fa fa-graduation-cap" /> <span>Training</span>
22-
</button>
20+
</Button>
2321
</li>
2422
</ul>
2523
</div>

0 commit comments

Comments
 (0)