Skip to content

Commit c38e96b

Browse files
author
Noer Paanakker
committed
finished homeworks week 1
1 parent 59edcd9 commit c38e96b

File tree

12 files changed

+340
-40
lines changed

12 files changed

+340
-40
lines changed

EXTRA.md

-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ React makes use of this SPA structure, bundling all your JavaScript code and inj
1515
There is nothing inherently bad about having static frontends. However, as websites increasingly became more interactive there arose a need to display customized content. Content that is dependent upon the user and user input. This is what React aims to do.
1616

1717
4. Learn about the how and why of [JavaScript frameworks](https://medium.com/dailyjs/the-deepest-reason-why-modern-javascript-frameworks-exist-933b86ebc445). Whenever building software you can build on top of what others have already done; this is why we use a framework. It not only allows us to structure our application, but also gives us tools on how to achieve certain requirements (like faster loading, and showing customized information to the user)
18-
19-
With that out of the way, let's get started with React!

assets/project/week1.png

100 KB
Loading

assets/project/week2.png

113 KB
Loading

week1/MAKEME.md

+92-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
1. Practice the concepts
66
2. React exercises
77
3. Code along
8-
4. PROJECT: Hack Your Todolist I
8+
4. PROJECT: Hack Your Weather I
99

1010
## **1. Practice the concepts**
1111

@@ -15,29 +15,108 @@ Let's get started with some interactive exercises! Complete the exercises from t
1515

1616
## **2. React exercises**
1717

18-
> Inside of your `React` fork, go to the `week1` folder and create a folder called `react-exercises`. For each exercise create a new folder (call it `exercise` follwed by the right number) and create 3 files: and `index.html`, `script.js` and `style.css`.
18+
> Inside of your `React` fork, go to the `week1` folder and create a React application called `react-exercises` (use `create-react-app`). Inside of the `src` folder create a JavaScript file with an appropriate name.
1919
20-
**Exercise 1**
20+
**Exercise 1: Extreme hobbies**
2121

22-
**Exercise 2**
22+
There's nothing better than some extreme sports to get the blood pumping.
2323

24-
**Exercise 3**
24+
Take a look at the following:
25+
26+
```js
27+
const hobbies = ['Surfing', 'Rock climbing', 'Mountain biking', 'Breakdancing'];
28+
```
29+
30+
1. Create 2 functional components: `<HobbyList>` and `<Hobbies>`
31+
2. Put the `hobbies` variable into the `<HobbyList>` component as state.
32+
3. In the `return` statement of the `<HobbyList>` use the `map()` function to return an instance of `<Hobby>`
33+
4. Pass down the hobby as a `prop`
34+
5. Test out if it works by importing it into the top level component, which in this case is `<App>`
35+
36+
**Exercise 2: Perfect customer service!**
37+
38+
Don't you love it when a company provides great customer service?
39+
40+
Take a look at the following image:
41+
42+
![Exercise 2](exercises/exercise2.png)
43+
44+
In this exercise you have to create a single component that you'll reuse to display different information each time.
45+
46+
1. Create a functional component called `<Guarantee>`
47+
2. Instantiate it 3 times
48+
3. Give each component 3 `props`: an `img`, `title` and `description`
49+
4. Pass down to each component the appropriate content. Take the images from the **assets** folder, inside the **exercise1** folder
50+
5. Test out if it works by importing it into the top level component, which is `<App>`
51+
52+
**Exercise 3: It's higher than 10!**
53+
54+
Let's create a simple number counter, starting from 0 until infinity!
55+
56+
1. Create 3 functional components called `<Counter>`, `<Count>` and `<Button>`
57+
2. Inside `<Counter>` define a state variable called `count` (initialized with value `0`) and state handler called `setCount`
58+
3. Inside `<Button>` create a `<button>` with the text `Add 1!` and `onClick` attribute
59+
4. Pass down the `count` state variable to `<Count>`, and the `setCount` to `<Button>`
60+
5. Inside `<Counter>`, declare a variable called `feedback` above the return statement. Give this variable a ternary operator value: if `count` is higher than 10 it should display the string `"It's higher than 10!"`, else it displays `"Keep counting..."`
61+
6. 5. Test out if it works by importing `<Counter>` into the top level component, which is `<App>`
2562

2663
## **3. Code along**
2764

28-
In the following tutorial you'll learn how to make
65+
Learning how to work with React is a fundamentally different approach to building frontends. Therefore, we need to practice a lot!
66+
67+
In the following tutorial you'll learn how to a `Random Quote Machine`!
68+
69+
Notice how you'll be writing `class` based components. This is an older React feature for writing components, but that's still valid.
70+
71+
Even though you'll be learning more modern ways of writing React applications, you should always be aware that applications can vary in the versions of technologies they're working with.
72+
73+
Don't worry! You don't have to memorize it all. Aim for understanding the principle behind it to the best you can. If you ever feel in doubt: do a Google search or ask a question in Slack!
74+
75+
Enjoy!
2976

30-
- [Build a Quiz](https://www.youtube.com/watch?v=aq-fCtg_gG4)
31-
- [Build a Recipe App With React](https://www.youtube.com/watch?v=U9T6YkEDkMo)
32-
- [Build a Calculator with React and Flexbox](https://www.youtube.com/watch?v=KzYUuTiHdiY)
33-
- [Build a Movie Database](https://www.youtube.com/playlist?list=PL_kAgwZgMfWyZ6m8fDwdiwEarr_g6nFxz)
3477
- [Build a Random Quote Machine](https://www.youtube.com/playlist?list=PL3cz80ehFCan4srLIp1HmhrQ0CU8Cw9XM)
3578

36-
## **4. PROJECT: Hack Your Todolist**
79+
## **4. PROJECT: Hack Your Weather I**
80+
81+
> Before you start, create a new folder called `project` that includes the files for the following web application you'll be building.
82+
83+
During this module you'll be starting a project called `Hack Your Weather`! Like in the Node.js module, each week you'll add to it until it becomes a fully-fledged application you can be proud of.
84+
85+
Here's what you're eventually going end up with: [Hack Your Weather Finished](https://hyf-weather-app.netlify.com/)
86+
87+
Let's get into it.
88+
89+
### 1. Setup
90+
91+
The first step to any project is to setup your development environment. Follow the steps:
92+
93+
1. Navigate to your `project` folder
94+
2. Inside, use `create-react-app` to create a React application. Give it the name `hackyourweather`
95+
3. Copy and paste the file `city-weather.json` inside of your project folder, into the `src` folder
96+
97+
### 2. Requirements
98+
99+
This week you'll build the foundation of your application. It should eventually look like this:
100+
101+
![Week 1 Wireframe](../assets/project/week1.png)
102+
103+
Here are the requirements your project needs to fulfill:
104+
105+
- List all the cities and their weather information (taken from `city-weather.json`)
106+
- Display each city in its own box
107+
- Each box should contain the following pieces of data:
108+
- `city name`
109+
- `country name`
110+
- `weather main`
111+
- `weather desciption`
112+
- `max and min temprature`
113+
- `location (longitude and lattitude)`
37114

38-
> Every week ends with a project you have to build on your own. Instead of getting clear-cut instructions, you'll get a list of criteria that your project needs to measure up to.
115+
Hints:
39116

40-
> Before you start, create a new folder called `project` that includes the files for the following app you'll be building.
117+
- Make use of the `map()` function to show the
118+
- Try to "think in components"
119+
- Look at the JSON file and carefully look at where the useful data is found
41120

42121
## **SUBMIT YOUR HOMEWORK!**
43122

week1/assets/exercise1/chat.png

4.76 KB
Loading

week1/assets/exercise1/coin.png

4.53 KB
Loading

week1/assets/exercise1/exercise2.png

143 KB
Loading

week1/assets/exercise1/f-delivery.png

3.02 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
[
2+
{
3+
"coord": {
4+
"lon": 4.89,
5+
"lat": 52.37
6+
},
7+
"weather": [
8+
{
9+
"id": 801,
10+
"main": "Clouds",
11+
"description": "few clouds",
12+
"icon": "02d"
13+
}
14+
],
15+
"base": "stations",
16+
"main": {
17+
"temp": 280.09,
18+
"pressure": 1005,
19+
"humidity": 87,
20+
"temp_min": 278.71,
21+
"temp_max": 281.48
22+
},
23+
"visibility": 10000,
24+
"wind": {
25+
"speed": 3.6,
26+
"deg": 190
27+
},
28+
"rain": {},
29+
"clouds": {
30+
"all": 20
31+
},
32+
"dt": 1573207196,
33+
"sys": {
34+
"type": 1,
35+
"id": 1524,
36+
"country": "NL",
37+
"sunrise": 1573195700,
38+
"sunset": 1573228801
39+
},
40+
"timezone": 3600,
41+
"id": 2759794,
42+
"name": "Amsterdam",
43+
"cod": 200
44+
},
45+
{
46+
"coord": {
47+
"lon": -0.13,
48+
"lat": 51.51
49+
},
50+
"weather": [
51+
{
52+
"id": 300,
53+
"main": "Drizzle",
54+
"description": "light intensity drizzle",
55+
"icon": "09d"
56+
}
57+
],
58+
"base": "stations",
59+
"main": {
60+
"temp": 280.32,
61+
"pressure": 1012,
62+
"humidity": 81,
63+
"temp_min": 279.15,
64+
"temp_max": 281.15
65+
},
66+
"visibility": 10000,
67+
"wind": {
68+
"speed": 4.1,
69+
"deg": 80
70+
},
71+
"clouds": {
72+
"all": 90
73+
},
74+
"dt": 1485789600,
75+
"sys": {
76+
"type": 1,
77+
"id": 5091,
78+
"message": 0.0103,
79+
"country": "GB",
80+
"sunrise": 1485762037,
81+
"sunset": 1485794875
82+
},
83+
"id": 2643743,
84+
"name": "London",
85+
"cod": 200
86+
},
87+
{
88+
"coord": { "lon": 139.76, "lat": 35.68 },
89+
"weather": [
90+
{
91+
"id": 803,
92+
"main": "Clouds",
93+
"description": "broken clouds",
94+
"icon": "04n"
95+
}
96+
],
97+
"base": "stations",
98+
"main": {
99+
"temp": 288.6,
100+
"pressure": 1017,
101+
"humidity": 63,
102+
"temp_min": 286.15,
103+
"temp_max": 290.93
104+
},
105+
"visibility": 10000,
106+
"wind": { "speed": 6.7, "deg": 80 },
107+
"clouds": { "all": 75 },
108+
"dt": 1573207100,
109+
"sys": {
110+
"type": 1,
111+
"id": 8074,
112+
"country": "JP",
113+
"sunrise": 1573160942,
114+
"sunset": 1573198819
115+
},
116+
"timezone": 32400,
117+
"id": 1850147,
118+
"name": "Tokyo",
119+
"cod": 200
120+
},
121+
{
122+
"coord": { "lon": 72.85, "lat": 19.01 },
123+
"weather": [
124+
{ "id": 721, "main": "Sunny", "description": "sunny", "icon": "50d" }
125+
],
126+
"base": "stations",
127+
"main": {
128+
"temp": 303.85,
129+
"pressure": 1008,
130+
"humidity": 79,
131+
"temp_min": 302.15,
132+
"temp_max": 305.93
133+
},
134+
"visibility": 4000,
135+
"wind": { "speed": 5.1, "deg": 260 },
136+
"clouds": { "all": 75 },
137+
"dt": 1573207302,
138+
"sys": {
139+
"type": 1,
140+
"id": 9052,
141+
"country": "IN",
142+
"sunrise": 1573175518,
143+
"sunset": 1573216361
144+
},
145+
"timezone": 19800,
146+
"id": 1275339,
147+
"name": "Mumbai",
148+
"cod": 200
149+
},
150+
{
151+
"coord": { "lon": 151.22, "lat": -33.85 },
152+
"weather": [
153+
{
154+
"id": 802,
155+
"main": "Clouds",
156+
"description": "scattered clouds",
157+
"icon": "03n"
158+
}
159+
],
160+
"base": "stations",
161+
"main": {
162+
"temp": 291.33,
163+
"pressure": 1006,
164+
"humidity": 37,
165+
"temp_min": 289.82,
166+
"temp_max": 293.15
167+
},
168+
"visibility": 10000,
169+
"wind": { "speed": 11.8, "deg": 240, "gust": 17 },
170+
"clouds": { "all": 31 },
171+
"dt": 1573207399,
172+
"sys": {
173+
"type": 1,
174+
"id": 9600,
175+
"country": "AU",
176+
"sunrise": 1573152549,
177+
"sunset": 1573201711
178+
},
179+
"timezone": 39600,
180+
"id": 2147714,
181+
"name": "Sydney",
182+
"cod": 200
183+
}
184+
]

0 commit comments

Comments
 (0)